// JavaScript Document
//bingye??±??é?¤?í?§????±?

// 
// 
function checkstr(formName,FieldName,Showmessage)
{
	//------------
  var str;
  expstr=" "; // 
  count=0;  // 
  str=eval("document."+formName+"."+FieldName).value; // 
  for(i=0;i<str.length;i++)
  {
	 str1="";    
     str1=str.charAt(i); // 
	 if(str1==expstr)    // 
	 {
	    count=count+1;   // 
	 }
  }
  if(count==str.length)
  {
      alert(Showmessage);
      eval("document."+formName+"."+FieldName).focus();
      return false;  // 
  }
  
  return true; 

}
//******************  


//************** 
function checknum(formName,FieldName,Showmessage,Type)
{
   numstr=eval("document."+formName+"."+FieldName).value;
   num=""
   switch(Type)
   {
	   case 1:   //è?2?óé"0123456789 
	          num="0123456789";// 
	          break;
	   case 2:   //è?2?óé"0123456789-()"×é3é
	          num="0123456789-()";//àà??μ??°, -65245769 [4-8??] ?ò (010)2354215 [3-7??] ?ò0898-6524576 [4-7??]
	          break;
	   case 3:   //è?2?óé0123456789×é3é//ê??úo????é?¤
	          num="0123456789";//ê??úo????é?¤ 13975482635
	          break;
   }
 
   for(k=0;k<numstr.length;k++)
   { 
     if(num.indexOf(numstr.charAt(k))==-1)
	 {
	    alert(Showmessage);
		eval("document."+formName+"."+FieldName).select();
	    return false;
	 }
   }
   if(Type==3)//ê??úo????é?¤ 
   {
     if(numstr.length!=11)
     {
		alert("手机号码应为11位！");
		eval("document."+formName+"."+FieldName).select();
		return false;
     }
	 //********?é?¤ê??ú?aí·μ?3??êy×?130---139
	 Mobilestartnum=numstr.substring(0,3);
	 Mobilenum=130;
	 mbnum=0;
	 for(g=0;g<10;g++)
	 {
		  if(Mobilestartnum!=Mobilenum)
		  {
			  mbnum=mbnum+1;
		  }
		  Mobilenum++;
	 }
	 if(mbnum==10)
	 {
	    alert("手机号码格式不对！");
		eval("document."+formName+"."+FieldName).select();
		return false;
	 }
   }
   return true;
}
//*************************************



//?D??Emailμ???ê?ê?·??yè·**************
function checkEmail(formName,FieldName)
{
	str="";
	str=eval("document."+formName+"."+FieldName).value;
	if(str!="") //2??a??μ?ê±oò2??D??
	{
	  if((str.indexOf("@")==-1)||(str.indexOf(".")==-1)||(str.charAt(0)=="@")||(str.charAt(0)==".")||(str.charAt(str.length-1)=="@")||(str.charAt(str.length-1)=="."))
	  {
	    alert("Email格式不对！");
		eval("document."+formName+"."+FieldName).select();
	    return false;
      }

	}
	return true;
}

//?D??óê?t±à??μ???ê?ê?·??yè·**************
function checkPost(formName,FieldName,Showmessage)
{
	 
	str="";
	postnum="0123456789"
	poststr=eval("document."+formName+"."+FieldName).value;
	if(!checkstr(formName,FieldName,Showmessage))return false;
	if(!checknum(formName,FieldName,"请填写邮政编码",1))return false;
	if(poststr.length!=6)
	{
		 alert('邮政编码格式不对！'); 
		 eval("document."+formName+"."+FieldName).select();
		 return false;
	}
	 
	return true;
	 
}

//********* 
function checknumeric()
 {
    if(event.keyCode<48||event.keyCode>57)event.returnValue=false;
 }


//********** 
function getdate()///获取日期和星期
{
 var tdate=new Date();
 var vyear=tdate.getFullYear();
 var month=tdate.getMonth()+1;
 var vday=tdate.getDate();
 var week=tdate.getDay();
 var weekarr=new Array(7);
 weekarr[0]="日";
 weekarr[1]="一";
 weekarr[2]="二";
 weekarr[3]="三";
 weekarr[4]="四";
 weekarr[5]="五";
 weekarr[6]="六";
 getdate=vyear+"-"+month+"-"+vday+"  星期"+weekarr[week];
 document.write(getdate);
}


//*********** ************************
function gettime()
{
 var tdate=new Date();
 var vHours=tdate.getHours();
 var vMinutes=tdate.getMinutes();
 var vSeconds=tdate.getSeconds();
 if(vHours<10)vHours="0"+vHours;
 if(vMinutes<10)vMinutes="0"+vMinutes;
 if(vSeconds<10)vSeconds="0"+vSeconds;
 
 vtime=vHours+":"+vMinutes+":"+vSeconds; 
 timearea.innerHTML=vtime;
 
// setInterval("gettime()",1000);
 setTimeout("gettime()",1000);
}


function checknumeric()
 {
    if(event.keyCode<48||event.keyCode>57)event.returnValue=false;
 }
 
function checkID_card(formName,FieldName)
{
 
	checkIDstr=eval("document."+formName+"."+FieldName).value; 
	if(checkIDstr.length!=18)
	{
		  alert('身份证号码应为18位！');
		  eval("document."+formName+"."+FieldName).select();
		  return false;
	}
	return true;
}
