/**
 * @fileoverview Giant Interective Group, Inc. Javascript Library v#version.
 * 该Javascript UI库是基于jQuery的扩展。
 * <pre>
 * Copyright (C) 2004-2009 Giant Interective Group, Inc. All rights reserved.
 * 版权所有 2004-2009 上海巨人网络科技有限公司
 * </pre>
 * Download by http://sc.xueit.com
 * @version 1.0.0, #date 2009-04-06
 * @author  Zhangkai
 * Depend on jQuery 1.3.x
 */
 (function($){
	$.fn.downmenu=function(options){
		 var defaults = {                
							  this_in: "tab_selected" 
					  };            
		var options = $.extend(defaults, options); 
		
		$(this).mouseover(function() {
		
			$(this).find("div#"+options.this_in).show(); 
			//$(".nav").css("z-index","-100")
			$(this).hover(function() {}, function(){$(this).find("div#"+options.this_in).hide(); });
		});
		$(this).hover(function() {
			if($(this).hasClass("wid146") ){$(this).addClass("nav_liwid146_hover"); }else{$(this).addClass("nav_li_hover"); }
		}, function(){	
		if($(this).hasClass("wid146") ){$(this).removeClass("nav_liwid146_hover"); }else{$(this).removeClass("nav_li_hover"); }
		});
			
		}//自定义方法indexDownMenu()结束
 })(jQuery);
 (function($){
	$.fn.auto_height=function(options){
		 var defaults = {                
							  this_in: "tab_selected" 
					  };            
		var options = $.extend(defaults, options); 
		$('.left').css("height","500px");
		var right_h=$('.right').height();
		if(right_h>500){$(".left").height(right_h+40);}else{$(".right").height(500);$(".left").height(540);}
		
		$(this).resize(function(){
					var right_h=$('.right').height();
					if(right_h>500){$(".left").height(right_h+40);}else{$(".right").height(500);}				
		});
			
		}//自定义方法indexDownMenu()结束
 })(jQuery);
(function($){
	$.fn.downlang=function(options){
		 var defaults = {                
							  this_in: "tab_selected" 
					  };            
		var options = $.extend(defaults, options); 
		
		$(this).mouseover(function() {
		
			$(this).find("div."+options.this_in).show();
			
			$(".lang_a").css("z-index","30000");
			$(".lang_a").addClass("lang_a_hover");
			$(".lang_in").css("z-index","-11");
			
			$(this).hover(function() {}, function(){$(this).find("div."+options.this_in).hide();$(".lang_a").removeClass("lang_a_hover");});
		});
		$(this).hover(function() { 
			$(this).addClass(""); 				 
		}, function(){	
		$(this).removeClass(""); 
		});
			
		}//自定义方法indexDownMenu()结束
 })(jQuery);
 
 
 
 (function($) {
    var isShow = false;
    $.fn.tab = function(options) {
        this.opts = $.extend({},$.fn.tab.defaults, options);
		this._init();
		this.disableArr=[];
	}	
	$.fn.tab.prototype={
		_init:function(){
			var _this = this;
			if($(_this.opts.tabList).length>0){
				$(_this.opts.tabList).each(function(index){
						$(this).bind(_this.opts.eventType,function(){
							//判断是否禁用，是否效果还在执行中，是否在当前选中的按钮上
							if($.inArray(index,_this.disableArr)==-1&&(!isShow)&&$(this).attr("class").indexOf(_this.opts.tabActiveClass)==-1){
								//callback
								if(_this.opts.callBackStartEvent){
									_this.opts.callBackStartEvent(index);
								}
								$(_this.opts.tabList).removeClass(_this.opts.tabActiveClass);
								$(this).addClass(_this.opts.tabActiveClass);
								_this._showContent(index);
							}
						});
					});
			}
		},
		_showContent:function(index){
			isShow = true;
			var _this = this;
			switch(_this.opts.showType){
				case "show":
					$(_this.opts.contentList+":visible").hide();
					//callback
					if(_this.opts.callBackHideEvent){
						_this.opts.callBackHideEvent(index);
					}
					$(_this.opts.contentList).eq(index).show();
					if(_this.opts.callBackShowEvent){
						_this.opts.callBackShowEvent(index);
					}
					isShow =false;
					break;
				case "fade":
					$(_this.opts.contentList+":visible").fadeOut(_this.opts.showSpeed,function(){
						//callback
						if(_this.opts.callBackHideEvent){
							_this.opts.callBackHideEvent(index);
						}
						$(_this.opts.contentList).eq(index).fadeIn(function(){
							//callback
							if(_this.opts.callBackShowEvent){
								_this.opts.callBackShowEvent(index);
							}
							isShow =false;
						});
					});
					break;
				case "slide":
					$(_this.opts.contentList+":visible").slideUp(_this.opts.showSpeed,function(){
						//callback
						if(_this.opts.callBackHideEvent){
							_this.opts.callBackHideEvent(index);
						}
						$(_this.opts.contentList).eq(index).slideDown(function(){
							//callback
							if(_this.opts.callBackShowEvent){
								_this.opts.callBackShowEvent(index);
							}
							isShow =false;
						});
					});
					break;
			}
		},
		setDisable:function(index){
			//如果不存在
			var _this = this;
			if($.inArray(index,this.disableArr)==-1){
				this.disableArr.push(index);
				$(_this.opts.tabList).eq(index).addClass(_this.opts.tabDisableClass);
			}
		},
		setEnable:function(index){
			//如果不存在
			var _this = this;
			var i =$.inArray(index,this.disableArr);
			if(i>-1){
				this.disableArr.splice(i,1);
				$(_this.opts.tabList).eq(index).removeClass(_this.opts.tabDisableClass);
			}
		},
		triggleTab:function(index){
			$(this.opts.tabList).eq(index).trigger(this.opts.eventType);
		}
	}
    $.fn.tab.defaults = {
	   tabList:".ui-tab-container .ui-tab-list li",
	   contentList:".ui-tab-container .ui-tab-content",
       tabActiveClass:"ui-tab-active",
	   tabDisableClass:"ui-tab-disable",
	   eventType:"click",									//触发事件，有click和mouseover两种类型
	   showType:"show",										//显示方式，show 直接显示，fade渐变，slide滑动
	   showSpeed:200,										//显示速度，单位为毫秒
	   callBackStartEvent:null,
	   callBackHideEvent:null,
	   callBackShowEvent:null
    };
})(jQuery);
