// 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 ========== */ // javascript document ///二级菜单//// $(function(){ //subnav $(".nav li").hover(function(){ $("dl",this).css("display","block"); //$(".subnav",this).fadein("3000"); 淡入 //$("dl",this).show("fast"); //滑入 //$(this).addclass("hover"); },function(){ $("dl",this).css("display","none"); //$(".subnav",this).hide("3000"); 淡出 //$("dl",this).hide("fast"); //滑出 //$(this).removeclass("hover"); }); // //中间提示框 //$("#cbtn").click(function(){ //$("#cpop").center(); //}); $("#oalogin").hover(function(){ $("#oa",this).removeclass("dis"); },function(){ $("#oa",this).addclass("dis"); }); }) function checksearch(the) { if(the.key.value=="") { alert("请输入关键字"); the.key.focus(); return false } } //////gotop/////// $(function(){ $(window).scroll(function(){ //只要窗口滚动,就触发下面代码 var scrollt = document.documentelement.scrolltop + document.body.scrolltop; //获取滚动后的高度 if( scrollt >200 ){ //判断滚动后高度超过200px,就显示 $("#gotop").fadein(400); //淡出 }else{ $("#gotop").stop().fadeout(400); //如果返回或者没有超过,就淡入.必须加上stop()停止之前动画,否则会出现闪动 } }); $("#gotop").click(function(){ //当点击标签的时候,使用animate在200毫秒的时间内,滚到顶部 $("html,body").animate({scrolltop:"0px"},200); }); });