//GetObj begin
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else if(document.layers){return eval("document.layers['"+objName+"']")}else{return eval('document.all.'+objName)}}
//GetObj end

//添加到收藏 begin
function bookmarkit(url,name){
	window.external.addFavorite(url,name);
}
//添加到收藏 end

/*
舌签构造函数
SubShowClass(ID[,eventType][,defaultID][,openClassName][,closeClassName])
version 1.21

参数说明：
	ID: String类型，舌签主容器ID，必须存在的ID，如果为空，必须指定为"none"
	eventType: String类型，默认触发事件，可选，默认为"onmousedown"，参数范围（mousedown,onmouseover,onmouseout,onclick,onmouseup）
	defaultID: Number类型，默认打开第N项，可选，默认为0，范围（0～length-1）
	openClassName: String类型，打开标签项的className，可选，默认为"selected"
	closeClassName: String类型，关闭标签项的className，可选，默认为""

方法1：addLabel(labelID[,contID][,parentBg][,springEvent][,blurEvent])
	功能：
		添加一个标签。
	参数说明：
		labelID: String类型，标签的ID，必须存在的ID，如果为空，必须指定为"none"
		contID: String类型，标签对应的内容ID，可选，如果不存在，标签切换将不对内容进行操作
		parentBg: String类型，当切换到该标签时重置主容器背景CSS，可选，默认为""，格式为CSS样式的background属性，如：url(images/abc.gif) no-repeat 2px 3px #fff
		springEvent: String类型，当切换到该标签时执行的JavaScript代码，可选
		blurEvent: String类型，当标签从打开状态恢复时执行的JavaScript代码，可选
		
方法2：select(num,force)
	功能：
		打开第num项。
	参数说明：
		num: Number类型，要打开项的编号，必须的，从0开始，范围（0～length-1）
		force: 布尔型，如果值等于true强行遍历所有标签，并执行各标签所绑定的springEvent和blurEvent事件。如不指定为true，则只执行新打开标签的springEvent和所要关闭标签的blurEvent事件。
	
方法3：random(num[,num][,num][...])
	功能：
		随机打开其中一项。此方法应该在添加标签(addLabel())之后使用。
	参数说明：
	num: Number类型，每项的随机概率
		参数的个数必须与标签个数相同。如三个标签的舌签按1:1:1随机打开 random(1,1,1)，按1:2:3随机打开 random(1,2,3)
	
方法4：play([spaceTime])
	功能：
		每隔spaceTime毫秒自动切换到下一个标签，鼠标移入到舌签与内容时暂停。此方法应该在添加标签(addLabel())之后使用。
	参数说明：
		spaceTime: Number类型，间隔时间，单位毫秒，默认为5000毫秒(1秒 = 1000毫秒)

方法5：stop()
	功能：
		停止自动播放。

方法6：nextLabel()
	功能：
		切换到下一个标签。如果当前是最后一个标签，则切换到第一个标签。此方法应该在添加标签(addLabel())之后使用。

方法7：previousLabel()
	功能：
		切换到上一个标签。如果当前是第一个标签，则切换到最后一个标签。此方法应该在添加标签(addLabel())之后使用。

例：
//注意：JS必须放在HTML后面，特别要注意要放在内容的后面
var SubShow_01 = new SubShowClass("T_Menu_01","onmouseover",0,"onClassName","offClassName");//String 主ID(必须的)，String 触发事件(onmouseover)，Number 默认打开项(0)，String 打开项className(selectd)，String 关闭项className(空)
SubShow_01.addLabel("S_Menu_00","S_Cont_00","url(images/1.gif) no-repeat 0 0","window.status='1打开了'","window.status='1关闭了'");//String 标签ID(必须的)，String 内容ID(null)，String 重置主容器背景CSS(null)，String 绑定触发事件(null)，String 绑定恢复事件(null)
SubShow_01.addLabel("S_Menu_01","S_Cont_01","url(images/2.gif) no-repeat 0 0","window.status='2打开了'","window.status='2关闭了'");
SubShow_01.addLabel("S_Menu_02","S_Cont_02","url(images/3.gif) no-repeat 0 0","window.status='3打开了'","window.status='3关闭了'");
SubShow_01.random(1,1,1); //随机打开，参数列表为比率，参数数量必须与标签数量相等
SubShow_01.play(5000);

//SubShow_01.select(1); //用来接打开指定项

*/

