function barSearch()
	{
		
		var cid ;
		for(m=0;m<document.getElementById("country").length;m++)
		{	
			if(document.getElementById("country").options[m].selected==true && document.getElementById("country").options[m].value!="")
			cid = document.getElementById("country").options[m].text ;
		}
		document.getElementById("country").value = cid ;
		cid = '' ;

		for(m=0;m<document.getElementById("state").length;m++)
		{	
			if(document.getElementById("state").options[m].selected==true && document.getElementById("state").options[m].value!="")
			cid = document.getElementById("state").options[m].text ;
		}
		document.getElementById("state").value = cid ;
		cid = '' ;


		for(m=0;m<document.getElementById("city").length;m++)
		{	
			if(document.getElementById("city").options[m].selected==true && document.getElementById("city").options[m].value!="")
			cid = document.getElementById("city").options[m].text ;
		}
		document.getElementById("city").value = cid ;
		cid = '' ;



	 	document.getElementById("myform").submit();
		
	}
	

	
	function fillState()
{
		var arrManager=new Array();
		var cid ;
	  		 
		for(m=0;m<document.getElementById("country").length;m++)
		{	
			if(document.getElementById("country").options[m].selected==true && document.getElementById("country").options[m].value!="")
			cid = document.getElementById("country").options[m].value;
		}
			 		
			var poststr = "cid="+escape(encodeURI(cid));
     		makePOSTState('getstate.php', poststr);
		
}




function makePOSTState(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert("<?php echo _XMLHTTP_CREATE_ERROR; ?>");
         return false;
      }
      
      http_request.onreadystatechange = alertContentsState;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
function alertContentsState() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
			
			if(result.indexOf("ok")>-1)
			{
				word=result.split("|");
				//document.getElementById("cboRole").options[0]=null;
				for(l=document.getElementById("state").options.length-1;l>0;l--)
				{
					document.getElementById("state").options[l]=null;
				}
				

				for(l=document.getElementById("city").options.length;l>0;l--)
				{
					document.getElementById("city").options[0]=null;
				}
				document.getElementById("city_details").innerHTML= "";
				if((word.length-1)%3==0)
				{
					var l=1;
					while(l<word.length)
					{
						if((l-1)%3==0)
						{
						
							var opt = document.createElement("option");
							
							opt.setAttribute('value',word[l]); // set the value-attribute of it:
							opt.setAttribute('id','state_option'+word[l]);
							
							opt.innerHTML = word[l+2];// set the displayed value:
							
							document.getElementById("state").appendChild(opt);
							
							l=l+2;
						}
						l++;
					}
					
				}
					
	
				

				for(m=0;m<document.getElementById("country").length;m++)
				{	
				if(document.getElementById("country").options[m].selected==true && document.getElementById("country").options[m].value!="")
				cid = document.getElementById("country").options[m].value;
				}
				var poststr = "cid="+escape(encodeURI(cid));
     			makePOSTRequestCity('getallcityforcountry.php', poststr);
				//FillBarCount();	
				
			} 
			else
			{
				if(result.indexOf("ok")==-1)
				alert(result);
			}           
         } else {
            alert("<?php echo _XMLHTTP_CREATE_ERROR; ?>");
         }
      }
   }














   	function fillCity()
{
		var arrManager=new Array();
		var cid ;
	  		 
		for(m=0;m<document.getElementById("state").length;m++)
		{	
			if(document.getElementById("state").options[m].selected==true && document.getElementById("state").options[m].value!="")
			cid = document.getElementById("state").options[m].value;
		}
			 		
			var poststr = "sid="+escape(encodeURI(cid));
     		makePOSTRequestCity('getcity.php', poststr);
		
}




function makePOSTRequestCity(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert("<?php echo _XMLHTTP_CREATE_ERROR; ?>");
         return false;
      }
      
      http_request.onreadystatechange = alertContentsCity;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
