String.prototype.trim = function () { var str = this, str = str.replace(/^\s+/, ''); for (var i = str.length - 1; i >= 0; i--) { if (/\S/.test(str.charAt(i))) { str = str.substring(0, i + 1); break; } } return str; } Array.prototype.Contain = function (item) { var array = this; for (var i = array.length - 1; i >= 0; i--) { if (array[i] == item) return true; } return false; } var _browser = (function (a) { var r = /(webkit)[ \/]([\w.]+)/, s = /(opera)(?:.*version)?[ \/]([\w.]+)/, t = /(msie) ([\w.]+)/, u = /(mozilla)(?:.*? rv:([\w.]+))?/; var b = r.exec(a) || s.exec(a) || t.exec(a) || a.indexOf("compatible") < 0 && u.exec(a) || []; return { name: b[1] || "", version: b[2] || "0" }; })(window.navigator.userAgent.toLowerCase()); /*取cookies*/ var getCookie = function (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 decodeURIComponent(document.cookie.substring(c_start, c_end)); } } return ""; } var showadvert = function (url, objId) { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var _txt = xmlhttp.responseText; _txt = _txt.replace("document.write(\"", ""); _txt = _txt.replace("\")", ""); _txt = _txt.split("\\").join(""); if (objId) document.getElementById(objId).innerHTML = _txt; } } xmlhttp.open("GET", url, true); xmlhttp.send(); } var showSelectBox = function () { $(document).click(function (event) { var _box = $(".mSelectBox"); var _select = _box.children(".mSelect"); var _list = _box.children(".mSelectList"); if (_browser.name == "msie") { if (event.srcElement.className == "mSelect") { if (_list.css("display") == "block") { _list.css("display", "none"); } else { _list.css("display", "block"); } } else { _list.css("display", "none"); } } else { if ($(event.target).attr("class") == "mSelect") { if (_list.css("display") == "block") { _list.css("display", "none"); } else { _list.css("display", "block"); } } else { _list.css("display", "none"); } } }); } var showNavSelect = function () { $("#nav-all-box").children("li").each(function () { var $this = $(this); var css = $this.attr("class") || ""; if (-1 < css.indexOf("js-dropdown")) { var $dl = $this.children("dl").eq(0); $this.hover( function () { $dl.slideDown("fast"); }, function () { $dl.slideUp("fast"); } ); } }); } var scrollTrend = function () { if (_browser.name == "msie" && parseInt(_browser.version) == 6) { return true; } var position = "fixed"; var b = $("#chartBody"); var p = { t: b.offset().top, h: b.height() }; $("div.scrollBanner").each(function () { var $this = $(this); var st = $(window).scrollTop(); if (st >= p.t && st < p.t + p.h) { $this.css({ position: position, display: "block" }); } else { $this.hide(); } }); } //设为首页 var sethomepage = function (url) { if (document.all) { document.body.style.behavior = 'url(#default#homepage)'; document.body.setHomePage(window.location.href); } else if (window.sidebar) { if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"); } } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', window.location.href); } else { alert('您的浏览器不支持自动设置首页, 请使用浏览器菜单手动设置!'); } } //加入收藏 var addfav = function () { if (document.all) { try { window.external.addFavorite(window.location.href, document.title); } catch (e) { alert("加入收藏失败,请使用Ctrl+D进行添加"); } } else if (window.sidebar) { window.sidebar.addPanel(document.title, window.location.href, ""); } else { alert("加入收藏失败,请使用Ctrl+D进行添加"); } } //图片缩放 参数(图片,允许的宽度,允许的高度) function DrawImage(ImgD, iwidth, iheight) { var image = new Image(); image.src = ImgD.src; if (image.width > 0 && image.height > 0) { if (image.width / image.height >= iwidth / iheight) { if (image.width > iwidth) { ImgD.width = iwidth; ImgD.height = (image.height * iwidth) / image.width; } else { ImgD.width = image.width; ImgD.height = image.height; } } else { if (image.height > iheight) { ImgD.height = iheight; ImgD.width = (image.width * iheight) / image.height; } else { ImgD.width = image.width; ImgD.height = image.height; } } } } //search checkTerm = function (min, max) { var newterm = $("#newterm").val(); newterm = $.trim(newterm); if (isEmpty(newterm)) { $("#newterm").val(""); alert("期数不能为空!"); return false; } if (isNaN(newterm)) { $("#newterm").val(""); alert("请输入正确的期数值!"); return false; } if (!isInteger(newterm)) { $("#newterm").val(""); alert("请输入整数!"); return false; } if (newterm.length >= max || newterm.length <= min) { $("#newterm").val(""); alert("请输入正确的期数格式!"); return false; } $("#newterm").val(newterm); $("#form1").submit(); } isEmpty = function (str) { if (str == "") { return true; } var regu = /^[ ]+$/; var re = new RegExp(regu); return re.test(str); } isInteger = function (str) { var regu = /^\+?[0-9]+$/; var re = new RegExp(regu); return re.test(str); } //农历计算与显示 var CalConv = function (objId) { if (typeof (objId) == "undefined") { return; } var _o = document.getElementById(objId); if (typeof (_o) == "undefined") { return; } var tagLunarCal = function (d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) { this.BaseDays = d; this.Intercalation = i; this.BaseWeekday = w; this.BaseKanChih = k; this.MonthDays = [m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13]; return this; }; var GetLeap = function (year) { if (year % 400 == 0) return 1; else if (year % 100 == 0) return 0; else if (year % 4 == 0) return 1; else return 0; }; var LunarCal = [ tagLunarCal(27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1), tagLunarCal(46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1), /* 88 */ tagLunarCal(35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1), /* 89 */ tagLunarCal(23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), tagLunarCal(42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), tagLunarCal(31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0), tagLunarCal(21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1), /* 93 */ tagLunarCal(39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1), tagLunarCal(28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1), tagLunarCal(48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1), tagLunarCal(37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1), /* 97 */ tagLunarCal(25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), tagLunarCal(44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1), tagLunarCal(33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), tagLunarCal(22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), /* 101 */ tagLunarCal(40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0), tagLunarCal(30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1), tagLunarCal(49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1), tagLunarCal(38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0), /* 105 */ tagLunarCal(27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1), tagLunarCal(46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0), tagLunarCal(35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0), tagLunarCal(24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1), /* 109 */ tagLunarCal(42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), tagLunarCal(31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0), tagLunarCal(21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1), tagLunarCal(40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1), /* 113 */ tagLunarCal(28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0), tagLunarCal(47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1), tagLunarCal(36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1), tagLunarCal(25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0), /* 117 */ tagLunarCal(43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1), tagLunarCal(32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0), tagLunarCal(22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0)]; var FIRSTYEAR = 1998; var LASTYEAR = 2031; var today = new Date(); var SolarYear = today.getFullYear(); var SolarMonth = today.getMonth() + 1; var SolarDate = today.getDate(); var Weekday = today.getDay(); /* 民国年月日 */ var SolarCal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; var SolarDays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397]; var sm, leap, d, y, acc, kc, Kan, Chih, Age, l1, i, LunarMonth, LunarDate, im; if (SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR) return; sm = SolarMonth - 1; if (sm < 0 || sm > 11) return; leap = GetLeap(SolarYear); if (sm == 1) d = leap + 28; else d = SolarCal[sm]; if (SolarDate < 1 || SolarDate > d) return; y = SolarYear - FIRSTYEAR; acc = SolarDays[leap * 14 + sm] + SolarDate; kc = acc + LunarCal[y].BaseKanChih; Kan = kc % 10; Chih = kc % 12; Age = kc % 60; if (Age < 22) Age = 22 - Age; else Age = 82 - Age; if (acc <= LunarCal[y].BaseDays) { y--; LunarYear = SolarYear - 1; leap = GetLeap(LunarYear); sm += 12; acc = SolarDays[leap * 14 + sm] + SolarDate; } else LunarYear = SolarYear; l1 = LunarCal[y].BaseDays; for (i = 0; i < 13; i++) { l2 = l1 + LunarCal[y].MonthDays[i] + 29; if (acc <= l2) { break; } l1 = l2; } LunarMonth = i + 1; LunarDate = acc - l1; im = LunarCal[y].Intercalation; if (im != 0 && LunarMonth > im) { LunarMonth--; if (LunarMonth == im) { LunarMonth = -im; } } if (LunarMonth > 12) { LunarMonth -= 12; } //2015年9月21日 星期一 农历八月初九 var _week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"); var _months = ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"]; var _days = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"]; var _html = new Array(); _html.push(today.getFullYear()); _html.push("年"); _html.push(today.getMonth() + 1); _html.push("月"); _html.push(today.getDate()); _html.push("日 "); _html.push(_week[today.getDay() + 1]); _html.push(" 农历"); _html.push(_months[Math.abs(LunarMonth) - 1]); _html.push("月"); _html.push(_days[LunarDate - 1]); _o.innerHTML = _html.join(""); }