function SubShowClass(ID,eventType,defaultID,openClassName,closeClassName){
	this.version = "1.21";
	this.author = "mengjia";
	this.parentObj = SubShowClass.$(ID); //舌签主容器ID
	if(this.parentObj == null && ID != "none"){throw new Error("SubShowClass(ID)参数错误:ID 对像存在!(value:" + ID + ")")};
	
	//舌签对象压栈
	if(!SubShowClass.childs){ //创建栈
		SubShowClass.childs = new Array();
	};
	this.ID = SubShowClass.childs.length;
	SubShowClass.childs.push(this);
	
	this.lock = false; //锁
	this.label = [];
	
	this.defaultID = defaultID==null?0:defaultID;
	
	this.selectedIndex = this.defaultID;
	
	this.openClassName = openClassName==null?"selected":openClassName;
	this.closeClassName = closeClassName==null?"":closeClassName;
	
	//鼠标移入移出
	this.mouseIn = false;
	var mouseInFunc = Function("SubShowClass.childs[" + this.ID + "].mouseIn = true");
	var mouseOutFunc = Function("SubShowClass.childs[" + this.ID + "].mouseIn = false");
	if(ID != "none"){if(this.parentObj.attachEvent){this.parentObj.attachEvent("onmouseover",mouseInFunc)}else{this.parentObj.addEventListener("mouseover",mouseInFunc,false)};};
	if(ID != "none"){if(this.parentObj.attachEvent){this.parentObj.attachEvent("onmouseout",mouseOutFunc)}else{this.parentObj.addEventListener("mouseout",mouseOutFunc,false)};};
	
	if(typeof(eventType) != "string"){eventType = "onmousedown"};
	eventType = eventType.toLowerCase(); //触发事件
	switch(eventType){
		case "onmouseover":
			this.eventType = "mouseover";
			break;
		case "onmouseout":
			this.eventType = "mouseout";
			break;
		case "onclick":
			this.eventType = "click";
			break;
		case "onmouseup":
			this.eventType = "mouseup";
			break;
		default :
			this.eventType = "mousedown";
	};
		
	//添加标签
	this.addLabel = function(labelID,contID,parentBg,springEvent,blurEvent){ 
		if(SubShowClass.$(labelID) == null && labelID != "none"){throw new Error("addLabel(labelID)参数错误:labelID 对像存在!(value:" + labelID + ")")};
		var TempID = this.label.length;
		if(parentBg==""){parentBg=null};
		
		this.label.push([labelID,contID,parentBg,springEvent,blurEvent]); //绑定默认事件
		var tempFunc = Function('SubShowClass.childs[' + this.ID + '].select(' + TempID + ')');
		if(labelID != "none"){if(SubShowClass.$(labelID).attachEvent){SubShowClass.$(labelID).attachEvent("on" + this.eventType,tempFunc)}else{SubShowClass.$(labelID).addEventListener(this.eventType,tempFunc,false)};};
		
		if(TempID == this.defaultID){ //默认状态
			if(labelID != "none"){SubShowClass.$(labelID).className = this.openClassName;};
			if(SubShowClass.$(contID)){SubShowClass.$(contID).style.display = ""};
			if(ID != "none"){if(parentBg != null){this.parentObj.style.background = parentBg};};
			if(springEvent != null){eval(springEvent)};
		}else{
			if(labelID != "none"){SubShowClass.$(labelID).className = this.closeClassName;};
			if(SubShowClass.$(contID)){SubShowClass.$(contID).style.display = "none";}
		};
		
		//鼠标移入移出
		if(SubShowClass.$(contID)){
			if(SubShowClass.$(contID).attachEvent){SubShowClass.$(contID).attachEvent("onmouseover",mouseInFunc)}else{SubShowClass.$(contID).addEventListener("mouseover",mouseInFunc,false)};
			if(SubShowClass.$(contID).attachEvent){SubShowClass.$(contID).attachEvent("onmouseout",mouseOutFunc)}else{SubShowClass.$(contID).addEventListener("mouseout",mouseOutFunc,false)};
		}
		
	};
	//选择标签
	this.select = function(num,force){
		if(typeof(num)!="number"){throw new Error("select(num)参数错误:num 不是 number 类型!(value:" + num + ")")};
		if(force != true && this.selectedIndex == num){return};
		var i;
		for(i=0;i<this.label.length;i++){
			if(i==num){
				if(this.label[i][0] != "none"){SubShowClass.$(this.label[i][0]).className = this.openClassName;};
				if(SubShowClass.$(this.label[i][1])){SubShowClass.$(this.label[i][1]).style.display = ""};
				if(ID != "none"){if(this.label[i][2]!=null){this.parentObj.style.background = this.label[i][2]};};
				if(this.label[i][3]!=null){eval(this.label[i][3])};
				
			}else if(this.selectedIndex == i || force == true){
				if(this.label[i][0] != "none"){SubShowClass.$(this.label[i][0]).className = this.closeClassName;};
				if(SubShowClass.$(this.label[i][1])){SubShowClass.$(this.label[i][1]).style.display = "none"};
				if(this.label[i][4]!=null){eval(this.label[i][4])};
			}
		};
		this.selectedIndex = num;
	};
	//随机
	this.random = function(){ //随机，参数为一组数字，表示百分比
		if(arguments.length != this.label.length){throw new Error("random()参数错误:参数数量与标签数量不符!(length:" + arguments.length + ")")};
		var sum = 0,i;
		for(i=0;i<arguments.length;i++){sum+=arguments[i]}; //sum
		var randomNum = Math.random(),percent = 0;
		for(i=0;i<arguments.length;i++){
			percent += arguments[i]/sum;
			if(randomNum < percent){
				this.select(i);
				break;
			}
		}
	};
	
	//播放停止
	this.autoPlay = false;
	var autoPlayTimeObj = null;
	this.spaceTime = 5000;
	this.play = function(spTime){ //播放
		if(typeof(spTime) == "number"){this.spaceTime = spTime};
		clearInterval(autoPlayTimeObj);
		autoPlayTimeObj = setInterval("SubShowClass.childs[" + this.ID + "].autoPlayFunc()",this.spaceTime);
		this.autoPlay = true;
	};
	this.autoPlayFunc = function(){
		if(this.autoPlay == false || this.mouseIn == true){return};
		this.nextLabel();
	};
	this.nextLabel = function(){ //下一个
		var index = this.selectedIndex;
		index ++;
		if(index >= this.label.length){index = 0};
		this.select(index);
		if(this.autoPlay == true){
			clearInterval(autoPlayTimeObj);
			autoPlayTimeObj = setInterval("SubShowClass.childs[" + this.ID + "].autoPlayFunc()",this.spaceTime);
		};
	};
	this.previousLabel = function(){ //上一个
		var index = this.selectedIndex;
		index --;
		if(index < 0){index = this.label.length - 1};
		this.select(index);
		if(this.autoPlay == true){
			clearInterval(autoPlayTimeObj);
			autoPlayTimeObj = setInterval("SubShowClass.childs[" + this.ID + "].autoPlayFunc()",this.spaceTime);
		};
	};
	this.stop = function(){
		clearInterval(autoPlayTimeObj);
		this.autoPlay = false;
	}
};
SubShowClass.$ = function(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}