var http;// = getHTTPObject();
var srcobj;
var destinationobj_pob;
var pob_destinationobj;
var selected_value_pob;
var sel_id=0;
var fileobj;
// get poblancia according to zone 
function handleHttpResponse_zonepoblancia() 
{ 
	if (http.readyState == 4) 
	{	       
	  	isWorking = false;
    if (http.responseText.indexOf('invalid') == -1) 
		{
			var xmlDocument = http.responseXML; 
			var no = xmlDocument.getElementsByTagName('no').item(0).firstChild.data;
			//alert(pob_destinationobj);
			var Prod_Obj=pob_destinationobj;
			Prod_Obj.length=parseInt(no)+1;
			if(parseInt(no)>0)
			{			
				
				for(j=0,i=1;j<parseInt(no);i++,j++)
				{
		   			var iPId =xmlDocument.getElementsByTagName('id').item(j).firstChild.data;
	   		   		var PName =xmlDocument.getElementsByTagName('text').item(j).firstChild.data;
					//var SelVal = (selected_value_pob == iPId)? true : false ;
					if(selected_value == iPId) sel_id=i;
					Prod_Obj[i].value	= iPId;
	   				Prod_Obj[i].text 	= PName;
					//Prod_Obj[i].selected=SelVal;
   					isWorking = false;
  				}
				Prod_Obj[sel_id].selected=true;
    		}
			else
			{
				Prod_Obj.length=2;
				var SelVal = (selected_value_pob == 'Other')? true : false ;
				Prod_Obj[1].value	= 'Other';
   				Prod_Obj[1].text 	= 'Other';
				Prod_Obj[1].selected=SelVal;
				isWorking = false;
			}
		}
  		if(fileobj=="reservation" || fileobj=="promo_building")
			 getNombreAndCode( '' , '');		
	   else if(fileobj=="quotation")
			 getNombreAndCode( document.getElementById('hid_nombre').value, document.getElementById('hid_code').value);
	   else if(fileobj=="site_building")
	        getNombreAndCode( '' , '');
	}
}

function getPoblacionName(srcvalue, selected_val,dstselectid, file) 
{
  sel_id=0;
	if(!srcvalue)srcvalue='';
	if(!selected_val)selected_val='';
	if(!dstselectid)dstselectid='';
	fileobj=file;
	selected_value=selected_val;
	pob_destinationobj=document.getElementById(dstselectid);
	if(fileobj == 'siteuser')
	   var url = AJAX_URL+"getPoblancion.php?id_provincia="+srcvalue;
	else
	   var url = AJAX_URL+"getPoblancion.php?Code="+srcvalue;
//	alert(url);
	var isWorking = false;
	if (!isWorking)
	{
		//alert(url);
		if (window.XMLHttpRequest)
	  	{
	  		http=new XMLHttpRequest()
	  		http.open("GET",url, true);
		  	http.onreadystatechange=handleHttpResponse_zonepoblancia
		  	http.send(null)
	  	}
		// code for IE
		else if (window.ActiveXObject)
	  	{
	  		http=new ActiveXObject("Microsoft.XMLHTTP")
	    	if (http)
	    	{
	    		http.open("GET",url, true);
	    		http.onreadystatechange=handleHttpResponse_zonepoblancia
	    		http.send()
	    	}
	  	}
  	}
}

