//删除空格处理，供checkValidate调用
function KillSpace(x) {
	while ((x.length > 0) && (x.charAt(0) == " ")) {
		x = x.substring(1, x.length);
	}
	while ((x.length > 0) && (x.charAt(x.length - 1) == " ")) {
		x = x.substring(0, x.length - 1);
	}
	return x;
}

//判断是否整数，供checkValidate调用
function isNature(inputVal) {
	if ("+" == inputVal.substring(0, 1)) {
		inputVal = inputVal.substring(1, inputVal.length);
	}
	if (isNaN(inputVal)) {
		return false;
	}
	var i = parseInt(inputVal);
	if (i.toString().length != inputVal.length) {
		return false;
	}
	return true;
	/*
	var inputStr = inputVal;//inputVal.toString();
	if (inputStr.length==0)
		return false;
	for(var i=0;i<inputStr.length;i++){
		var oneChar=inputStr.charAt(i);
		if(oneChar<"0"||oneChar>"9"){
			return false;
		}
	}
	return true;
*/
}
// samson add to count chinese
function count_char(str) {
	var len = 0;
	for (i = 0; i < str.length; i++) {
		var ech = escape(str.charAt(i));
		if (ech.length > 4) {
    //			len++;
    
    //// 修改下面的数字，len + 1 表示2个字符代表一个中文字，len + 5 表示6个字符代表一个中文字
			len = len + 1;
			/*
    			if (ech>"%u07ff")
    				len++;
    */
		}
		len++;
	}
	return len;
}
function LengthCheck(text, size) {
	var len = strLen(text);
	if (len > size) {
		return true;
	}
	return false;
}
/**
 * 检验用户指定的对象是否合法
 * @param element        用户需要校验的对象
 * @param discript       对象的描述
 * @param type           对象的类型:
 *                       i  整数
 *                       f  浮点           
 *                       s  字符
 * @param length         对象的最大长度
 * @param type           能否为空：
 *                       1  可以为空
 *                       0  不能为空
 * @param maxs           最大值
 * @param mins           最小值
 * @return               全部条件合法返回true；否则返回false
 */