function alertContentsCity() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
			
			if(result.indexOf("ok")>-1)
			{
				word=result.split("|");
				//document.getElementById("cboRole").options[0]=null;
				for(l=document.getElementById("city").options.length;l>0;l--)
				{
					document.getElementById("city").options[0]=null;
				}
				
				document.getElementById("city_details").innerHTML= "";

				if((word.length-1)%2==0)
				{
					var l=1;
					while(l<word.length)
					{
						if((l-1)%2==0)
						{
						
							var opt = document.createElement("option");
							
							opt.setAttribute('value',word[l]); // set the value-attribute of it:
							opt.setAttribute('id','city_option'+word[l]);
							
							opt.innerHTML = word[l+1];// set the displayed value:
							
							document.getElementById("city").appendChild(opt);
							
							l=l+1;
						}
						l++;
					}
					
				}
					
				//FillBarCount();
				
			} 
			else
			{
				if(result.indexOf("ok")==-1)
				alert(result);
			}           
         } else {
            alert("<?php echo _XMLHTTP_CREATE_ERROR; ?>");
         }
      }
   }




	function NextBar( pagenav )
	{

	var arrManager=new Array();
		var cid ,sid , id ;

		for(m=0;m<document.getElementById("country").length;m++)
		{	
			if(document.getElementById("country").options[m].selected==true && document.getElementById("country").options[m].value!="")
			cid = document.getElementById("country").options[m].value;
		}

	  		 
		for(m=0;m<document.getElementById("state").length;m++)
		{	
			if(document.getElementById("state").options[m].selected==true && document.getElementById("state").options[m].value!="")
			sid = document.getElementById("state").options[m].value;
		}

		for(m=0;m<document.getElementById("city").length;m++)
		{	
			if(document.getElementById("city").options[m].selected==true && document.getElementById("city").options[m].value!="")
			id = document.getElementById("city").options[m].value;
		}
			 		
			var poststr = "country="+escape(encodeURI(cid));
			poststr=poststr+"&state_province="+escape(encodeURI(sid));
			poststr=poststr+"&city="+escape(encodeURI(id));
			poststr=poststr+"&pagenav="+escape(encodeURI(pagenav));
			poststr=poststr+"&nav="+escape(encodeURI('next'));
			makePOSTBarCount('barcount.php', poststr);





	}
function PrevBar( pagenav )
{

	var arrManager=new Array();
		var cid ,sid , id ;

		for(m=0;m<document.getElementById("country").length;m++)
		{	
			if(document.getElementById("country").options[m].selected==true && document.getElementById("country").options[m].value!="")
			cid = document.getElementById("country").options[m].value;
		}

	  		 
		for(m=0;m<document.getElementById("state").length;m++)
		{	
			if(document.getElementById("state").options[m].selected==true && document.getElementById("state").options[m].value!="")
			sid = document.getElementById("state").options[m].value;
		}

		for(m=0;m<document.getElementById("city").length;m++)
		{	
			if(document.getElementById("city").options[m].selected==true && document.getElementById("city").options[m].value!="")
			id = document.getElementById("city").options[m].value;
		}
			 		
			var poststr = "country="+escape(encodeURI(cid));
			poststr=poststr+"&state_province="+escape(encodeURI(sid));
			poststr=poststr+"&city="+escape(encodeURI(id));
			poststr=poststr+"&pagenav="+escape(encodeURI(pagenav));
			poststr=poststr+"&nav="+escape(encodeURI('prev'));
			makePOSTBarCount('barcount.php', poststr);





	}

	



	function FillBarCount()
{
		var arrManager=new Array();
		var cid ,sid , id ;

		for(m=0;m<document.getElementById("country").length;m++)
		{	
			if(document.getElementById("country").options[m].selected==true && document.getElementById("country").options[m].value!="")
			cid = document.getElementById("country").options[m].value;
		}

	  		 
		for(m=0;m<document.getElementById("state").length;m++)
		{	
			if(document.getElementById("state").options[m].selected==true && document.getElementById("state").options[m].value!="")
			sid = document.getElementById("state").options[m].value;
		}

		for(m=0;m<document.getElementById("city").length;m++)
		{	
			if(document.getElementById("city").options[m].selected==true && document.getElementById("city").options[m].value!="")
			id = document.getElementById("city").options[m].value;
		}
			 		
			var poststr = "country="+escape(encodeURI(cid));
			poststr=poststr+"&state_province="+escape(encodeURI(sid));
			poststr=poststr+"&city="+escape(encodeURI(id));
     		makePOSTBarCount('barcount.php', poststr);
		
}


function makePOSTBarCount(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/xml');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert("<?php echo _XMLHTTP_CREATE_ERROR; ?>");
         return false;
      }
      
      http_request.onreadystatechange = alertBarCount;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }
function alertBarCount() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
			
			if(result.indexOf("ok")>-1)
			{
				word=result.split("|");
				
				document.getElementById("city_details").innerHTML=word[1];
				
			
				
			} 
			else
			{
				if(result.indexOf("ok")==-1)
				alert(result);
			}           
         } else {
            alert("<?php echo _XMLHTTP_CREATE_ERROR; ?>");
         }
      }
   }