
var xmlHttp;

function createxmlhttp()
{
//    xmlhttpobj = false;
//    try{//创建对象
//        xmlhttpobj = new XMLHttpRequest;
//    }catch(e){
//        try{
//            xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
//        }catch(e2){
//            try{
//                xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
//            }catch(e3){
//                xmlhttpobj = false;
//            }
//        }
//    }
//    return xmlhttpobj; 
        //alert("Begin-----");
  		if(window.XMLHttpRequest)
  		{
  			xmlHttp = new XMLHttpRequest();
			//alert("Begin1111-----");
  		}else if(window.ActiveXObject)
  		{
  			try{
  				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				
  			}catch(e){
  				try{
  					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					
  				}catch(e){
  					alert("创建异步对象失败");
  				}
  			}
  		}
  		if(!xmlHttp)
  		{
  			alert("创建异步对象失败");
  			return;
  		}
		
}


function getSubItems(bigclassid,divId){
	
	if(bigclassid==0){
		document.getElementById("AreaId").innerHTML="<select name='AreaId'><option value='0' selected>--请选择--</option></select>";
		document.getElementById("CountryId").innerHTML="<select name='CountryId'><option value='0' selected>--请选择--</option></select>";
		return;
	};
	
	
//	var xmlhttpobj = createxmlhttp();

	createxmlhttp();
	
	var type="";
	
	type="queryArea";
	
	
	if(divId=="CountryId"){
		flag=0
	}else{
		flag=1
	}
	
	if(xmlHttp){//如果创建对象xmlhttpobj成功
		xmlHttp.open('get',"../Template/getSubItems.asp?BigType="+bigclassid+"&flag="+flag+"&action="+type+"&number="+Math.random(),true);//get方法 加个随机数。
		
		//alert(divId);
		
		xmlHttp.send(null);
		
		xmlHttp.onreadystatechange=function(){//客户端监控函数
			//html=xmlHttp.responseText;
			
			if(xmlHttp.readyState==4){//服务器处理请求完成
				
		     if(xmlHttp.status==200){
			
			//alert('ok');

				var html = xmlHttp.responseText;//获得返回值
				//alert(html);
				showResult(xmlHttp.responseText,divId);
				//document.getElementById(divId).innerHTML=html;
				}else{
					document.getElementById(divId).innerHTML="对不起，您请求的页面有问题...";
				}
				
			}else{
				//alert(html);
				//alert(xmlHttp.readystate+"error");
				
				document.getElementById(divId).innerHTML="正在加载页面...";//服务器处理中
			}
			
		}	
	}
}


function createoption(proid,proname,pro){
var oSelect=document.getElementById(pro)
var   cld=document.createElement('option');  
var   text=document.createTextNode(proname);
   cld.setAttribute('value', proid); 
   //alert("aaa");
   cld.appendChild(text); 
  oSelect.appendChild(cld);
}


function showResult(oText,pro){
 var ss,i;
// alert(oText);
 ss=oText.split("|");
 //alert(ss.length);
 for(i=0;i<=ss.length;i=i+1){
	tempop=ss[i].split(",");
	proid=tempop[0];
	proname=tempop[1];
	//alert(proid.length);
	if(proid.length==0){
	//   alert(proid.length+"aaa");
	   proid=0;
	   proname="--请选择分类--";
	}
	createoption(proid,proname,pro);
 }
}


function Visa_List(bigclassid,divId){
	
	if(bigclassid==0){
		document.getElementById("AreaId").innerHTML="<select name='QTitle'><option value='0' selected>--请选择--</option></select>";
		document.getElementById("CountryId").innerHTML="<select name='VisaType'><option value='0' selected>--暂无--</option></select>";
		return;
	};
	
	
//	var xmlhttpobj = createxmlhttp();

	createxmlhttp();
	
	var type="";
	
	type="queryVisa";
	
	
	if(xmlHttp){//如果创建对象xmlhttpobj成功
		xmlHttp.open('get',"../Template/getSubItems.asp?BigType="+bigclassid+"&action="+type+"&number="+Math.random(),true);//get方法 加个随机数。
		
		//alert(divId);
		
		xmlHttp.send(null);
		
		xmlHttp.onreadystatechange=function(){//客户端监控函数
			//html=xmlHttp.responseText;
			
			if(xmlHttp.readyState==4){//服务器处理请求完成
				
		     if(xmlHttp.status==200){
			
			//alert('ok');

				var html = xmlHttp.responseText;//获得返回值
				//alert(html);
				showResult(xmlHttp.responseText,divId);
				//document.getElementById(divId).innerHTML=html;
				}else{
					document.getElementById(divId).innerHTML="对不起，您请求的页面有问题...";
				}
				
			}else{
				//alert(html);
				//alert(xmlHttp.readystate+"error");
				
				document.getElementById(divId).innerHTML="正在加载页面...";//服务器处理中
			}
			
		}	
	}
}



function GetUserName(x,divId){


	createxmlhttp();
	
	var type="";
	
	type="queryUser";
	
	
	if(xmlHttp){//如果创建对象xmlhttpobj成功
		xmlHttp.open('get',"../Template/getSubItems.asp?BigType="+x+"&action="+type+"&number="+Math.random(),true);//get方法 加个随机数。
		
		//alert(divId);
		
		xmlHttp.send(null);
		
		xmlHttp.onreadystatechange=function(){//客户端监控函数
			//html=xmlHttp.responseText;
			
			if(xmlHttp.readyState==4){//服务器处理请求完成
				
		     if(xmlHttp.status==200){
			
			//alert('ok');

				var html = xmlHttp.responseText;//获得返回值
					if(html=="false"){
						document.getElementById(divId).innerHTML="<font color='#FF0000'>此账号已被注册！请重新输入！</font>";
						document.getElementById("Account1").value="";
					}else if(html=="true"){
						
					 document.getElementById(divId).innerHTML="<font color='#FF0000'>恭喜：该账号可以注册！</font>";	
					}
				
				}else{
					document.getElementById(divId).innerHTML="对不起，您请求的页面有问题...";
				}
				
			}else{
				//alert(html);
				//alert(xmlHttp.readystate+"error");
				
				document.getElementById(divId).innerHTML="正在加载页面...";//服务器处理中
			}
			
		}	
	}
}


function GetUserTelephone(x,divId){


	createxmlhttp();
	
	var type="";
	
	type="queryTelephone";
	
	
	if(xmlHttp){//如果创建对象xmlhttpobj成功
		xmlHttp.open('get',"../Template/getSubItems.asp?BigType="+x+"&action="+type+"&number="+Math.random(),true);//get方法 加个随机数。
		
		//alert(divId);
		
		xmlHttp.send(null);
		
		xmlHttp.onreadystatechange=function(){//客户端监控函数
			//html=xmlHttp.responseText;
			
			if(xmlHttp.readyState==4){//服务器处理请求完成
				
		     if(xmlHttp.status==200){
			
			//alert('ok');

				var html = xmlHttp.responseText;//获得返回值
					if(html=="false"){
						document.getElementById(divId).innerHTML="<font color='#FF0000'>此手机号已被注册！请重新输入！</font>";
						document.getElementById("Telephone").value="";
					}else if(html=="true"){
						
					 document.getElementById(divId).innerHTML="<font color='#FF0000'>恭喜：该手机可以注册！</font>";	
					}
				
				}else{
					document.getElementById(divId).innerHTML="对不起，您请求的页面有问题...";
				}
				
			}else{
				//alert(html);
				//alert(xmlHttp.readystate+"error");
				
				document.getElementById(divId).innerHTML="正在加载页面...";//服务器处理中
			}
			
		}	
	}
}