function checkValidate(element, discript, type, length, nullflag, maxs, mins) {
	if (element == "") {
		window.alert("\u51fd\u6570\u8c03\u7528\u51fa\u9519,\u8bf7\u8f93\u5165\u63a7\u4ef6!");
		return (0);
	}
	if (discript == "") {
		window.alert("\u51fd\u6570\u8c03\u7528\u51fa\u9519,\u8bf7\u8f93\u5165\u63a7\u4ef6\u63cf\u8ff0!");
		return (0);
	}
	if (nullflag == 0) {
		if (element.value == "") {
			window.alert(discript + "\u4e0d\u80fd\u4e3a\u7a7a\u503c!");
			element.focus();
			return (0);
		}
	}
	if (type != "") {
		switch (type) {
		  case "i":
			if (element.value.length != 0 && isNature(element.value) != true) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6574\u6570!");
				element.focus();
				return (0);
			}
			break;
		  case "f":
			if (element.value.length != 0 && isNaN(element.value) == true) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6570\u5b57!");
				element.focus();
				return (0);
			}
			break;
		  case "s":
			break;
		  case "d":
			if (element.value.length != 0 && dateCheck(element.value) == false) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6709\u6548\u65e5\u671f!");
				element.focus();
				return (0);
			} else {
				if (element.value.length == 8) {
					var idate = element.value;
					element.value = idate.substring(0, 4) + "-" + idate.substring(4, 6) + "-" + idate.substring(6, 8);
				}
			}
			break;
		  case "m":
			if (element.value.length != 0 && ValidateEMail(element.value) == true) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6709\u6548\u90ae\u4ef6!");
				element.focus();
				return (0);
			}
			break;
		  case "h":
			if (element.value.length != 0 && !CheckIDCard(element.value)) {
				//window.alert(discript + "格式不符合规定!");
				element.focus();
				return (0);
			}
			break;
		}
	}
	if (length != "" && type != "d") {
	 //if (element.value.length>length)     
		if (LengthCheck(element.value, length)) {
			window.alert(discript + "\u7684\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e" + length + "!");
			element.focus();
			return (0);
		}
	}
	if (maxs != "" && mins != "") {
		if (strLen(element.value) < mins || strLen(element.value) > maxs) {
			window.alert(discript + "\u53d6\u503c\u5fc5\u987b\u5c0f\u4e8e" + maxs + ",\u5927\u4e8e" + mins + "!");
			element.focus();
			return (0);
		}
	} else {
		if (maxs != "") {
			if (strLen(element.value) > maxs) {
				window.alert(discript + "\u53d6\u503c\u5fc5\u987b\u5c0f\u4e8e" + maxs + "!");
				element.focus();
				return (0);
			}
		}
		if (mins != "") {
			if (strLen(element.value) < mins) {
				window.alert(discript + "\u53d6\u503c\u5fc5\u987b\u5927\u4e8e" + mins + "!");
				element.focus();
				return (0);
			}
		}
	}
	return (1);
}
function checkValidate2(element, discript, type, length, nullflag, maxs, mins) {
	if (element == "") {
		window.alert("\u51fd\u6570\u8c03\u7528\u51fa\u9519,\u8bf7\u8f93\u5165\u63a7\u4ef6!");
		return (0);
	}
	if (discript == "") {
		window.alert("\u51fd\u6570\u8c03\u7528\u51fa\u9519,\u8bf7\u8f93\u5165\u63a7\u4ef6\u63cf\u8ff0!");
		return (0);
	}
	if (nullflag == 0) {
		if (element.value == "") {
			window.alert(discript + "\u4e0d\u80fd\u4e3a\u7a7a\u503c!");
  		// element.focus();
			forfocus(element);
			return (0);
		}
	}
	if (type != "") {
		switch (type) {
		  case "i":
			if (element.value.length != 0 && isNature(element.value) != true) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6574\u6570!");
						// element.focus();
				forfocus(element);
				return (0);
			}
			break;
		  case "f":
			if (element.value.length != 0 && isNaN(element.value) == true) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6570\u5b57!");
						// element.focus();
				forfocus(element);
				return (0);
			}
			break;
		  case "s":
			break;
		  case "d":
			if (element.value.length != 0 && dateCheck(element.value) == false) {
				window.alert(discript + "\u8bf7\u8f93\u5165\u6709\u6548\u65e5\u671f!");
						// element.focus();
				forfocus(element);
				return (0);
			} else {
				if (element.value.length == 8) {
					var idate = element.value;
					element.value = idate.substring(0, 4) + "-" + idate.substring(4, 6) + "-" + idate.substring(6, 8);
				}
			}
			break;
		}
	}
	if (length != "" && type != "d") {
	 //if (element.value.length>length)     
		if (LengthCheck(element.value, length)) {
			window.alert(discript + "\u7684\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e" + length + "!");
  		// element.focus();
			forfocus(element);
			return (0);
		}
	}
	if (maxs != "" && mins != "") {
		if (element.value < mins || element.value > maxs) {
			window.alert(discript + "\u53d6\u503c\u5fc5\u987b\u5c0f\u4e8e" + maxs + ",\u5927\u4e8e" + mins + "!");
  		//element.focus();
			forfocus(element);
			return (0);
		}
	} else {
		if (maxs != "") {
			if (element.value > maxs) {
				window.alert(discript + "\u53d6\u503c\u5fc5\u987b\u5c0f\u4e8e" + maxs + "!");
  			//element.focus();
				forfocus(element);
				return (0);
			}
		}
		if (mins != "") {
			if (element.value < mins) {
				window.alert(discript + "\u53d6\u503c\u5fc5\u987b\u5927\u4e8e" + mins + "!");
  			//element.focus();
				forfocus(element);
				return (0);
			}
		}
	}
	return (1);
}



//判断是否整数,供dateCheck调用
function ifIsInt(sVal) {
	try {
		eval(sVal);
		return true;
	}
	catch (errorObject) {
		return false;
	}
}

//取得输入字符的ASCII码,供dateCheck调用
function getvalue(string) {
	var count;
	var numchar;
	var numvalue;
	var value;
	value = 0;
	for (count = 0; count < string.length; count++) {
		numchar = string.charAt(count);
		numvalue = numchar - "0";
		value = value * 10 + numvalue;
	}
	return value;
}
function mod(var1, var2) {
	return (var1 % var2);
}

//检查字符是否合法,供dateCheck调用
function checkvalue(string) {
	var count;
	var numchar;
	var numvalue;
	for (count = 0; count < string.length; count++) {
		numchar = string.charAt(count);
		numvalue = numchar - "0";
		if (!(numvalue >= 0 && numvalue <= 9)) {
			return false;
		}
	}
	return true;
}

