//函数的javascript判断 

  var checked=false;
  var checkfk=false;
function check(i)
{ 
   switch(i)
   {
    case 1:
     if(document.form1.username.value=="")
   {
      
      showStr.innerHTML="<font color=red >提示：用户名不能为空！！</font>";
      checked=false;
      //document.form1.username.focus();

   }
   else
   {
     showStr.innerHTML="<font color=blue size=2>√</font>";
	 checked=true;
   }
    break;
    case 2:
     	if(document.form1.password.value=="")
   {
      password.innerHTML="<font color=red size=2>提示：请输入密码！！</font>";
      checked=false;
      //document.form1.password.focus();

   }
   else
   {
      password.innerHTML="<font color=blue size=2>√</font>";
      checked=true;
   }
     	
   break;
    case 3:
      if (document.form1.email.value!="") 
     	{
     	   if (document.form1.email.value.length > 0 && !document.form1.email.value.match( /^.+@.+$/ )) 
     	       {
	             email.innerHTML="<font color=red size=2>提示：请输入有效的电子信箱</font>";
	             checked=false;
				//document.form1.email.focus();

	           }
	       else
               {
                 email.innerHTML="";
				 checked=true;
               }
        } 	
	 else
        {
     
           email.innerHTML="<font color=red size=2>提示：请输入有效的电子信箱</font>";
           checked=false;
           //document.form1.email.focus();

        }
	
   break;
    case 4:
      if(document.form1.repassword.value!=""){
      if(document.form1.repassword.value!=document.form1.password.value)
	{
	  repassword.innerHTML="<font color=red size=2>提示：两次输入的密码不一样！！</font>";
	  checked=false;
	  //document.form1.repassword.focus();

	}
	else
	{
	  repassword.innerHTML="";
	  checked=true;
	}
	}
	else{checked=false;}
	break;
	   }	  
}
function checkall()
{
   var i;
	for(i=1;i<3;i++){
	check(i);

	}
	//document.write(checked);

	if(checked==false)
	{
	  history.go(-1);

//	  return false;
	}
	else
	{
		checklogin();

	}
}
function checklogin()
{
	
	var user,pass,actionurl;
	user=document.getElementById("username").value;
	pass=document.getElementById("password").value;
	actionurl="checklogin.asp?user="+user+"&pass="+pass;
//	document.write(actionurl);

	CreateXMLHttpRequest();

	xmlHttp.onreadystatechange=loginstate;    //callback为回调函数
	xmlHttp.open("GET",actionurl,true);

	xmlHttp.send(null);

}
function checkyzm()
{
  var yzm,url1;
  yzm=document.getElementById("verfiy").value;
  url1="yzm.asp?yzm="+yzm;
  CreateXMLHttpRequest();

  xmlHttp.onreadystatechange=loginstate;    
  xmlHttp.open("GET",url1,true);

  xmlHttp.send(null);


}

//前台客户反馈信息表为空检查
function checkfk1(x)
{
  var user,commany,address1;
  user=document.getElementById("username").value;
  company=document.getElementById("company").value;
  address1=document.getElementById("address").value;
  tel=document.getElementById("tel").value;
  fax=document.getElementById("fax").value;
  email=document.getElementById("email").value;
  caption1=document.getElementById("caption").value;
  remark=document.getElementById("remark").value;
  switch(x)
  {
    case 0:
    if(user=="")
    {
    	cuser.innerHTML="<font color=red>Import your full name please! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        cuser.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
      case 1:
    if(company=="")
    {
    	ccompany.innerHTML="<font color=red>Import your CompanyName please! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        ccompany.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
    case 2:
    if(address1.length<6)
    {
    	caddress.innerHTML="<font color=red>Your Address is too short! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        caddress.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
 case 3:
    if(tel=="")
    {
    	ctel.innerHTML="<font color=red>Your the form contacting way is incorrect! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        ctel.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
     case 4:
    if(fax=="")
    {
    	cfax.innerHTML="<font color=red>Your the form fax is incorrect! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        cfax.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
    case 5:
    if(email=="")
    {
    	cemail.innerHTML="<font color=red>Your the form email is null! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        if (email.length > 0 && !email.match( /^.+@.+$/ )) 
     	       {
	            cemail.innerHTML="<font color=red>Your the form email is incorrect! !</font>";
    	        document.getElementById("submit").disabled=1;	
		checkfk=false;
           }
	          
	           else
	           {
                 cemail.innerHTML="<font color=blue>√</font>";
    	         document.getElementById("submit").disabled=0;
		checkfk=true;
      }
    }
    break;
     case 6:
    if(caption1=="")
    {
    	ccaption.innerHTML="<font color=red>Your the caption is null! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        ccaption.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
     case 7:
    if(remark=="")
    {
    	cremark.innerHTML="<font color=red>Your the remark is null! !</font>";
    	document.getElementById("submit").disabled=1;
	checkfk=false;
    }
    else
    {
        cremark.innerHTML="<font color=blue>√</font>";
    	document.getElementById("submit").disabled=0;
	checkfk=true;
    }
    break;
  }
}

function checkfkall()
{
 var j,errnum;
 errnum=0;
//document.write("ffwfwf");

	for(j=0;j<8;j++){
	checkfk1(j);

	if(checkfk==false)
	{
	 errnum+=1;
	}
	}
//document.write(errnum);

	if(errnum<1)
	{
		handle(0);

	}
}
//利用ajax向服务器进行回调处理
 //0表示处理客户反馈信息
function handle(x)
{
  switch(x)
  {
	case 0:
	//保存客户反馈信息
	
	actionurl="savefk.asp?"+fkstring();

	//document.write(actionurl);

	ajax(0);

	break;
      
  }
}

//ajax函数
function ajax(x)
{
        CreateXMLHttpRequest();

     switch(x){
	case 0:
	xmlHttp.onreadystatechange=savefkstate; 
	break;
	}
	xmlHttp.open("GET",actionurl,true);

	xmlHttp.send(null);

}
//反馈信息的url字符串处理
function fkstring()
{
 var user,commany,address1,urlstring;
        user=document.getElementById("username").value;
        company=document.getElementById("company").value;
        address1=document.getElementById("address").value;
        tel=document.getElementById("tel").value;
        fax=document.getElementById("fax").value;
        email=document.getElementById("email").value;
        caption1=document.getElementById("caption").value;
        remark=document.getElementById("remark").value;
        urlstring="user="+user+"&company="+company+"&address="+address1+"&tel="+tel;
	urlstring+="&fax="+fax+"&email="+email+"&caption="+caption1+"&remark="+remark;
	return urlstring;
}
//清除文本框
function clean()
{
  document.getElementById("username").value="";
       document.getElementById("company").value="";
        document.getElementById("address").value="";
        document.getElementById("tel").value="";
        document.getElementById("fax").value="";
        document.getElementById("email").value="";
        document.getElementById("caption").value="";
        document.getElementById("remark").value="";
}