   var http_request = false;   	
   function sndReqCat(pag) {	

		var thediv = document.getElementById('marco'); // the div	
		alert("pag");
		var dire='searchdest.php?p='+provincia+'&o='+nota+'&pd='+provinciad+'&od='+notad;	
	  	thediv.innerHTML = '<span class="loading"><br><br><br><br><br><br><br><br><br><br><br><strong>Cargando...</strong><br><img src="images/working.gif" /><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></span>';		
		//detallet_paso2(dire);					
	}
	
   
   function makeRequest_Cate(url) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 // alert("explorer "+url);
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
	  //alert("explorer d win "+url);
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
  
      if (!http_request) {
         alert('No se pudo crear la instancia XMLHTTP');
         return false;
      }
	 // valor=cate;
//	  alert("esta el el link completo "+url);
      http_request.onreadystatechange = alertContentsCat;	 
      http_request.open('GET', url, true);
	 // alert("despues de open");
      http_request.send(null);	
   }

   function alertContentsCat() {	  
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			//AQUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
            result = http_request.responseText;			
			var update = new Array();
			//alert("entre: "+result.indexOf('|'));
			//if(result.indexOf('|') != -1)
			//{
				update = result.split('|');	
				//changeTextCat(update[0], update[1]);
				//alert( "separando el contenido");
				//alert(update[0]+"    "+ update[1]+"    "+update[2]);
				changeTextCat(update[0]);
			//}     
         } 
		 else {
            alert('Hubo un problema en ejecutar la petición.');
         }
	
      }
//else{
//alert('algo paso.');
//}
   }

	function inicio(pag) {			
		
	    var thediv = document.getElementById('marco'); // the div
		var dire='videos.php?p='+pag;	
	  	thediv.innerHTML = '<span class="loading"><br><br><br><br><br><br><br><br><br><br><br><strong>Cargando...</strong><br><img src="images/working.gif" /><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></span>';			
		makeRequest_Cate(dire);	
		
	}
	
	function changeTextCat(text) {
		// Detect Browser
		id = parseInt('marco');
		var IE = (document.all) ? 1 : 0;
		var DOM = 0; 
		if (parseInt(navigator.appVersion) >=5) {DOM=1};		
		// Grab the content from the requested "div" and show it in the "container"
		if (DOM) {			
			if (id==-1)	{
			//	alert("aqui va: "+text+'  meter:  cate1['+nivel+']');
					var viewer = document.getElementById('marco');	}
				
			else
				var viewer = document.getElementById('marco'); // the div
				viewer.innerHTML = text;	
		}  else if(IE) {
			
//			si es provinvia
			if (id==-1){
//				alert("aqui esta el nivel: "+text+'  meter:  cate1['+nivel+']');
				document.all['marco'].innerHTML = text;}
			else{
			//alert(text);
			//	alert ("ponisndo un cantonnnnn: "+ text);
				document.all['marco'].innerHTML = text;

			}
//          si es canton		
		}
	}


	function sndReqCat_rec(categoria, nivel) {
		
		var thediv = document.getElementById('cate_'+nivel); // the div
		if(categoria == 0){
			thediv.innerHTML = '';
			return false;
		}
		
		nivel++;
		
		// switch UL with a loading div
		thediv.innerHTML = '<span class="loading"><strong>Cargando...</strong><img src="working.gif" /></span>';
		
		makeRequest_rec('ajax.php?c='+categoria+'&n='+nivel);
	}

   function makeRequest_rec(url) {
      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/html');
         }
      } 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('No se pudo crear la instancia XMLHTTP');
         return false;
      }
      http_request.onreadystatechange = alertContents_rec;
      http_request.open('GET', url, true);
      http_request.send(null);
   }


   function alertContents_rec() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
			
            result = http_request.responseText;
			
			var update = new Array();			
			if(result.indexOf('|') != -1) {
				update = result.split('|');
				changeTextCat_rec(update[0], update[1],update[2]);
			}       
         } else {
            alert('Hubo un problema en ejecutar la petición.');
         }
      }
   }
	
	function changeTextCat_rec(div2show, text,nivel) {
		n=nivel-1;
	
		// Detect Browser
		id = parseInt(div2show);
		var IE = (document.all) ? 1 : 0;
		var DOM = 0; 
		if (parseInt(navigator.appVersion) >=5) {DOM=1};
	
		// Grab the content from the requested "div" and show it in the "container"
		if (DOM) {
			var viewer = document.getElementById('cate_'+n);
			viewer.innerHTML = text;		
		}  else if(IE) {
			document.all['cate_'+n].innerHTML = text;
		}
	}
	
	
	
	
	
	
	
