	var xmlrequest;
function newXMLHttpRequest() {
  var xmlreq = false;  
  if (window.XMLHttpRequest) {
  
    xmlreq = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
  
    try {    
      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");      
    } catch (e1) {
    
      try {
        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
      }
    }
  }
  return xmlreq;
}
var _xmlrequest=null;
function sendRequest(url){
	_xmlrequest=newXMLHttpRequest();
	_xmlrequest.onreadystatechange=callbackFun;
	_xmlrequest.open("get",url,true);
	_xmlrequest.send(null);
}
var _xmlChina = null;
function sendRequestChina(url){
	_xmlChina = newXMLHttpRequest();
	_xmlChina.onreadystatechange = chinaCallBack;
	_xmlChina.open("get",url,true);
	_xmlChina.send(null);
}
function chinaCallBack(){
	if(_xmlChina.readyState==4){
		if(_xmlChina.status==200){
			alert("china--2");
			//alert(_xmlChina.responseText)
			accountIndexArr=_xmlChina.responseText;
			//numberArr=accountIndexArr.split(',');
			//alert(accountIndexArr);
			//setAccountTypeSelectComponent(numberArr);
			createOptions(accountIndexArr);
		}
	}
}
function callbackFun(){
	if(_xmlrequest.readyState==4){
		if(_xmlrequest.status==200){
			//alert(_xmlrequest.responseText)
			accountIndexArr=_xmlrequest.responseText;
			//numberArr=accountIndexArr.split(',');
			//setAccountTypeSelectComponent(numberArr);
			createOptions(accountIndexArr);
		}
	}
}

function createOptions(AccountTypeArr){
	var select=createSelect();
	var optionLength=select.options.length;
		for(var i=optionLength-1;i>=0;i--){
			//select.options.remove(i);//this method can't use in firefox scan...
			select.options[i]=null;
	}
	var listStr=AccountTypeArr.split(">>");
	var arr=listStr[0].split("|");
	var defaultIndex=listStr[1].split("=");
	var defaultAffiliateArr=listStr[2].split("=");
	var defaultAffiliate=defaultAffiliateArr[1];
	setAffiliateComponent(defaultAffiliate);
	for(var i=0;i<arr.length;i++){
		if(""!=arr[i] && null!=arr[i]){
			var des=arr[i].split("=");
			var option=document.createElement("Option");
			select.appendChild(option);			
			option.value=des[0];
			option.text=des[1];
			if(option.value==defaultIndex[1]){
				option.selected=true;
			}
		}
	}
}
function createSelect(){
	var select=document.getElementById("accountType");
	/*if(select==null){
		select=document.createElement("select");
		select.id="accountType";
		select.style.width=260;
		try{
			if(accountTypeDisable){
				select.disabled="disabled";
			}
		}catch(e){}
		return select;
	}else{
		var optionLength=select.options.length;
		for(var i=optionLength-1;i>=0;i--){
			//select.options.remove(i);//this method can't use in firefox scan...
			select.options[i]=null;
		}
		return select;
	}*/
	return select;
}
function removeSelectOptions(selectComponent,indexArr,obj){
	var length=selectComponent.options.length;
	for(var i=length-1;i>=0;i--){
		var indexValue=selectComponent.options[i].value;
		var falg=false;
		for(var j=indexArr.length-1;j>=0;j--){
			if(indexValue==indexArr[j]){
				falg=true;
				break;
			}
		}
		if(!falg){
				selectComponent.options.remove(i);
		}
	}
	// add option
	var dellength=selectComponent.options.length;
	if(dellength==0){
		var orgLength=document.getElementsByName("marketer.accounttype")[0].options.length;
		var orgOptions=document.getElementsByName("marketer.accounttype")[0];
		for(var j=orgLength-1;j>=0;j--){
			var orgValue=orgOptions.options[j].value;
			var boo=false;
			for(var i=indexArr.length-1;i>=0;i--){
				if(orgValue==indexArr[i]){
					boo=true;
					break;
				}
			}
			if(boo){
				var option=document.createElement("option");
				var temp=orgOptions[j];	
				selectComponent.options.add(option);
				option.value=temp.value;
				option.innerText=temp.text;
			}
		}
		
		
	}
	obj.value=indexArr[indexArr.length-1];
}
function setStyleIsEnable(obj){
	obj.disabled="disabled";
}
function setStyleEnable(obj){
	obj.disabled="";
}
function pageLoadingSetAccountType(){
	//alert(_loading_accountArr_des);
	createOptions(_loading_accountArr_des);
}

function setAffiliateComponent(mes){
 	//var str="&nbsp;"+"<input type='text' id='affiliate' name='affiliate' value='"+mes+"' size='10' maxlength='10' onBlur='javascript:setAffiliateCode(this.value)'>";
   	//affiliate_value=mes;
    //document.getElementById("affiliate_td").innerHTML=str;
    try{
    	document.getElementById("affiliate2").value=mes;
    }catch(e){}
}

function pageLoadingSetAffiliate(){
	setAffiliateComponent(_loading_affiliate);
}

function setDefaultCountry(){
	var link=window.parent.location.href;
	var country=document.getElementsByName("marketer.country")[0];
	var phone=document.getElementsByName("marketer.phone")[0];
	if(link.indexOf("dibai.htm")>0){
		country.value="AE";
		phone.value="971";
	}else if(link.indexOf("licai18.htm")>0){
		country.value="CN";
		phone.value="86";
	}
}


function setFormOfActionProperty(){
	var index=window.parent.location.href.indexOf("licai18.htm");
	var dibaiindex=window.parent.location.href.indexOf("dibai.htm");
	var searchindex=window.parent.location.href.indexOf("search.htm");
	var fx618index=window.parent.location.href.indexOf("fx618.htm");
	if(index>0){
		document.forms[0].action="zhCNlandpage.hyml";
	}else if(dibaiindex>0){
		document.forms[0].action="dibaizhCNlandpage.hyml";
	}else if(searchindex>0){
		document.forms[0].action="searchCNlandpage.hyml";
	}else if(fx618index>0){
		document.forms[0].action="fx618CNlandpage.hyml";
	}else{
		document.forms[0].action="enloadhylp.hyml";
	}
	
}

