//css判断 function supportcss3(style) { var prefix = ['webkit', 'moz', 'ms', 'o'], i, humpstring = [], htmlstyle = document.documentelement.style, _tohumb = function(string) { return string.replace(/-(\w)/g, function($0, $1) { return $1.touppercase(); }); }; for (i in prefix) humpstring.push(_tohumb(prefix[i] + '-' + style)); humpstring.push(_tohumb(style)); for (i in humpstring) if (humpstring[i] in htmlstyle) return true; return false; } function ckall(e,t){ if($(e).attr("checked")){ $(t).find("input").attr("checked",true); $(t).addclass("act"); } else{ $(t).find("input").attr("checked",false); $(t).removeclass("act"); } } //响应试 var sto_css; function ccss(maxw,minw,cla){ var ww=$(window).width() if(ww>=minw && ww<=maxw){ $("html").addclass(cla); } else{ $("html").removeclass(cla); } $(window).resize(function(){ cleartimeout(sto_css); sto_css=settimeout(function(){ ccss(maxw,minw,cla); },500); }); } //滚动触发 function scrollact(e,fix){ if(!fix){fix=0;} if($(window).scrolltop()>=$(e).offset().top-fix){ return true; } if($(window).scrolltop()+$(window).height()>=$(e).offset().top+$(e).height()-fix){ return true; } } //弹出层 function showlayer(e){ $(e).css({margintop:$(e).outerheight()*-0.5}); $(e).show(); $(".shadow").fadein(300); } function hidelayer(e){ $(e).hide(); $(".shadow").fadeout(300); } //自动调整底部,配合相应class function autofoot(){ var wh=$(window).height(); var dh=$(document.body).height(); if($("#footer").attr("class")=="footb"){ dh=$(document.body).height()+$("#footer").height();; } if(wh>dh){ $("#footer").addclass("footb"); } else{ $("#footer").removeclass("footb"); } } //根据dom的w和h属性配合type进行尺寸及定位的计算 function autodiv(e,type){ $(e).each(function(index, element) { if(type=="h"){ $(this).width("100%"); $(this).height($(this).width()/$(this).attr("w")*$(this).attr("h")); } if(type=="v"){ $(this).height("100%"); $(this).width($(this).height()/$(this).attr("h")*$(this).attr("w")); } if(type=="c"){ $(this).width($(this).parent().width()/$(this).parent().attr("w")*$(this).attr("w")); $(this).height($(this).parent().height()/$(this).parent().attr("h")*$(this).attr("h")); $(this).css("left",$(this).parent().width()/$(this).parent().attr("w")*$(this).attr("l")); $(this).css("top",$(this).parent().height()/$(this).parent().attr("h")*$(this).attr("t")); } }); } //建立下拉列表功能 function selector(e){ $(e).each(function(){ s=$(this); s.click(function(){ s.find("ul").show(); }); s.mouseleave(function(){ s.find("ul").hide(); }); s.find("li").click(function(){ s.find("input").val($(this).text()); s.find("ul").hide(); }); }); } //新tab切换 function tabdiv(tab,div,event,speed){ speed=isnan(speed)?0:speed; $(div).each(function(index, element) { $(this).attr("idx",index); }); $(tab).each(function(index, element) { $(this).bind(event,function(){ $(tab).removeclass("now"); $(this).addclass("now"); $(div+"[idx='"+index+"']").fadein(speed); $(div+"[idx!='"+index+"']").stop(true,true).hide(); }); }); } //数字初始化效果 function numshow(e,t){ if(t=="")t=1; var stv1; var x=parseint($(e).text()); var y=0; if(x>=100){ var z=parseint(x/100); var t=10*t; } else{ var z=1; t=150*t; } var stv1=setinterval(function(){ y=y+z; $(e).text(y); if(y+z>=x){ $(e).text(x); clearinterval(stv1); } },t); } //获取日期 function getdate(e){ var day=""; var month=""; var ampm=""; var ampmhour=""; var myweekday=""; var year=""; mydate=new date(); myweekday=mydate.getday(); mymonth=mydate.getmonth()+1; myday= mydate.getdate(); myyear= mydate.getyear(); year=(myyear > 200) ? myyear : 1900 + myyear; if(myweekday == 0) weekday=" 星期日 "; else if(myweekday == 1) weekday=" 星期一 "; else if(myweekday == 2) weekday=" 星期二 "; else if(myweekday == 3) weekday=" 星期三 "; else if(myweekday == 4) weekday=" 星期四 "; else if(myweekday == 5) weekday=" 星期五 "; else if(myweekday == 6) weekday=" 星期六 "; $(e).text(year+"年"+mymonth+"月"+myday+"日 "+weekday) } //设置cookie function setcookie(c_name,value,expiredays){ var exdate=new date() exdate.setdate(exdate.getdate()+expiredays) document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.togmtstring()); } function getcookie(c_name){ if(document.cookie.length>0){ c_start=document.cookie.indexof(c_name + "=") if(c_start!=-1){ c_start=c_start + c_name.length+1 c_end=document.cookie.indexof(";",c_start) if(c_end==-1)c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)) } } return ""; } //是否支持html5 function ishtml5(){ if(typeof(worker)!=="undefined"){ return true; } else{ return false; } } //是否支持css3 function iscss3(style) { var prefix = ['webkit', 'moz', 'ms', 'o'], i, humpstring = [], htmlstyle = document.documentelement.style, _tohumb = function(string) { return string.replace(/-(\w)/g, function($0, $1) { return $1.touppercase(); }); }; for (i in prefix) humpstring.push(_tohumb(prefix[i] + '-' + style)); humpstring.push(_tohumb(style)); for (i in humpstring) if (humpstring[i] in htmlstyle) return true; return false; } //获取随机数 function getrandomnum(min,max){ var range = max - min; var rand = math.random(); return(min + math.round(rand * range)); } //初始化jquery时间插件 function loaddate(e,lang){ if(lang=="zh"){ $.datepicker.regional["zh-cn"] = { closetext: "关闭", prevtext: "<上月", nexttext: "下月>", currenttext: "今天", monthnames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], monthnamesshort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"], daynames: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], daynamesshort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"], daynamesmin: ["日", "一", "二", "三", "四", "五", "六"], weekheader: "周", dateformat: "yy-mm-dd", firstday: 1, isrtl: !1, showmonthafteryear: !0, yearsuffix: "年" } $.datepicker.setdefaults($.datepicker.regional["zh-cn"]); } else{ $.datepicker.regional['en-gb'] = { closetext: 'done', prevtext: 'prev', nexttext: 'next', currenttext: 'today', monthnames: ['january','february','march','april','may','june', 'july','august','september','october','november','december'], monthnamesshort: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'], daynames: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'], daynamesshort: ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'], daynamesmin: ['su','mo','tu','we','th','fr','sa'], weekheader: 'wk', dateformat: 'dd/mm/yy', firstday: 1, isrtl: false, showmonthafteryear: false, yearsuffix: ''}; $.datepicker.setdefaults($.datepicker.regional['en-gb']); $('#date').datepicker('option', $.datepicker.regional['en-gb']); } //var datepicker = $("#ctl00_bodymain_txtdate").datepicker({ //howothermonths: true, //selectothermonths: true //}); /*$( "#from" ).datepicker({ defaultdate: "+1w", changemonth: true, numberofmonths: 1, onclose: function( selecteddate ) { $( "#to" ).datepicker( "option", "mindate", selecteddate ); } }); $( "#to" ).datepicker({ defaultdate: "+1w", changemonth: true, numberofmonths: 1, onclose: function( selecteddate ) { $( "#from" ).datepicker( "option", "maxdate", selecteddate ); } });*/ //$("#from").datepicker("option", "dateformat", "yy-mm-dd"); //$("#to").datepicker("option", "dateformat", "yy-mm-dd"); } //var t=new date(); //var start=t.getfullyear()+"-"+(t.getmonth()+1)+"-"+t.getdate()+" "+t.gethours()+":"+t.getminutes()+":"+t.getseconds() //var end="2015-03-27"; //$(".time p").html(countdate(start,end)); function countdate(start,end){ //创建date变量: start = date.parse(start.replace(/-/g,"/")); var date1 = new date(start); //开始时间 end = date.parse(end.replace(/-/g,"/")); var date2=new date(end); //结束时间 var date3=date2.gettime()-date1.gettime() //时间差的毫秒数 //计算出相差天数 var days=math.floor(date3/(24*3600*1000)); //计算出小时数 var leave1=date3%(24*3600*1000) //计算天数后剩余的毫秒数 var hours=math.floor(leave1/(3600*1000)); if(hours<10 && hours>=0){hours="0"+hours;} if(hours<0){hours="00";} //计算相差分钟数 var leave2=leave1%(3600*1000) //计算小时数后剩余的毫秒数 var minutes=math.floor(leave2/(60*1000)); if(minutes<10 && minutes>=0){minutes="0"+minutes;} if(minutes<0){minutes="00";} //计算相差秒数 var leave3=leave2%(60*1000) //计算分钟数后剩余的毫秒数 var seconds=math.round(leave3/1000); if(seconds<10 && seconds>=0){seconds="0"+seconds;} if(seconds<0){seconds="00";} //var now=hours+":"+minutes+":"+seconds; //var now=""+days+"天  "+hours+"小时  "+minutes+"分"; return now; } function mjump(url){ var ua=navigator.useragent.tolowercase(); if(ua.match(/ipad/i)=="ipad" || ua.match(/iphone/i)=="iphone" || ua.match(/android/i)=="android") { location=url; } } //字数判断 function limitword(e,x,fn){ $(e).bind('propertychange input',function(){ if($(this).val().length<=x){ return fn(x-$(this).val().length); } else{ return fn(0); } }); }