//AJAX START
var xmlHttp

function setAjax(url,str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
url=url+"?"+str
url=url+"&rid="+Math.random()
xmlHttp.onreadystatechange=stateChangeds
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChangeds() 
{ 
//displace loading status
//var loadingDiv = document.getElementById("loading"); // get the div
//loadingDiv.innerHTML = "loading..."; // insert tip information
//loadingDiv.style.right = "0"; // set position, the distance to the right border of current document is 0px
//loadingDiv.style.top = "0"; // set position, the distance to the top border of current document is 0px
//loadingDiv.style.display = ""; // display the div
//load completed
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
//hide loading status
//loadingDiv.style.display = "none"; // after completed, hidden the div again
//loadingDiv.innerHTML = ""; // empty the tip information
//document.getElementById(outputID).innerHTML=xmlHttp.responseText 
var   response   =   xmlHttp.responseText;   
var   ss   =   response.split( '|'); 
var   outputID   =   ss[0];     //取出前面的id 
//alert(ss);
   if(xmlHttp.status == 200) {
      document.getElementById(outputID).innerHTML=ss[1];
   }else{
       alert("Error!" + "\nStatus code is: " + xmlHttp.status + "\nStatus text is: " + xmlHttp.statusText);
   }
} 
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
}
return xmlHttp;
}

//AJAX END


function showHintEmail(str,hintID,msg)
{
    var strP=/^\w+@[0-9a-zA-Z]+\.[a-zA-Z]+$/; 
    if(!strP.test(str)){
        document.getElementById(hintID).innerHTML=msg
    }else{
	 document.getElementById(hintID).innerHTML=""  
    }
} 

function showHintField(str,hintID,msg)
{
if (str.length==0 || str.length>250)
  { 
  document.getElementById(hintID).innerHTML=msg
  }else{
	 document.getElementById(hintID).innerHTML=""  
  }
}

 //验证只能输入数字.
function check_validate1(value){
    //定义正则表达式部分
    var strP = /^\d+$/;
    if(strP.test(value)){
        return true;
	}else{
        return false;	
	}
}
//验证只能输入字母.数字和下划线. 
function check_validate2(value){
    var strP = /^\w+$/;
    if(strP.test(value)){
        return true;
	}else{
        return false;	
	}

}
//验证固定电话：只能是数字.并且有相应的格式//028-67519441 或者 0839-8777222或者 028-6545124
function check_validate(value){
    var strP = /^(\d{3,4})-(\d{7,8})/;
    if(strP.test(value)){
        return true;
	}else{
        return false;	
	}
} 

//验证邮箱
function check_email(value){
    var strP=/^\w+@[0-9a-zA-Z]+\.[a-zA-Z]+$/; 
    if(strP.test(value)){
        return true;
	}else{
        return false;	
	}
} 


 function chkorder(){
     if (document.orderform.proname.value.length<1 || document.orderform.proname.value.length>255 ){
	    alert("你要参加的课程未选择！");
		document.orderform.proname.focus();
		return false; 
	 }
	 if (document.orderform.linkman.value.length<1 || document.orderform.linkman.value.length>4 ){
	    alert("姓名未填写或填写错误！");
		document.orderform.linkman.focus();
		return false; 
	 }
	 if (document.orderform.phone.value.length<7 || document.orderform.phone.value.length>50 ){
	    alert("联系方式未填写或填写不正确,请填写联系电话或手机号码！");
		document.orderform.phone.focus();
		return false; 
	 }
	 if (document.orderform.qq.value.length>0){
		if (document.orderform.qq.value.length<5 || document.orderform.qq.value.length>10 ){
	        alert("QQ号码位数不对，请输入5-10位以内QQ号码！");
		    document.orderform.qq.focus();
		    return false; 
		}
		if(!check_validate1(document.orderform.qq.value)){
			alert("QQ号码只能输入数字！");
		    document.orderform.qq.focus();
		    return false;
		}
	 }
      if(document.orderform.email.value.length>0){
         if(!check_email(document.orderform.email.value)){
             alert("您的邮箱填写不正确，请检查！");
             document.orderform.email.focus();
             return false; 
         }
      }
	  if(document.orderform.content.value.length>0){
          if (document.orderform.content.value.length>300 ){
			  alert("备注填写不能超过300个字！");
             document.orderform.content.focus();
             return false; 
		  }
	  }
//	  if(confirm("请确认您填写的信息正确无误，您真的要提交么？")){
//		return true;
//	  }else{
//		return false;
//	  }
 }


function chkgbook(){
	 if (document.gbookform.guestname.value.length<2 || document.gbookform.guestname.value.length>10 ){
	    alert("用户名称请输入2-10位以内！");
		document.gbookform.guestname.focus();
		return false; 
	 }
	 if (document.gbookform.phone.value.length>0){
	     if (document.gbookform.phone.value.length<7 || document.gbookform.phone.value.length>50 ){
	        alert("联系方式未填写或填写不正确,请填写联系电话或手机号码！");
		    document.gbookform.phone.focus();
		    return false; 
	     }
	 }
	 if (document.gbookform.qq.value.length>0){
		if (document.gbookform.qq.value.length<5 || document.gbookform.qq.value.length>10 ){
	        alert("QQ号码位数不对，请输入5-10位以内QQ号码！");
		    document.gbookform.qq.focus();
		    return false; 
		}
		if(!check_validate1(document.gbookform.qq.value)){
			alert("QQ号码只能输入数字！");
		    document.gbookform.qq.focus();
		    return false;
		}
	 }
	 if (document.gbookform.fax.value.length>0){
	     if (document.gbookform.fax.value.length<7 || document.gbookform.fax.value.length>30 ){
	        alert("联系传真未填写或填写不正确,请填写传真！");
		    document.gbookform.fax.focus();
		    return false; 
	     }
	 }
      if(document.gbookform.email.value.length>0){
         if(!check_email(document.gbookform.email.value)){
             alert("您的邮箱填写不正确，请检查！");
             document.gbookform.email.focus();
             return false; 
         }
      }
	  if (document.gbookform.content.value.length<2 || document.gbookform.content.value.length>300 ){
	     alert("请发表留言主题字数在2-300字之间");
		 document.gbookform.content.focus();
		 return false; 
	 }
}

