

/*---------------------SendBusinssInfo Start---------------------------------*/


function cus_infoCheck()
{    
		
	if( _("txtTitle").value =="") {
		alert("\请输入商机名称 !");
		_("txtTitle").select();
		_("txtTitle").focus();
		return false;
	}	
	if( _("ManuList").value =="-1") {
		alert("\请选择一级类别 !");
		//_("ManuList").select();
		_("ManuList").focus();
		return false;
	}
	if(_("ModelList").value =="" || _("ModelList").value =="0") {
		alert("\请选择二级类别 !");
		//_("ModelList").select();
		_("ModelList").focus();
		return false;
	}
	if( _("txtvtime").value =="") {
		alert("\请输入商机有效期 !");
		_("txtvtime").select();
		_("txtvtime").focus();
		return false;
	}	
	
	if( _("txtContent").value =="") {
		alert("\请输入商机描述 !");
		_("txtContent").select();
		_("txtContent").focus();
		return false;
	}
	
	if(comparedate("txtvtime")==false)
	{
	   alert("\有效期小于发布日期 !");
		_("txtvtime").select();
		_("txtvtime").focus();
		return false;
	}
	if( _("txtcode").value == "" || !( /^\w{5}$/.test( _("txtcode").value) ) || _("txtcode").value.length != 5 )
    {
      alert("\输入的验证码不正确 !");
      _("txtcode").select();
		_("txtcode").focus();
      return false;    
    }    

   
	return true;
	
	
}

/*---------------------SendBusinssInfo  End---------------------------------*/



/*---------------------CustomBusinssInfo Start---------------------------------*/


function CustomBusinssInfoCheck()
{    
	if( _("AreaClassOne").value =="0") {
		alert("\请选择地区一级类别 !");
		//_("ManuList").select();
		_("AreaClassOne").focus();
		return false;
	}
	if(_("AreaClassTwo").value =="" || _("AreaClassTwo").value =="0") {
		alert("\请选择地区二级类别 !");
		//_("ModelList").select();
		_("AreaClassTwo").focus();
		return false;
	}
			
	if( _("Title").value =="") {
		alert("\请输入商机名称 !");
		_("Title").select();
		_("Title").focus();
		return false;
	}	
	if( _("ClassOne").value =="0") {
		alert("\请选择一级类别 !");
		//_("ManuList").select();
		_("ClassOne").focus();
		return false;
	}
	if(_("ClassTwo").value =="" || _("ClassTwo").value =="0") {
		alert("\请选择二级类别 !");
		//_("ModelList").select();
		_("ClassTwo").focus();
		return false;
	}
	if( _("ValidTime").value =="") {
		alert("\请输入商机有效期 !");
		_("ValidTime").select();
		_("ValidTime").focus();
		return false;
	}	
	
	if(comparedate("ValidTime")==false)
	{
	   alert("\有效期小于发布日期 !");
		_("ValidTime").select();
		_("ValidTime").focus();
		return false;
	}	
	
	if( _("Content").value =="") {
		alert("\请输入商机描述 !");
		_("Content").select();
		_("Content").focus();
		return false;
	}	

	if( _("CompanyName").value =="") {
		alert("\请输入企业名称 !");
		_("CompanyName").select();
		_("CompanyName").focus();
		return false;
	}
	
	if( _("ContactMan").value =="") {
		alert("\请输入联系人 !");
		_("ContactMan").select();
		_("ContactMan").focus();
		return false;
	}
	
	if( _("Contact").value =="") {
		alert("\请输入联系方式 !");
		_("Contact").select();
		_("Contact").focus();
		return false;
	}		
	
	if( _("ValidCode").value == "" || !( /^\w{5}$/.test( _("ValidCode").value) ) || _("ValidCode").value.length != 5 )
    {
      alert("\输入的验证码不正确 !");
      _("ValidCode").select();
		_("ValidCode").focus();
      return false;    
    }    

   
	return true;
	
	
}

/*---------------------CustomBusinssInfo  End---------------------------------*/


/*----------------------------检测企业用户三级域名合法性--------------------*/

function CheckCompanyUserDomainName() {
	var domainName = document.getElementById("DomainName").value;
	if( domainName == "" || domainName == null ){
		alert( "请先填写域名！" );
		_("DomainName").focus();
		return false;
	}
	
	if(! /^.{3,10}$/.test( domainName ) ){
		alert( "域名长度在3到10位之间！" );
		_("DomainName").focus();
		return false;
	}
	if(! /^[A-Za-z0-9]+$/.test( domainName ) ){
		alert( "域名只能是数字和字母的组合！" );
		_("DomainName").focus();
		return false;
	}
	return true;
}

