(function(){ //清除所有input的value function clearvalue(forms){ this.forms = forms; this.load(); } clearvalue.prototype = { constructor : this, load : function(){ var _this = this; this.forms.each(function(){ _this.clearvalue($(this)); }); }, clearvalue : function(fm){ this.inputs = $("input.text,input.keyword",fm); this.textarea = $("textarea",fm); var _this = this; var dvalues = []; var avalues = []; this.inputs.each(function(n){ dvalues[n] = $(_this.inputs[n]).val(); }); this.textarea.each(function(n){ avalues[n] = $(_this.textarea[n]).html(); }); this.inputs.each(function(n){ $(this).focus(function(){ if($(this).val() == dvalues[n]){ $(this).val(""); $(this).removeclass("text_hover"); } }); $(this).blur(function(){ if($(this).val() == ""){ $(this).val(dvalues[n]); $(this).removeclass("text_hover"); }else{ $(this).addclass("text_hover"); } }); }); this.textarea.each(function(n){ $(this).focus(function(){ if($(this).html() == avalues[n]){ $(this).html(""); $(this).removeclass("text_hover"); } }); $(this).blur(function(){ if($(this).html() == ""){ $(this).html(avalues[n]); $(this).removeclass("text_hover"); }else{ $(this).addclass("text_hover"); } }); }); } }; window.clearvalue = clearvalue; //清除所有input的value //changediv切换效果 function changediv(args){ for(var i in args){ this[i] = args[i]; } this.type = this.type ? this.type : "mouseover"; this.load(); } changediv.prototype = { constructor : this, load : function(){ var _this = this; this.btns.each(function(num){ if(_this.type == "click"){ $(this).click(function(){ _this.change(num) }); }else{ $(this).mouseover(function(){ _this.change(num) }); } }); }, change : function(num){ var _this = this; this.btns.each(function(n){ if(n ==num){ $(this).addclass("hover"); }else{ $(this).removeclass("hover"); } }); this.divs.each(function(n){ if(n ==num){ $(this).addclass("show"); }else{ $(this).removeclass("show"); } }); } }; window.changediv = changediv; //changediv切换效果 //顶端adver渐隐 function fadeadver(args){ for(var i in args){ this[i] = args[i]; } this.speed = args.speed ? args.speed : 5000; //间隔时间默认5秒 this.stime = args.stime ? args.stime : 500; //渐进时间,默认1秒 this.load(); this.start(); } fadeadver.prototype ={ constructor : this, load : function(){ var _this = this; this.num = 0; //计时器 this.mnum = this.num+1; //轮播计时 this.len = this.divs.length; //所有div设置absolute并排好index this.divs.each(function(num){ var z_index = 50-num; $(this).css({ "position" : "absolute", "left" : 0, "top" : 0, "z-index" : z_index, "display" : "none" }) }); $(this.divs[0]).show(); //所有div设置absolute并排好index this.btns.each(function(num){ $(this).mouseover(function(){ _this.show(num); _this.stop(); }).mouseout(function(){ _this.start(); }); }); //左右按钮的使用 if(!!this.prebtn && !!this.nextbtn){ this.prebtn.css("z-index",60); this.prebtn.click(function(){ var num = _this.num - 1; if(num < 0){ num = _this.len-1; } _this.show(num); }); this.nextbtn.css("z-index",60); this.nextbtn.click(function(){ var num = _this.num + 1; if(num >= _this.len){ num = 0; } _this.show(num); }); } this.divs.each(function(num){ $(this).mouseover(function(){ _this.stop(); }).mouseout(function(){ _this.start(); }); }); }, show : function(num){ if(num == this.num) return; //同一个返回 var _this = this; this.flag = false; //关闭控制开关 this.btns.each(function(i){ if(i == num){ $(this).addclass("hover"); }else{ $(this).removeclass("hover"); } }); $(this.divs[this.num]).fadeout(this.stime); //旧的淡出 $(this.divs[num]).fadein(_this.stime); //新的淡入 _this.num = num; _this.mnum = num+1; }, start : function(){ var _this = this; this.interval = setinterval(function(){ if(_this.mnum >= _this.len){ _this.mnum = 0; } _this.show(_this.mnum); },this.speed); }, stop : function(){ clearinterval(this.interval); } }; window.fadeadver = fadeadver; //顶端adver })(); $(function(){ new clearvalue($("form")); //清除默认文字 //head_map的下拉效果 $(".map_handle .handle_btn").click(function(){ if(!$(".head_map").hasclass("show")){ $(".head_map").addclass("show"); }else{ $(".head_map").removeclass("show"); } }); //nav下拉菜单 $(".nav_in").hover(function(){ $("ul",this).slidedown("fast"); $(this).addclass("nav_hover"); },function(){ var _this = this; if($("ul",this).length != 0){ $("ul",this).slideup("fast",function(){ $(_this).removeclass("nav_hover"); }); }else{ $(_this).removeclass("nav_hover"); } }); });