//检验日期是否合法,供dateCheck调用
function CheckDate(year, month, day) {
	var iyear;
	var imonth;
	var iday;
	if (year.length != 4 || month.length != 2 || day.length != 2) {
		return false;
	}
	if (!checkvalue(year) || !checkvalue(month) || !checkvalue(day)) {
		return false;
	}
	iyear = getvalue(year);
	imonth = getvalue(month);
	iday = getvalue(day);
	if (imonth < 1 || imonth > 12) {
		return false;
	}
	switch (imonth) {
	  case 1:
	  case 3:
	  case 5:
	  case 7:
	  case 8:
	  case 10:
	  case 12:
		if (iday > 31) {
			return false;
		}
		break;
	  case 4:
	  case 6:
	  case 9:
	  case 11:
		if (iday > 30) {
			return false;
		}
		break;
	  default:
		if (mod(iyear, 4) == 0 && (mod(iyear, 100) != 0 || mod(iyear, 400) == 0)) {//判断是否润年
			if (iday > 29) {
				return false;
			}
		} else {
			if (iday > 28) {
				return false;
			}
		}
	}
	return true;
}
/**调用此函数校验日期。
 * @param s         输入日期string s,如2001-01-01
 * @return          若输入的日期没有包含非法字符，以及该日期合法，则返回true；否则返回false
 */
