//自动调整底部,配合相应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 autoimg(e, w, h) { var img = new image(); img.src = $(e).attr("src"); img.onload = function() { w1 = img.width; h1 = img.height; if ((w / h) < (w1 / h1)) { if (w1 > w) { $(e).width(w); } $(e).css("margin-top", (h - $(e).height()) * 0.5); } else { if (h1 > h) { $(e).height(h); } else { $(e).css("margin-top", (h - h1) * 0.5); } } } if ((w / h) < (img.width / img.height)) { if (img.width > w) { $(e).width(w); } $(e).css("margin-top", (h - $(e).height()) * 0.5); } else { if (img.height > h) { $(e).height(h); } else { $(e).css("margin-top", (h - img.height) * 0.5); } } } //调整图片充满容器 function autoimg1(e) { var img = new image(); img.src = $(e).attr("src"); img.onload = function() { w1 = img.width; h1 = img.height; if ($(e).parent().width() / $(e).parent().height() >= w1 / h1) { $(e).css({ width: "100%", height: "auto" }); } else { $(e).css({ height: "100%", width: "auto" }); } } if ($(e).parent().width() / $(e).parent().height() >= $(e).width() / $(e).height()) { $(e).css({ width: "100%", height: "auto" }); } else { $(e).css({ height: "100%", width: "auto" }); } } //鼠标滑过时增加指定的class function hover(e, classname, child) { if (classname == undefined) { classname = "hover"; } if (child == undefined) { $(e).hover( function() { $(this).addclass(classname); }, function() { $(this).removeclass(classname); } ); } else { $(e).hover( function() { $(this).find(child).addclass(classname); }, function() { $(this).find(child).removeclass(classname); } ); } } //建立下拉列表功能 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 + "']").hide(); }); }); } //tab切换,最多支持30个 function showdiv(id, idx, fade) { if (!fade) fade = 0; for (var i = 1; i < 30; i++) { if ($("#div" + id + i)) { $("#div" + id + i).hide(); } if ($("#tab" + id + i)) { $("#tab" + id + i).removeclass("now"); } } $("#tab" + id + idx).addclass("now"); if (!fade) { $("#div" + id + idx).show(); } else { $("#div" + id + idx).fadein(fade); } } //原生tab切换 function showdiv1(id, idx) { for (var i = 1; i < 30; i++) { if (document.getelementbyid("div" + id + i)) { document.getelementbyid("div" + id + i).style.display = "none"; } if (document.getelementbyid("tab" + id + i)) { document.getelementbyid("tab" + id + i).classname = document.getelementbyid("tab" + id + i).classname.replace("now", ""); } } document.getelementbyid("tab" + id + idx).classname = document.getelementbyid("tab" + id + idx).classname + " now"; if (document.getelementbyid("div" + id + idx)) { document.getelementbyid("div" + id + idx).style.display = ""; } } //数字初始化效果 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 showslider(id, e, cname) { if (!cname) { cname = "act"; } if (!$(id).attr("h")) { $(id).attr("h", $(id).height()); } $(id).children().wrapall("
"); if ($(id).height() == $(id).attr("h") && $(id).height() < $(id).find(".bd").height()) { $(id).animate({ height: $(id).find(".bd").height() }); } else { $(id).animate({ height: $(id).attr("h") }); } if ($(e).attr("class").match(cname)) { $(e).removeclass(cname); } else { $(e).addclass(cname); } } //弹出层居中,待修改 function divcenter(e, mintop) { $(e).css({ display: 'block', top: -9999 }); var w = $(e).width(); var h = $(e).height(); var top, left; if ($(window).height() > h) { top = $(window).scrolltop() + ($(window).height() - h) * 0.5; } else { top = $(window).scrolltop() + mintop; } left = w * 0.5 * -1; return array(top, left); } function divshow(e, mintop) { var arr = divcenter(e, mintop); var top = arr[0]; var left = arr[1]; $(e).hide(); $(e).css("top", top); $(e).css("margin-left", left); $(e).fadein(); } //获取随机数 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; } }