	var xmlHttp;
	var elemIdDondeInsertar = "";
	var counter = 0;

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}

	addLoadEvent (volverOpc);
	
	function busqProv (idProv, idLoc){
		document.getElementById("content").innerHTML="";
		document.myform.quebusc.value = "";
		counter = 0;
		elemIdDondeInsertar = "cmbLocalidad";
		ejecBusq (idProv,idLoc, "cmbLoca.php");
	}
	
	function busqLoc (idProv,idLoc){
		elemIdDondeInsertar = "content";
		ejecBusq (idProv,idLoc, "cmbBusqL.php");
	}
	
	function busQueda (buscado,idLoc){
		elemIdDondeInsertar = "content";
		ejecBusq (buscado,idLoc, "resBusq.php");
	}
	
	function ejecBusq (idProv, idLoc, fname){
		if (idProv.length == 0 || idLoc.length == 0){ 
			eval ("document.getElementById('" + elemIdDondeInsertar + "').innerHTML='No puede ingresar blanco'");
			return;
		}
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null){
			alert ("Browser does not support HTTP Request");
			return;
		} 
		eval ("var urel='" + fname + "'");
		urel = urel + "?p=" + idProv;
		urel = urel + "&l=" + idLoc;
		urel = urel + "&sid=" + Math.random();

		xmlHttp.onreadystatechange = stateChanged ;
		xmlHttp.open ("GET", urel, true);
		xmlHttp.send (null);
	} 

	function stateChanged(){ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			//document.getElementById ("imgLdng").style.visibility = 'hidden';
			eval ("document.getElementById('" + elemIdDondeInsertar + "').innerHTML=xmlHttp.responseText") ;
			if (document.myform.loca.length == 1 && counter == 0){
				busqLoc(document.myform.provin.value, document.myform.loca.value);
				document.myform.loca.blur();
				window.focus();
				counter = 1;
			}
			
			getcontent_height();
			
		} else if (xmlHttp.readyState==1 || xmlHttp.readyState==2 || xmlHttp.readyState==3){
			//document.getElementById ("imgLdng").style.visibility = 'visible';
		}
	} 

	function GetXmlHttpObject(){ 
		var objXMLHttp=null;
		if (window.XMLHttpRequest){
			objXMLHttp=new XMLHttpRequest();
		} else if (window.ActiveXObject){
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		return objXMLHttp
	} 
	
	function actionKey(e){
		if (e.keyCode == 13){
			var stbus = document.myform.quebusc.value;
			busQueda(stbus);
		}
		return true;
	}
	
	function volverOpc(){
		document.myform.provin.selectedIndex=0;
		document.myform.loca.selectedIndex=0;
	}

	function get(obj) {
		var i = 1;
		i++;
   }

