//Design By L.C.H
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function fucCheckLength(strTemp)
{
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++)
	{
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else
			sum=sum+2;
	}
	return sum;
}
function IsDigit(cCheck)      
 {      
 return (('0'<=cCheck) && (cCheck<='9'));      
 }      
      
function IsAlpha(cCheck)      
 {      
 return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))      
 }
function Juge(theForm)
{
  username=theForm.username.value;
  if (username == "")
  {
    alert("请输入用户帐号!");
    theForm.username.focus();
    return (false);
  }
  if (fucCheckLength(theForm.username.value) <4 )
	{
		alert("用户帐号必须至少4位或2个中文");
		theForm.username.focus();
		return (false);
	}
pwd1=theForm.pwd1.value	
	if (pwd1.value == "")
  {
    alert("请输入您的密码!");
    pwd1.focus();
    return (false);
  }
  if (fucCheckLength(theForm.pwd1.value) <4 )
	{
		alert("密码必须至少4位");
		theForm.pwd1.focus();
		return (false);
	}  
  	if (theForm.pwd2.value == "")
  {
    alert("请输入您的确认密码!");
    theForm.pwd2.focus();
    return (false);
  }
  if (theForm.pwd1.value !=theForm.pwd2.value)
  {
    alert("两次密码输入不一样");
    theForm.pwd1.focus();
    return (false);
  }
   if (theForm.ques.value == "")
  {
    alert("请输入提示问题");
    theForm.ques.focus();
    return (false);
  }
  if (theForm.answ.value == "")
  {
    alert("请输入提示答案");
    theForm.answ.focus();
    return (false);
  }
  if(!theForm.email.value.strEmail()) {
			alert("邮箱地址填写不正确！");
			theForm.email.focus();
			return false;
	}
  if (theForm.web.value == "")
  {
    alert("请输入网站名称");
    theForm.web.focus();
    return (false);
  }
  if (theForm.url.value == "")
  {
    alert("请输入网址");
    theForm.url.focus();
    return (false);
  }
}
//===========================================================================

function check_username() {
var _value = document.forms[0].elements[0].value.toLowerCase();
	if (fucCheckLength(_value) <4 )
	{
		alert("用户帐号必须至少4位或2个中文");
	    document.forms[0].elements[0].focus();;
		return;
	}
			var open_url = "chkreg.asp?username=" + _value;
			var _return = showDialog(open_url, 380, 280, _value);
			//window.open(open_url,'','status=0,directories=0,resizable=0,toolbar=0,location=0,scrollbars=0,width=350,height=200');
	}
//-----------------------------------------------------------------------------------
var regList = {
	chinese:/^([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*$/gi,
	code:/^\d{1,6}?$/,
	number:/^[0-9]*$/,
	pcode:/^((\d{1,15})|(\d{1,18})|(\d{1,17}x))?$/,
	mobile:/^13(\d{1,9})?$/,
	username:/^[A-Za-z0-9\-\_]*$/,
	vcode:/^[A-Za-z0-9]*$/,
	password:/^[A-Za-z0-9~`!@#$%\^&\*()\=\+_\-\.]*$/,
	chinese:/^[\u4E00-\u9FA5]*$/,
	url:/[A-Za-z0-9_\-\.\/\:]*$/,
	mail:/^[A-Za-z0-9_\-\.\@]*$/
}
function regInput(obj, reg, type) {
	if(event.keyCode!=13&&event.keyCode!=9) {
		var inputStr = (typeof(type)!='boolean')?String.fromCharCode(event.keyCode):window.clipboardData.getData('Text');
		var docSel= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length);
		reg = regList[reg];
		return reg.test(str);
	}
	else {
		if(checkSubmit()) document.forms[0].submit();
		return false;
	}
}
var showDialog = function(_url,_w,_h, _defaultValue) {
	return showModalDialog(_url, _defaultValue, "dialogWidth:" + _w + "px;dialogHeight:" + _h + "px;help:no;scroll:no;status:no");
}
//============检测邮箱
String.prototype.strEmail = function() {
	return /^([\.a-zA-Z0-9_-]){2,}@([a-zA-Z0-9_-]){2,}(\.([a-zA-Z0-9]){2,6}){1,3}$/.test(this);
}