
/**
 * Tab切换类库
 */
TabClass = function (config)
{
	this.tabName	= config.tabName;	//Tab的名称前缀
	this.cntName	= config.cntName;	//Tab的内容前缀
	this.number		= config.number;	//Tab的个数
	this.tabShowCls = config.tabShowCls;//活动的Tab的Class
	if (config.tabHiddenCls)
		this.tabHiddenCls = config.tabHiddenCls;//非活动的Tab的Class
	else
		this.tabHiddenCls = '';
	if (config.cntShowCss)
		this.cntShowCss	= config.cntShowCss;//非活动的Tab的内容的样式
	else
		this.cntShowCss	= 'block';

	this.show = function(index){
		for (var i=0; i<this.number; i++) {
			if (i!=index) {
				$('#'+this.tabName+'_'+i).removeClass(this.tabShowCls);
				if (this.tabHiddenCls)
					$('#'+this.tabName+'_'+i).addClass(this.tabHiddenCls);
				$('#'+this.cntName+'_'+i).css('display', 'none');
			}
			else {
				if (this.tabHiddenCls)
					$('#'+this.tabName+'_'+i).removeClass(this.tabHiddenCls);
				$('#'+this.tabName+'_'+i).addClass(this.tabShowCls);
				$('#'+this.cntName+'_'+i).css('display', this.cntShowCss);
			}
		}
	}
}

// Special ver for Index Map hot point switch
TabClassMap = function (config)
{
	this.tabName	= config.tabName;	//Tab的名称前缀
	this.cntName	= config.cntName;	//Tab的内容前缀
	this.number		= config.number;	//Tab的个数
	this.tabShowCls = config.tabShowCls.split("@");//活动的Tab的Class,多个用@分割
	if (config.tabHiddenCls)
		this.tabHiddenCls = config.tabHiddenCls
	else
		this.tabHiddenCls = '';
	if (config.cntShowCss)
		this.cntShowCss	= config.cntShowCss;//非活动的Tab的内容的样式
	else
		this.cntShowCss	= 'block';

	this.show = function(index){
		for (var i=0; i<this.number; i++) {
			if (i!=index) {
				$('#'+this.tabName+'_'+i).removeClass(this.tabShowCls[0]);
				$('#'+this.tabName+'_'+i).removeClass(this.tabShowCls[1]);
				if (this.tabHiddenCls)
					$('#'+this.tabName+'_'+i).addClass(this.tabHiddenCls);
				$('#'+this.cntName+'_'+i).css('display', 'none');
			}
			else {
				if (this.tabHiddenCls)
					$('#'+this.tabName+'_'+i).removeClass(this.tabHiddenCls);
				var tab_str = $('#'+this.tabName+'_'+i).text();
				var tab_str_len = tab_str.length;
				var templen = tab_str_len;
				for(var j=0;j<tab_str_len;j++)
				{
					var rstr=escape(tab_str.substring(j,j+1));
					if (rstr.substring(0,2)=="%u")
					{
						templen++;
					}
				}
				if(templen > 6)
					$('#'+this.tabName+'_'+i).addClass(this.tabShowCls[1]);
				else
					$('#'+this.tabName+'_'+i).addClass(this.tabShowCls[0]);
				$('#'+this.cntName+'_'+i).css('display', this.cntShowCss);
			}
		}
	}
}