var siteurl='';

function setUrl(url){
	siteurl=url;
}
function submitThis(url, displaydiv){
	CalltoPhp(url, displaydiv);
}
function createQCObject(){ 
	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;
} 

function CalltoPhp(querystring, displaydiv){
    var http = createQCObject(); 
	var ran_no=(Math.round((Math.random()*9999))); 
	querystring=querystring+"&ran="+ran_no;
	http.open("GET",querystring,true);
   	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){ 
      		var response = http.responseText;
      		if(response){
				document.getElementById(displaydiv).innerHTML = http.responseText; 
      		} 
   		} 
	} 
   	http.send(null); 
}


function getVisatypes(){
	var to_country = document.formList.to_country;
	id = to_country.options[to_country.selectedIndex].value;
	document.formList.visatype.length = 0;
	document.formList.visatype.options[0] = new Option('Loading...','');
	var http = createQCObject(); 
	var ran_no=(Math.round((Math.random()*9999))); 
	querystring				=	siteurl+'common/ajaxCommon.php?functiontype=visatypes&id='+id;
	http.open("GET",querystring,true);
   	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200){ 
      		var response = http.responseText;
			document.formList.visatype.length = 0;
      		if(response){
				var newVal	=	response.split("|");
				if(newVal.length>0){
						document.formList.visatype.options[0] = new Option('--Select--','');
					for(i=0;i<newVal.length;i++){
						var $opt =newVal[i].split(';');
						document.formList.visatype.options[i+1] = new Option($opt[1], $opt[0]);
					}
					
				}
      		} 
   		} 
	} 
   	http.send(null); 
}
