//	Vamos a presuponer que el usuario es una persona inteligente...
var isIE = false;

//	Creamos una variable para el objeto XMLHttpRequest
var req;

//	Creamos una funcion para cargar los datos en nuestro objeto.
//	Logicamente, antes tenemos que crear el objeto.
//	Vease que la sintaxis varia dependiendo de si usamos un navegador decente
//	o Internet Explorer
function cargaXML(url) {
//alert('dentro cargaXml');
	//	Primero vamos a ver si la URL es una URL :)
	if(url==''){
		return;
	}
	//	Usuario inteligente...
	if (window.XMLHttpRequest) {
	   
		req = new XMLHttpRequest();
		//url3=url.substring(26,totalCaracteres);
		//req.open("get",'index.php?id='+url3);
		//alert('index.php?id='+url3);
		//alert('dentro window.xml 1 ');
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
		
	var totalCaracteres= url.length;
	url=url.substring(26,totalCaracteres);
	//alert('pruebaCarga2.php?id2='+url);
	url2='cargarMapa.php?controlAjax&id='+url;
	//url2='cargarMapa.php?id='+url;
	//alert(url2);
		req2 = new XMLHttpRequest();
		req2.onreadystatechange = processReqChange2;
		req2.open("GET", url2, true);
		req2.send(null);
		//alert('dentro window.xml 2 ');
	//	...y usuario de Internet Explorer Windows
	} else if (window.ActiveXObject) {
		isIE = true;
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
		var totalCaracteres= url.length;
	url=url.substring(26,totalCaracteres);
	//alert('pruebaCarga2.php?id2='+url);
		url2='cargarMapa.php?id='+url;
		req2 = new ActiveXObject("Microsoft.XMLHTTP");
		if (req2) {
			req2.onreadystatechange = processReqChange;
			req2.open("GET", url2, true);
			req2.send();
		}
	}
}

//	Funcion que se llama cada vez que se dispara el evento onreadystatechange
//	del objeto XMLHttpRequest
function processReqChange(){
//alert('dentro processReqChange 1 ');
	var detalles = document.getElementById("categorias");
	if(req.readyState == 4){
		detalles.innerHTML = req.responseText;
	} else {
		detalles.innerHTML = '<img src="loading.gif" align="middle" /> Loading...';
	}
}

function processReqChange2(){


//alert('dentro processReqChange 2 ');
	var detalles = document.getElementById("map");
	if(req2.readyState == 4){
		detalles.innerHTML = req2.responseText;
	} else {
		detalles.innerHTML = '<img src="loading.gif" align="middle" /> Loading...';
	}
}


var ajax = new sack();

function getCityList(categoriaCode)
{
	//alert(categoriaCode);
	//var categoriaCode = sel.options[sel.selectedIndex].value;
	//cargaXML('getCities.php?categoriaCode='.categoriaCode);
	document.getElementById('dhtmlgoodies_city').options.length = 0;	// Empty city select box
	if(categoriaCode.length>0){
		
		//alert(categoriaCode.length);
		//alert(sel.options[sel.selectedIndex].text);
		ajax.requestFile = 'getCities.php?categoriaCode='+categoriaCode;	// Specifying which file to get
		ajax.onCompletion = createCities;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function createCities()
{
	var obj = document.getElementById('dhtmlgoodies_city');
	//alert ('dentro createCities');
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}		