function dateCheck(s) {
	if (s.length == 10) {
		if (s.length != 10 || s.charAt(4) != "-" || s.charAt(7) != "-") {
			return false;
		}
		if (!ifIsInt(s.substring(0, 4)) || !ifIsInt(s.substring(5, 7)) || !ifIsInt(s.substring(8, 10)) || eval(s.substring(0, 4)) < 1 || eval(s.substring(5, 7)) < 1 || eval(s.substring(8, 10)) < 1) {
			return false;
		}
		if (CheckDate(s.substring(0, 4), s.substring(5, 7), s.substring(8, 10)) == false) {
			return false;
		}
		return true;
	}
	if (s.length == 8) {
		return CheckDate(s.substring(0, 4), s.substring(4, 6), s.substring(6, 8));
	}
	return false;
}
function tx_chk(obj) {
	var name, key, val = obj.value;
	name = obj.alt.slice(0, obj.alt.indexOf(":"));
	key = "/" + obj.alt.slice(obj.alt.indexOf(":") + 1) + "/";
	if (key.indexOf("/\u65e0\u5185\u5bb9/") > -1 && val == "") {
		return "\u8bf7\u8f93\u5165" + name;
	}
	if (key.indexOf("/4-16/") > -1 && (strLen(val) < 4 || strLen(val) > 16)) {
		return name + "\u957f\u5ea6\u5fc5\u987b4-16\u4f4d";
	}
	if (key.indexOf("/0-10/") > -1 && (strLen(val) < 0 || strLen(val) > 10)) {
		return name + "\u957f\u5ea6\u5fc5\u987b0-10\u4f4d";
	}
	if (key.indexOf("/0-50/") > -1 && (strLen(val) < 0 || strLen(val) > 50)) {
		return name + "\u957f\u5ea6\u5fc5\u987b0-50\u4f4d";
	}
	if (key.indexOf("/0-100/") > -1 && (strLen(val) < 0 || strLen(val) > 100)) {
		return name + "\u957f\u5ea6\u5fc5\u987b0-100\u4f4d";
	}
	if (key.indexOf("/6-16/") > -1 && (strLen(val) < 6 || strLen(val) > 16)) {
		return name + "\u957f\u5ea6\u5fc5\u987b6-16\u4f4d";
	}
	if (key.indexOf("/\u602a\u5b57\u7b26/") > -1 && (/>|<|,|\[|\]|\{|\}|\?|\/|\+|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(val)) {
		return name + "\u8bf7\u52ff\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26";
	}
	if (key.indexOf("/\u6709\u7a7a\u683c/") > -1 && val.indexOf(" ") > -1) {
		return name + "\u4e0d\u80fd\u5305\u542b\u7a7a\u683c\u7b26";
	}
	if (key.indexOf("/\u5168\u6570\u5b57/") > -1 && val != "" && !isNaN(val)) {
		return name + "\u4e0d\u53ef\u4ee5\u5168\u662f\u6570\u5b57";
	}
	if (key.indexOf("/\u6709\u5927\u5199/") > -1 && /[A-Z]/.test(val)) {
		return name + "\u4e0d\u80fd\u6709\u5927\u5199\u5b57\u6bcd";
	}
	if (key.indexOf("/\u82f1\u6587\u6570\u5b57/") > -1 && !/^[a-zA-Z0-9_]*$/.test(val)) {
		return name + "\u53ea\u80fd\u4e3a\u82f1\u6587\u548c\u6570\u5b57";
	}
	if (key.indexOf("/\u4ec5\u6570\u5b57/") > -1 && !/^[0-9]*$/.test(val)) {
		return name + "\u53ea\u80fd\u4e3a\u6570\u5b57";
	}
	if (key.indexOf("/\u6709\u5168\u89d2/") > -1 && /[ａ-ｚ０-９]/.test(val)) {
		return name + "\u4e0d\u80fd\u6709\u5168\u89d2\u5b57\u7b26";
	}
	if (key.indexOf("/\u6709\u6c49\u5b57/") > -1 && escape(val).indexOf("%u") > -1) {
		return name + "\u4e0d\u80fd\u6709\u6c49\u5b57";
	}
	if (key.indexOf("/\u4e0b\u5212\u7ebf/") > -1 && val.slice(val.length - 1) == "_") {
		return name + "\u4e0b\u5212\u7ebf\u4e0d\u80fd\u5728\u6700\u540e";
	}
	if (key.indexOf("/\u786e\u8ba4\u5bc6\u7801/") > -1) {
		if (obj.form[name].value != val) {
			return "\u786e\u8ba4\u5bc6\u7801\u4e0d\u4e00\u81f4";
		}
	}
	if (key.indexOf("/\u5fc5\u9009/") > -1) {
		var ol = obj.form[obj.name], isSel = false;
		for (var i = 0; i < ol.length; i++) {
			if (ol[i].checked) {
				isSel = true;
			}
		}
		if (!isSel) {
			return name + "\u5fc5\u987b\u9009\u62e9";
		}
	}
	return "";
}
function strLen(key) {
	var l = escape(key), len;
	len = l.length - (l.length - l.replace(/\%u/g, "u").length) * 4;
	l = l.replace(/\%u/g, "uu");
	len = len - (l.length - l.replace(/\%/g, "").length) * 2;
	return len;
}
_charset_email_extra = ".-_@";
function ValidateEMail(str) {
	element2 = str.indexOf("@");
	if ((element2 > 0) && (str.substring(0, element2).indexOf("@") < 0) && (str.substring(element2 + 1).indexOf("@") < 0) && (str.substring(element2 + 1).indexOf(".") > 0) && (str.indexOf(".") > 0) && (str.lastIndexOf(".") < (str.length - 1))) {
		var i = IsDigiAlphExtra(str, _charset_email_extra);
		if (i >= 0) {
			return true;
		}
	} else {
		return true;
	}
	return false;
}
function IsDigiAlphExtra(str, charsetExtra) {
	for (var i = 0; i < str.length; i++) {
		var ch = str.charAt(i);
		if (!(((ch >= "A") && (ch <= "Z")) || ((ch >= "a") && (ch <= "z")) || ((ch >= "0") && (ch <= "9")) || ((charsetExtra != null) && (charsetExtra.indexOf(ch) >= 0)))) {
			return i;
		}
	}
	return -1;
}
/**
 * 提交并处理代码
 * targObj:parent窗口的iframe的名字
 * height:最小高度
 */
function forsubmit(form1, flag) {
	if (checkAll(form1, flag)) {
		form1.submit();
		return true;
	} else {
		return false;
	}
}
/**
 * 调用完ajax后的操作
 *
 */
function complete(req) {
	if (req.readyState == 4) {
		if (req.status == 200) {
			processLogon(req);
		}
	}
}
/**
 * 通过用户名或者昵称
 * 调用ajax进行操作
 */
function setAjax(url, name) {
	var url = url + escape(name);
	var req = new Ajax.Request(url, {method:"get", parameters:"Content=text/xml", onComplete:complete});
}
/**
 * 
 * 取cookie值
 */
function getCookie(str) {
	var tmp, reg = new RegExp("(^| )" + str + "=([^;]*)(;|$)", "gi");
	if (tmp = reg.exec(document.cookie)) {
		return (tmp[2]);
	}
	return null;
}
/**
 * 
 * 删除
 */
function ClearCookie(name) {
	var ThreeDays = 3 * 24 * 60 * 60 * 1000;
	var expDate = new Date();
	expDate.setTime(expDate.getTime() - ThreeDays); 
//document.cookie=name+"=;path=/;expires="+expDate.toGMTString(); 
	document.cookie = name + "=;domain=.china.com;path=/;expires=" + expDate.toGMTString();
}

//
function goindex() {
	window.location.href = "/index.html";
}
function find(str) {
	for (var i = 0; i < str.length; i++) {
		var ch = str.charAt(i);
		if (!(((ch >= "A") && (ch <= "Z")) || ((ch >= "a") && (ch <= "z")) || ((ch >= "0") && (ch <= "9")))) {
			return i;
		}
	}
	return -1;
}
function findNowDateIsOk(ss) {
	if (ss != null && ss != "") {
		if (ss.length == 8) {
			ss = ss.substring(0, 4) + "-" + ss.substring(4, 6) + "-" + ss.substring(6, 8);
		}
		ss = ss.replace(/-/g, "/");
		var date = new Date(ss.replace(/-/g, "/"));
		var ddd = new Date();
		var dd = new Date(ddd.getFullYear(), ddd.getMonth(), ddd.getDate());
		if (dd <= date) {
			return false;
		}
	}
	return true;
}
function strLen(key) {
	var l = escape(key), len;
	len = l.length - (l.length - l.replace(/\%u/g, "u").length) * 4;
	l = l.replace(/\%u/g, "uu");
	len = len - (l.length - l.replace(/\%/g, "").length) * 2;
	return len;
}
function CheckIDCard(StrNumber) {
//判断身份证号码格式函数
//公民身份号码是特征组合码，
//排列顺序从左至右依次为：六位数字地址码，八位数字出生日期码，三位数字顺序码和一位数字校验码

//身份证号码长度判断
	if (StrNumber.length != 18) {
		alert("\u586b\u5199\u7684\u8eab\u4efd\u8bc1\u53f7\u7801\u957f\u5ea6\u4e0d\u6b63\u786e\uff0c\u8bf7\u91cd\u65b0\u586b\u5199!");
		return false;
	}
//身份证号码最后一位可能是超过100岁老年人的X.X也可以代表是阿拉伯数字10的意思
//所以排除掉最后一位数字进行数字格式测试，最后一位数字有最后一位数字的算法
	var Ai;
	if (StrNumber.length == 18) {
		Ai = StrNumber.substring(0, 17);
	} else {
		Ai = StrNumber.substring(0, 6) + "19" + StrNumber.substring(6, 15);
	}
//调用数字判断函数IsNumeric()
	if (IsNumeric(Ai) == false) {
		alert("\u8eab\u4efd\u8bc1\u53f7\u7801\u6570\u5b57\u5b57\u7b26\u4e32\u4e0d\u6b63\u786e\uff0c\u8bf7\u91cd\u65b0\u586b\u5199!");
		return false;
	}
	var strYear, strMonth, strDay, strBirthDay;
	strYear = parseInt(Ai.substr(6, 4));
	strMonth = parseFloat(Ai.substr(10, 2));
	strDay = parseFloat(Ai.substr(12, 2));
//调用日期判断函数IsValidDate()
	
	if (IsValidDate(strYear, strMonth, strDay) == false) {
		alert("\u8eab\u4efd\u8bc1\u53f7\u7801" + Ai + "\u65e5\u671f\u683c\u5f0f\u5e74\u4efd" + strYear + "\u6708\u4efd" + strMonth + "\u65e5" + strDay + "\u4e0d\u6b63\u786e\uff0c\u8bf7\u91cd\u65b0\u586b\u5199!");
		return false;
	}
	var arrVerifyCode = new Array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
	var Wi = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 );
	var k, TotalmulAiWi = 0;
	for (k = 0; k < 17; k++) {
		TotalmulAiWi = TotalmulAiWi + parseInt(Ai.substr(k, 1)) * Wi[k];
	}
//alert("身份证号码最后一位的识别码是:"+TotalmulAiWi);
	var modValue = TotalmulAiWi % 11;
	var strVerifyCode = arrVerifyCode[modValue];
	Ai = Ai + strVerifyCode;
//alert("身份证号码"+StrNumber+"与正确的号码"+Ai+"一致!");
	if ((StrNumber.length == 18) && (StrNumber.toUpperCase() != Ai)) {
		alert("\u8eab\u4efd\u8bc1\u53f7\u7801" + StrNumber + "不是正确的号码!");
		return false;
	}
	return true;
}
//数字判断函数IsNumeric()
function IsNumeric(oNum) {
	if (!oNum) {
		return false;
	}
	var strP = /^\d+(\.\d+)?$/;
	if (!strP.test(oNum)) {
		return false;
	}
	try {
		if (parseFloat(oNum) != oNum) {
			return false;
		}
	}
	catch (ex) {
		return false;
	}
	return true;
}
//有效年份判断函数IsValidYear()
function IsValidYear(psYear) {
	var sYear = new String(psYear);
	if (psYear == null) {
		alert("\u8eab\u4efd\u8bc1\u53f7\u7801\u51fa\u751f\u65e5\u671f\u4e2d\u5e74\u4efd\u4e3aNull\uff0c\u8bf7\u91cd\u65b0\u586b\u5199!");
		return false;
	}
	if (isNaN(psYear) == true) {
		alert("\u8eab\u4efd\u8bc1\u53f7\u7801\u51fa\u751f\u65e5\u671f\u4e2d\u5e74\u4efd\u5fc5\u987b\u4e3a\u6570\u5b57\uff0c\u8bf7\u91cd\u65b0\u586b\u5199!");
	    return false;
	}
    if(sYear == "")
    {
  		alert("身份证号码出生日期中年份为空，请重新填写!");
        return true;
    }

    if(sYear.match(/[^0-9]/g)!=null)
    {
        alert("身份证号码出生日期中年份必须为0-9之间的数字组成，请重新填写!");
        return false;
    }

    var nYear = parseInt(sYear,10);

    if((nYear < 0) || (9999 < nYear))
    {
        alert(nYear +"身份证号码出生日期中年份必须为正常的正整数，请重新填写!");
       return false;
    }
    return true;
}

