var nowDate,theDate,theDay,theYear,theMonth,theHour,theMin,theSec,timeValue;
function ShowDateTime()
{
	var clock = document.getElementById("clock");
	weeks = new Array("日","一", "二","三","四","五","六");
	nowDate = new Date();
	theDate = nowDate.getDate();
	theDay = weeks[nowDate.getDay()];
	theYear = nowDate.getFullYear();
	theMonth = nowDate.getMonth() + 1;
	theHour = nowDate.getHours();
	theMin = nowDate.getMinutes(); if (theMin < 10) theMin = "0"+theMin; // 小於 10 分补 0
	theSec = nowDate.getSeconds(); if (theSec < 10) theSec = "0"+theSec; // 小於 10 秒补 0
	timeValue=theYear+"年"+theMonth+"月"+theDate+"日 "+"星期"+theDay+" "+theHour+":"+theMin+":"+theSec;
	clock.innerHTML = timeValue; //日期与时间的排列方式，通常只需要更改这里
	setTimeout("ShowDateTime()",1000);// 每隔一秒显示一将次
}
function startList(id) {
	if(document.all&&document.getElementById) {
		navRoot = document.getElementById(id);
		for(i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="li") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
$(function(){
	ShowDateTime();
	startList("menuList");
	$("form#messageForm").validate({
		rules:{
			message:{required:true},
			name:{required:true},
			tel:{required:true},
			mobile:{required:true,number:true,minlength:11},
			email:{required:true}
		},
		messages:{
			message:{required:"请填写留言内容"},
			name:{required:"请填写姓名"},
			tel:{required:"请填写电话号码"},
			mobile:{required:"请填写手机号码",number:"手机号码只能是数字",minlength:"手机号码为11位数字"},
			email:{required:"请填写联系邮箱"}
		}
	})
});
function Request(strName)
{
 
 var strHref = window.document.location.href;
 var intPos = strHref.indexOf("?");
 var strRight = strHref.substr(intPos + 1);
 var arrTmp = strRight.split("&");
 for(var i = 0; i < arrTmp.length; i++) { 
	 var arrTemp = arrTmp[i].split("=");
	  if(arrTemp[0].toUpperCase() == strName.toUpperCase()){
		  if(arrTemp[1].indexOf("#")!=-1) arrTemp[1] = arrTemp[1].substr(0, arrTemp[1].indexOf("#"));
		  return arrTemp[1]; 
	  }
}
 return "";
}

function showUrl(){
	document.write(window.location.hostname);
}

// PNG纠正控件 1.0 For IE 5.5或更高.
// 作者:舜子

function isIE(){
if (navigator.appName!="Microsoft Internet Explorer") {return false}
return true
}
var is_correct_png = true;
function correctPNG() 
{
	if(!is_correct_png) return;
var iexit=eval('document.all.Loadding?1:0'); 
   for(var i=0; i<document.images.length; i++)
   {
	  var img = document.images[i]
	  var LW=img.width
	  var LH=img.height
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	  { 
         img.style.filter+="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+img.src+", sizingmethod=scale);" 
         img.src="/images/transparent.gif"
         img.width=LW
         img.height=LH
	  }
   }
	if(document.getElementById('Loadding')) hideInfo();
}
if (isIE()) {window.attachEvent("onload", correctPNG);}

//cookie相关
function checkNum(nubmer)
{
    var re = /^[0-9]+.?[0-9]*$/;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
    
    if (re.test(nubmer))
    {
		return true;
    }
	return false;
}
/*
*@name  cookie 名字
*@value cookie 值
*@hours cookie 保存小时
*/
function SetCookie(name,value,hours)
{
	var hourstay = 30*24*60*60*1000; //此 cookie 将被默认保存 30 天
	if(checkNum(hours)){
		hourstay = hours;
	}
    
    var exp  = new Date();
    exp.setTime(exp.getTime() + hourstay*60*60*1000);
    document.cookie = name + "="+ escape(value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
//表单是否显示
function showForm(){
	if(getCookie('userlogin')==1){
		var formIsShow = document.getElementsByTagName('div');
		for(var i=0;i<formIsShow.length;i++){
			if(formIsShow[i].getAttribute("name")=="formIsShow"&&formIsShow[i].getAttribute("value")==1){
				formIsShow[i].style.display='block';
			}
		}
	}
}