/*--------------------------------------检测结束----------------------------*/

/*----------------------------检测用户Blog输入合法性--------------------*/

function CheckUserBlogForm() 
{
	if( _("RegBlog1_BlogName").value == "" ) {
		alert("\博客名不能为空 !");
		_("RegBlog1_BlogName").focus();
		return false;
	}
	if( !/^[^%&$#@!*()?\^,\\|.<>\[\]\{\}=~`\/]*$/.test( _("RegBlog1_BlogName").value )) {
		alert("\请重新输入博客名,博客名不能包括特殊字符!");
		_("RegBlog1_BlogName").select();
		_("RegBlog1_BlogName").focus();
		return false;
	}	
	
	if( _("RegBlog1_BlogTitle").value == "" ) {
		alert("\博客标题不能为空 !");
		_("RegBlog1_BlogTitle").focus();
		return false;
	}
	if( !/^[^%&$#@!*()?\^,\\|.<>\[\]\{\}=~`\/]*$/.test( _("RegBlog1_BlogTitle").value )) {
		alert("\请重新输入博客标题,博客标题不能包括特殊字符!");
		_("RegBlog1_BlogTitle").select();
		_("RegBlog1_BlogTitle").focus();
		return false;
	}	
	
	var domainName = document.getElementById("RegBlog1_DomainName").value;	
	if( domainName == "" || domainName == null ){
		alert( "请先填写博客域名！" );
		_("RegBlog1_DomainName").focus();
		return false;
	}
	
	if(! /^.{3,10}$/.test( domainName ) ){
		alert( "博客域名长度在3到10位之间！" );
		_("RegBlog1_DomainName").focus();
		return false;
	}
	if(! /^[A-Za-z0-9]+$/.test( domainName ) ){
		alert( "博客域名只能是数字和字母的组合！" );
		_("RegBlog1_DomainName").focus();
		return false;
	}	
				
	return true;
}

/*--------------------------------------检测结束----------------------------*/


/*---------------------用户注册Start---------------------------------*/
function checkUsername() {
	var username = document.getElementById("txtusername").value;
	if( username == "" || username == null ){
		alert( "请先填写用户名！" );
		return false;
	}
	switch( isUsername( username ) ){
		case 0: break;
		case 1:	{
			changeUsernamePrompt( "您选择的用户名‘"+username+"’格式不正确，用户名不能以数字开头" );
			return false;
		}
		case 2:	{
			changeUsernamePrompt( "您选择的用户名‘"+username+"’字符长度有误，合法长度为3-18个字符" );
			return false;
		}
		case 3:	{
			changeUsernamePrompt( "您选择的用户名‘"+username+"’含有非法字符，用户名只能包含_,中英文，数字" );
			return false;
		}
		case 4:	{
			changeUsernamePrompt( "您选择的用户名‘"+username+"’格式不正确，用户名只能包含_,中英文，数字" );
			return false;
		}
	}
	return true;
}

function ShowCheckName()
{
  if(checkUsername())
   {
	var openStr;
	openStr = "regCheck.aspx?RegName=" + _("txtusername").value;
	window.open(openStr,'','top=150,left=200,width=300,height=200');
   }
}
function changeUsernamePrompt(cnt){
	//document.getElementById( "failinfo" ).innerHTML = cnt;
	//document.getElementById( "failinfo" ).style.display = "";[\u4e00-\u9fa5]|
	alert(cnt);
	_("txtusername").focus();
}

function isUsername( username ){
	if( /^\d.*$/.test( username ) ){
		return 1;
	}
	if(! /^.{3,18}$/.test( username ) ){
		return 2;
	}
	if(! /^([\u4e00-\u9fa5]|[\w_])*$/.test( username ) ){
		return 3;
	}
	if(! /^(([\u4e00-\u9fa5]|[a-z]|[A-Z])*([\u4e00-\u9fa5]|[\w_])*){3,18}$/.test( username ) ){
		return 4;
	}
	return 0;
}

function checkPWD( me ){
	if( ! isPassword( me.value ) || !/^[^%&]*$/.test( me.value )) alert("密码长度或格式不正确！");	
}
function isPassword( str ){
	if (str.length < 6 || str.length > 16) return false;
	var len;
	var i;
	len = 0;
	for (i=0;i<str.length;i++){
		if (str.charCodeAt(i)>255) return false;
	}
	return true;
}
function checkNumber( num ,max){
    if( /^[0-9]+$/.test( num ) && num <=max)
		return true;
	else return false;
}

function confirmPwd( me ){
	var oPassword = _( "txtpwd" );
	if( ! ( me.value == oPassword.value ) || ! isPassword( me.value ) ) alert("确认密码不正确！");
}
function checkVerifyCode( me ){
	if( me.value == "" || !( /^\w{5}$/.test( me.value ) ) || me.value.length != 5 )  alert("验证码长度或格式不正确！");
}

function isAnswer( answer ){
	return /^[^%&]{2,20}$/.test( answer );
}

function checkAnswer( me ){
	if( ! isAnswer( me.value ) ) _( "answerConfirm" ).style.display = "";
}
function _(id) {
	return document.getElementById(id);
}
function checkemail( me ){
	if(!isAlt_email(me.value)) 
	{
	   alert("请填写email");
	}
}

function checkCustomQuestion( customquestion )
{   
    if ( customquestion == null || customquestion == "" )
    {
    	alert("请填写提示问题");
    	return;
    }
    if ( customquestion.length > 30 )
    {
    	alert("提示问题答案应不超过30个字符");
    	return;
    }
    if(! /^[^%&]+$/.test( customquestion ) )
    {
    	alert("提示问题中不能包含'%'和'&'这两个字符");
    	return;
    }
}

function isAlt_email(alt_email){
    return (/^[^@]+@[^@]+\.[^@]+$/.test(alt_email) && alt_email.length<128 );
}

function fCheck(){	
	if (!_("memberType1").checked && !_("memberType2").checked && !_("memberType4").checked)
	{
		alert("\请选择会员类型 !");
		_("memberType1").focus();
		return false;
	}
	if( _("txtUserName").value == "" ) {
		alert("\用户名不能为空 !");
		_("txtUserName").focus();
		return false;
	}
	if( _("txtUserName").value.length <3 ) {
		alert("\用户名长度不能小与三位 !");
		_("txtUserName").focus();
		return false;
	}	
	if( !/^[^%&$#@!*()?\^,\\|.<>\[\]\{\}=~`\/]*$/.test( _("txtUserName").value )) {
		alert("\请重新输入用户名,用户名不能包括特殊字符!");
		_("txtUserName").select();
		_("txtUserName").focus();
		return false;
	}	
	if( ! isPassword( _("txtpwd").value ) || !/^[^%&]*$/.test( _("txtpwd").value )) {
		alert("\请重新输入密码,密码由至少6个英文字母、数字、特殊字符等组成(不能包含'%'和'&'这两个字符) !");
		_("txtpwd").select();
		_("txtpwd").focus();
		return false;
	}
	if( _("txtpwdcf").value =="" ) {
		alert("\请输入密码确认 !");
		_("txtpwdcf").select();
		_("txtpwdcf").focus();
		return false;
	}
	if( _("txtpwdcf").value != _("txtpwd").value ) {
		alert("\两次密码输入不一致 !");
		_("txtpwdcf").select();
		_("txtpwdcf").focus();
		return false;
	}
	if(_("txtemail").value !="") {
		if(!isAlt_email(_("txtemail").value)) {
			alert("请正确填写其他常用邮箱！");
			_("txtemail").select();
			_("txtemail").focus();
			return false;
		}
	}	
	if( _("txtquestion").value !="" ) {		
			var customquestion = _("txtquestion").value;
			if ( customquestion == null || customquestion == "" ){
				alert("请填写自定义提示问题");
				_("txtquestion").select();
				_("txtquestion").focus();
				return false;
			}
			if ( customquestion.length > 30 ){
				alert("提示问题答案应不超过30个字符");
				_("txtquestion").select();
				_("txtquestion").focus();
				return false;
			}
			if(! /^[^%&]+$/.test( customquestion ) ){
				alert("提示问题中不能包含'%'和'&'这两个字符");
				_("txtquestion").select();
				_("txtquestion").focus();
				return false;
			}		
		
		if( ! isAnswer( _("txtanswer").value )  ) {
			alert("\密码提示答案为空或者长度不对，请重新输入密码提示答案 !");
			_("txtanswer").select();
			_("txtanswer").focus();
			return false;
		}
		if( (_("txtanswer").value.indexOf( "&" ) != -1) || (_("txtanswer").value.indexOf( "%" ) != -1) ) {
			alert("\请重新输入密码提示答案,密码提示答案中不允许含有'&'和'%'字符 !");
			_("txtanswer").select();
			_("txtanswer").focus();
			return false;
		}
	}	
	if( _("txtcode").value =="") {
		alert("\请输入您的验证码 !");
		_("txtcode").select();
		_("txtcode").focus();
		return false;
	}	
	return true;
}
/*---------------------用户注册END---------------------------------*/
