function isChinaPostCode(s){//邮编检测
	var rs=/^[0-9]{6}$/;
	if(!rs.test(s)){return false;}
	return true;
}
function isEmail(strEmail){//Email格式检测
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		{return true;}
	else{
		//alert("要求输入Email！");
		return false;
		}
}

String.prototype.Trim = function() {   
	var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);   
	return (m == null) ? "" : m[1];   
}   
String.prototype.isMobile = function() {   
	return (/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));   
}
String.prototype.isTel = function(){   
	//"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)"   
	return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));   
}
function  isEnglish(inputValue){//英文值检测
	var str=inputValue;
	var Expression=/^[A-Za-z]+$/; 
	var objExp=new RegExp(Expression);
	if(objExp.test(str)==true){return true;}
	else{return false;}
}
function  isChinese(inputValue){//中文值检测  
	if(inputValue.length==0){return false;}
	for(i=0;i<inputValue.length;i++){
		if(inputValue.charCodeAt(i)>128){return true;}
	}
	return  false;
}
function chkMobileTel(inputValue){ //手机号码或电话号码检测
	if(inputValue.length==0){return false;}
	if (inputValue.isMobile()||inputValue.isTel())
		{return true;}   
	else{   
		//alert("请输入正确的手机号码或电话号码\n\n例如:13888888888或020-8888888");   
		//MobileTel.focus();   
		return false; 
		}
}
function isURL(URL){//网址检测
	var str=URL;
	//在JavaScript中，正则表达式只能使用"/"开头和结束，不能使用双引号
	//判断URL地址的正则表达式为:http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
	//下面的代码中应用了转义字符"\"输出一个字符"/"
	var Expression=/^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?$/; 
	var objExp=new RegExp(Expression);
	if(objExp.test(str)==true){return true;}
	else{return false;}
}
function isCidInfo(sId){//身份证检测
	var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"***",71:"台湾",81:"香港",82:"澳门",91:"国外"}
	var iSum=0
	var info=""
	if(!/^\d{17}(\d|x)$/i.test(sId))return false;
	sId=sId.replace(/x$/i,"a"); 
	if(aCity[parseInt(sId.substr(0,2))]==null){
		//return "Error:非法地区";
		return false;
	}
	sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
	var d=new Date(sBirthday.replace(/-/g,"/"))
	//if(sBirthday!=(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate())){
	if(sBirthday!=(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate())){
		//return "Error:非法生日"; 
		return false;
	}
	for(var i=17;i>=0;i--){iSum+=(Math.pow(2,i)%11)*parseInt(sId.charAt(17-i),11)}
	if(iSum%11!=1){
		//return "Error:非法证号";
		return false;
	} 
	//return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女") 
	return true; 
}
function isNumber(name){//数值检测 
	if(name.length==0)
	return false;
	for(i=0;i<name.length;i++){  
	if(name.charAt(i)<"0"||name.charAt(i)>"9")
	return false;
	}
	return true;
}
function isDate(dateval){//日期检测 
	var arr = new Array();
	//alert("02/30/2008");
	if(dateval.indexOf("-") != -1){
		arr = dateval.toString().split("-");
	}else if(dateval.indexOf("/") != -1){
		arr = dateval.toString().split("/");
	}else{
		return false;		
	}
	//yyyy-mm-dd || yyyy/mm/dd
	if(arr[0].length==4){
		var date = new Date(arr[0],arr[1]-1,arr[2]);
		if(date.getFullYear()==arr[0] && date.getMonth()==arr[1]-1 && date.getDate()==arr[2]){
			return true;			
		}
	}
	return false;
}

function  CheckInputValue(inputname,checkSort)
{  
var InputN=document.getElementsByName(inputname)[0];
switch (checkSort){
	case 1:
	{
		if(!isChinaPostCode(InputN.value)){  
			alert("邮编输入不正确！");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 2:
	{
		if(!chkMobileTel(InputN.value)){  
			alert("请输入正确的手机号码或电话号码\n\n例如:13888888888或020-8888888");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 3:
	{
		if (!isEmail(InputN.value)){
			alert("输入的Email不正确！");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 4:
	{
		if (!isURL(InputN.value)){
			alert("输入的网址不正确！");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 5:
	{
		if(!isChinese(InputN.value)){  
			alert("只能输入中文字符！");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 6:
	{
		if(!isEnglish(InputN.value)){  
			alert("只能输入英文字符！");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 7:
	{
		if (!isCidInfo(InputN.value)){
			alert("输入的身份证不正确！");
			InputN.focus();
			return  false;
		}
	}
	break;
	case 8:
	{
		if (!isDate(InputN.value)){
			alert("输入的日期不正确！");
			InputN.focus();
			return  false;
		}
	}
	break;
}
}
function checkbox(BoxName)//获取复选框的值
{
	var str=document.getElementsByName(BoxName);
	var objarray=str.length;
	var chestr="";
	for (i=0;i<objarray;i++){
		if(str[i].checked == true){
		   chestr+=str[i].value+",";
		 }
	}
	if(chestr == ""){
		return null;
		}
	else{
		return chestr;
		}
}