var er					= "错误提示: "
var NotAllowEmpty		= "不能为空"
var FormatIncorrect		= "格式不正确，\n如：lffxunuo@163.com"
var LessThan			= "不能少于$$个字符"
var MoreThan			= "不能多于$$个字符"
var NotEqual			= "必须为$$个字符"
var Toosmall			= "的值要大于$$"
var Toobig				= "的值要小于$$"
var MustBeNumber		= "必须为数字"
var numNotEqual			= "必须为一个$$位数字"
var NotAllowSpecialstr	= "不能含有特殊字符"
var MustbeAllCnText		= "必须为中文"
var MustbeIncludeCnText	= "必须含有中文"
var IPStr_err			= "IP地址格式不正确"
var IDCardStr_err		= "输入不对"//身份证
var RadioErr			= "未选择"
var CheckboxErr			= "最少选择$1个，最多选择$2个"
var Notsamevalue		= "与确认不一样"
var Validationstr		= "ISOK"

function XN_alert(str)
{
	//alert("错误提示：\n\n"+str);
	alert(str);
}
//返回字符真实长度
function GetLength(str)
{
	return str.replace(/[^\x00-\xff]/g,'**').length
}

//除-_.以外的特殊字符
function XN_CheckSpecialStr(str)
{
	var reg=/[^\w\.-]/g
	if (reg.test(str)){return (false);}
	else{return(true);}
}
//全是中文
function XN_CheckAllCnText(str)
{
	var reg=/[^\u4E00-\u9FA5]/g
	if (reg.test(str)){return (false);}
	else{return(true);}
}
//含有中文
function XN_CheckCnText(str)
{
	var reg=/[\u4E00-\u9FA5]/g
	if (reg.test(str)){return (true);}
	else{return(false);}
}
//验证身份证
function XN_CheckIDCard (str)
{
	isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;//身份证正则表达式(15位)
	isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;//身份证正则表达式(18位)
	if (isIDCard1.test(str)||isIDCard2.test(str)){return (Validationstr);}
	else{return (IDCardStr_err)}
}
//验证email地址
function XN_CheckEmail(strEmail)
{
	if (strEmail==""){return(NotAllowEmpty)}
	if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1){return (Validationstr);}
	else{return(FormatIncorrect);}
}
//验证IP地址
function XN_CheckIP (str)
{
	ip='(25[0-5]|2[0-4]\\d|1\\d\\d|\\d\\d|\\d)';
	ipx=ip+'\\.';
	isIPaddress=new RegExp('^'+ipx+ipx+ipx+ip+'$');
	if (isIPaddress.test(str)){return (Validationstr);}
	else{return (IPStr_err)}
}

function XN_CheckNull(str)
{
	if (str.length>0){return (Validationstr);}
	else{return (NotAllowEmpty)}
}

function XN_CheckAllStrLen(str,theMin,theMax)
{
	if ((theMin==theMax)&GetLength(str)!=theMin){return (NotEqual.replace("$$",theMin));}
	if (GetLength(str)<theMin){return (LessThan.replace("$$",theMin));}
	else if (GetLength(str)>theMax){return (MoreThan.replace("$$",theMax));}
	else{return (Validationstr);}
}

function XN_CheckStrLen(str,theMin,theMax)
{
	if (!XN_CheckSpecialStr(str)){return (NotAllowSpecialstr)}
	if ((theMin==theMax)&GetLength(str)!=theMin){return (NotEqual.replace("$$",theMin));}
	if (GetLength(str)<theMin){return (LessThan.replace("$$",theMin));}
	else if (GetLength(str)>theMax){return (MoreThan.replace("$$",theMax));}
	else{return (Validationstr);}
}

function XN_CheckStrMinLen(str,theMin){   //指定最小长度
	if (GetLength(str)<theMin){
		return (LessThan.replace("$$",theMin));
	}else{
		return (Validationstr);
	}
}

