xianxing();
function getXHNumber(tDate, sDate) {
var nDayNum = tDate.getDay() == 0 ? 7 : tDate.getDay();
if (nDayNum > 5) return nDayNum;
var nDiff = (tDate - sDate) / 1000 / 3600 / 24 / 7 / 13;
nDiff = Math.floor(nDiff) % 5;
nDayNum = 5 - nDiff + nDayNum;
if (nDayNum > 5) nDayNum -= 5;
return nDayNum;
}
function xianxing() {
var sStartDate = '2014-04-14'; //开始星期,周一的日期
var x1 = '5和0';
var x2 = '1和6';
var x3 = '2和7';
var x4 = '3和8';
var x5 = '4和9';
var x6 = '不限行';
var x7 = '不限行';
var arr1 = sStartDate.split("-");
var vStartDate = new Date(arr1[0], arr1[1] - 1, arr1[2]);
var arr2 = document.getElementsByName("页面生成时间")[0].content.substr(0, 10).split("-");
var vToday = new Date(); //客户端时间
var d = new Date(arr2[0], arr2[1] - 1, arr2[2]);
var secs = Math.abs(vToday.getTime() - d.getTime());
if (secs >3 * 24 * 3600 * 1000) {
//$('#xianhao').hide();
$('#xianhao').html('<p class="zhuanti"><a href="http://www.bjjtgl.gov.cn/zhuanti/10weihao/index.html" target="_blank">尾号限行专题>></a></p>')
return;
}
var nTodayNum = getXHNumber(vToday, vStartDate);
vToday.setDate(vToday.getDate() + 1);
var nTomorrowNum = getXHNumber(vToday, vStartDate);
/***start week***/
var arr_week = new Array("星期六", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五");
var todayweek = vToday.getDay();
document.getElementById("todayweek").innerHTML = arr_week[todayweek];
document.getElementById("tomorrowweek").innerHTML = arr_week[(todayweek + 1) == 7 ? 0 : todayweek + 1];
/***end week***/
document.getElementById("todaynum").innerHTML = eval('x' + nTodayNum);
document.getElementById("tomorrownum").innerHTML = eval('x' + nTomorrowNum);
}
</script>