﻿// JavaScript Document
//全局
/* 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 hiddenObj(ObjId) { GetObj(ObjId).style.display = "none" } function showObj(ObjId) { GetObj(ObjId).style.display = "block" }
/* 显示/隐藏一个容器 end */

/* 改变className begin */
function chgClassName(ObjId, className) { GetObj(ObjId).className = className }
/* 改变className end */


/* ========== 舌签构造函数 begin ========== */
var isIE = navigator.appVersion.indexOf("MSIE") != -1 ? true : false; function SubShowClass(ID, eventType, defaultID, openClassName, closeClassName) { this.version = "1.0"; this.author = "mengjia"; this.parentObj = SubShowClass.$(ID); if (this.parentObj == null) {return; }; 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 (isIE) { this.parentObj.attachEvent("onmouseover", mouseInFunc) } else { this.parentObj.addEventListener("mouseover", mouseInFunc, false) }; if (isIE) { 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) { return; }; 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 (isIE) { SubShowClass.$(labelID).attachEvent("on" + this.eventType, tempFunc) } else { SubShowClass.$(labelID).addEventListener(this.eventType, tempFunc, false) }; if (TempID == this.defaultID) { SubShowClass.$(labelID).className = this.openClassName; if (SubShowClass.$(contID)) { SubShowClass.$(contID).style.display = "" }; if (parentBg != null) { this.parentObj.style.background = parentBg }; if (springEvent != null) { eval(springEvent) } } else { SubShowClass.$(labelID).className = this.closeClassName; if (SubShowClass.$(contID)) { SubShowClass.$(contID).style.display = "none" } }; if (SubShowClass.$(contID)) { if (isIE) { SubShowClass.$(contID).attachEvent("onmouseover", mouseInFunc) } else { SubShowClass.$(contID).addEventListener("mouseover", mouseInFunc, false) }; if (isIE) { SubShowClass.$(contID).attachEvent("onmouseout", mouseOutFunc) } else { SubShowClass.$(contID).addEventListener("mouseout", mouseOutFunc, false) } } };  this.select = function(num) { if (typeof (num) != "number") { throw new Error("select(num)参数错误:num 不是 number 类型!") }; var i; for (i = 0; i < this.label.length; i++) { if (i == num) { SubShowClass.$(this.label[i][0]).className = this.openClassName; if (SubShowClass.$(this.label[i][1])) { SubShowClass.$(this.label[i][1]).style.display = "" }; 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) { 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()参数错误:参数数量与标签数量不符!") }; var sum = 0, i; for (i = 0; i < arguments.length; i++) { sum += arguments[i] }; 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 + "].nextLabel()", this.spaceTime); this.autoPlay = true }; this.nextLabel = function() { if (this.autoPlay == false || this.mouseIn == true) { return }; var index = this.selectedIndex; index++; if (index >= this.label.length) { index = 0 }; this.select(index) }; 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) } }
/* ========== 舌签构造函数 end ========== */