function XN_CheckStrTheLen(str,theLen){   //指定长度
	if (GetLength(str)<theLen){
		return (LessThan.replace("$$",theLen));
	}else if (GetLength(str)>theLen){
		return (MoreThan.replace("$$",theLen));
	}else{
		return (Validationstr);
	}
}

function XN_CheckStrMaxLen(str,theMax){   //指定最大长度
	if (GetLength(str)>theMax){
		return (MoreThan.replace("$$",theMax));
	}else{
		return (Validationstr);
	}
}

function XN_CheckCnStrLen(str,theMin,theMax)
{
	if ((!XN_CheckCnText(str))&theMin!=0){return (MustbeIncludeCnText)}
	if ((theMin==theMax)&GetLength(str)!=theMin){return (NotEqual.replace("$$",theMin));}
	if (GetLength(str)<theMin){return (LessThan.replace("$$",theMin));}
	else if (GetLength(str)>theMax){return (MoreThan.replace("$$",theMax));}
	else{return (Validationstr);}
}

function XN_CheckAllCnStrLen(str,theMin,theMax)
{
	if ((!XN_CheckAllCnText(str))&theMin!=0){return (MustbeAllCnText)}
	if ((theMin==theMax)&str.length!=theMin){return (NotEqual.replace("$$",theMin));}
	if (str.length<theMin){return (LessThan.replace("$$",theMin));}
	else if (str.length>theMax){return (MoreThan.replace("$$",theMax));}
	else{return (Validationstr);}
}

function XN_CheckNumberSize(str,theMin,theMax)
{
	if (theMin!="0"&str==""){return (NotAllowEmpty);}
	if (isNaN(str)|str==""){return (MustBeNumber);}
	if (theMin==theMax){
		if (GetLength(str)==theMin){return (Validationstr)}else{return(numNotEqual.replace("$$",theMin));}
	}
	else{
		if (str<theMin){return (Toosmall.replace("$$",theMin));}
		else if (str>theMax){return (Toobig.replace("$$",theMax));}
		else{return (Validationstr);}
	}
}

function XN_CheckNumber(str)
{
	if (isNaN(str)|str==""){return (MustBeNumber);}
	else {return (Validationstr) ;}
}



function XN_CheckNumberLen(str,theMin,theMax)
{
	if (theMin!="0"&str==""){return (NotAllowEmpty);}
	if (isNaN(str)|str==""){return (MustBeNumber);}
	if (theMin==theMax){
		if (GetLength(str)==theMin){return (Validationstr)}else{return(numNotEqual.replace("$$",theMin));}
	}
	else{
		if (GetLength(str)<theMin){return (LessThan.replace("$$",theMin));}
		else if (GetLength(str)>theMax){return (MoreThan.replace("$$",theMax));}
		else{return (Validationstr);}
	}
}

function XN_CheckRadio(obj)
{
	var i,n=0;
	for(i=0 ;i<obj.length;i++)
	if(obj[i].checked){n++;}
	if (n<1){return (RadioErr);}else{return (Validationstr);}
}

function XN_CheckCheckbox(obj,theMin,theMax)
{
	var i,n=0;
	for(i=0 ;i<obj.length;i++)
	if(obj[i].checked){n++;}
	if (n<1&&theMin==1){return (RadioErr);}
	else{if (n<theMin|n>theMax){return (CheckboxErr.replace("$1",theMin).replace("$2",theMax));}else{return (Validationstr);}}
}

function XN_CheckIsSame(str1,str2)
{
	if (str1!=str2){return (Notsamevalue);}else{return (Validationstr);}
}

function XN_CheckSelect(str)
{
	if (str.length>0){return (Validationstr);}
	else{return (RadioErr)}
}

function dlg(urls,h,w)
{
	showModalDialog(urls,window,'edge: Raised; center: Yes; help: Yes; resizable: Yes; status: No;dialogHeight:'+h+'px;dialogWidth:'+w+'px');
}