//有效月份判断函数IsValidMonth()
function IsValidMonth(psMonth)
{
    var sMonth = new String(psMonth);

    if(psMonth==null)
    {
        return false;
    }

    if(isNaN(psMonth)==true)
    {
        return false;
    }

    if(sMonth == "")
    {
        return true;
    }

    if(sMonth.match(/[^0-9]/g)!=null)
    {
        return false;
    }

    var nMonth = parseFloat(sMonth,10);

    if((nMonth < 0) || (12 < nMonth))
    {
        return false;
    }

    return true;
}

//有效日判断函数IsValidDay()
function IsValidDay(psDay)
{
    var sDay  = new String(psDay);

    if(psDay==null)
    {
        return false;
    }

    if(isNaN(psDay)==true)
    {
        return false;
    }

    if(sDay == "")
    {
        return true;
    }

    if(sDay.match(/[^0-9]/g)!=null)
    {
        return false;
    }

    var nDay = parseFloat(psDay, 10);

    if((nDay < 0) || (31 < nDay))
    {

  return false;
    }

    return true;
}

//有效日期判断函数IsValidDate()
function IsValidDate(psYear, psMonth, psDay)
{
    if(psYear==null || psMonth==null || psDay==null)
    {
        return false;
    }

    var sYear  = new String(psYear);
    var sMonth = new String(psMonth);
    var sDay   = new String(psDay);

    if(IsValidYear(sYear)==false)
    {
        return false;
    }

    if(IsValidMonth(sMonth)==false)
    {
        return false;
    }

    if(IsValidDay(sDay)==false)
    {
        return false;
    }

    var nYear  = parseInt(sYear,  10);
    var nMonth = parseFloat(sMonth, 10);
    var nDay   = parseFloat(sDay,   10);

    if(sYear=="" &&  sMonth=="" && sDay=="")
    {
        return true;
    }

    if(sYear=="" || sMonth=="" || sDay=="")
    {
        return false;
    }
   
    if(nMonth < 1 || 12 < nMonth)
    {
        return false;
    }
    if(nDay < 1 || 31 < nDay)
    {
        return false;
    }

    if(nMonth == 2)
    {
        if((nYear % 400 == 0) || (nYear % 4 == 0) && (nYear % 100 != 0))
        {
            if((nDay < 1) || (nDay > 29))
            {
                return false;
            }
        }
        else
        {
            if((nDay < 1) || (nDay > 28))

  {
                return false;
            }
        }
    }
    else if((nMonth == 1)  ||
            (nMonth == 3)  ||
            (nMonth == 5)  ||
            (nMonth == 7)  ||
            (nMonth == 8)  ||
            (nMonth == 10) ||
            (nMonth == 12))
    {
        if((nDay < 1) || (31 < nDay))
        {
            return false;
        }
    }
    else
    {
        if((nDay < 1) || (30 < nDay))
        {
            return false;
        }
    }

    return true;
} 



