var xmlHttp

function LocCall(mid,sid,tp)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url
	if(mid!='none'){
		if(tp=='mainloc'){
			url='gmainloc.php?id='+mid+'&sid='+sid+'&tp='+tp
		}else if(tp=='subloc'){
			url = 'gsubloc.php?id='+mid+'&sid='+sid+'&tp='+tp
		}
	}else{
		document.register.fcountry.value = ''
		document.register.fcity.value = ''
		url='gmainloc.php?id='+mid+'&sid='+sid+'&tp='+tp
	}
		document.getElementById('othercitysub').style.display = 'none'
		document.getElementById('formothercity').style.display = 'none'
		xmlHttp.onreadystatechange=function() { stateChanged(mid,sid,tp) }
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
} 

function stateChanged(mid,sid,tp) 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	
	if(xmlHttp.responseText=='Error'){
		if(tp=='mainloc'){
			document.getElementById("mainloc").innerHTML= '' 
		}else if(tp=='bizname'){
			var serr = '<span class=disapproval>'+mid+' not accepted for registration.</span>'
			document.register.butSubmit.disabled = 'disabled'
			document.getElementById("subloc").innerHTML= serr 
		}
	}else{
		if(tp=='mainloc'){
			if(mid=='none'){
				document.register.fcountry.value = ''
			}else{
				document.register.fcountry.value = mid
			}
			document.register.fcity.value = ''
			document.getElementById("subloc").innerHTML= xmlHttp.responseText  
		}else if(tp=='bizname'){
			var serr = '<span class=disapproval>'+mid+' not accepted for registration.</span>'
			document.register.butSubmit.disabled = ''
			document.getElementById("subloc").innerHTML= serr 
		}
	}
}
} 

function GetXmlHttpObject()
{ 
var objxmlHttp=null
if (window.XMLHttpRequest)
{
objxmlHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objxmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objxmlHttp
} 

function SetVal(pid,tp){
	if(tp=='cat'){
		document.register.fcat.value = pid
	}else if(tp=='subloc'){
		document.register.fcity.value = pid
	}else if(tp=='pos'){
		document.register.fposition.value = pid
	}
	if(pid=='Other'){
		document.getElementById('othercitysub').style.display = ''
		document.getElementById('formothercity').style.display = ''
	}else{
		document.getElementById('othercitysub').style.display = 'none'
		document.getElementById('formothercity').style.display = 'none'
	}
}
