function nuevoAjax(){ 
 abrir_carga("Cargando...")  
	var xmlhttp=false; 
        
		try { 
             
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
            
			} catch (e) { 
            
			try { 
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
            
			} catch (E) { 
              
			   xmlhttp = false; 
           } 
		   
        } 

         if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
			  xmlhttp = new XMLHttpRequest(); 
		 } 
		 
        return xmlhttp; 
         
} 

function petision(pag, enDiv, metodo, parametros, tipo, id, subirScroll){
	
	var ajax = new nuevoAjax();
	
	ultimo_ajax = ajax;

	ajax.open(metodo, pag + "?nocahe=" + Math.random(), true);
	
	ajax.onreadystatechange = function() {


	if (ajax.readyState == 3){ 
			abrir_carga()
		}

		if (ajax.readyState == 4){ 

			if (ajax.status == 200){ 
				
				if(subirScroll!=1){
				window.scroll(0,1)
				window.scroll(0,0)
				}
				
				xmlDoc = ajax.responseText;
	

if(document.getElementById(enDiv)!=null){
				document.getElementById(enDiv).innerHTML = xmlDoc;
}
	
		
				if(pag == "registro_form.php"){

						Registro.add_pueblos()
				
				}
		
					if(pag!="noticias.php" && pag!="recursos.php"){
	
						add_history()
	
						
						
					}else if(pag=="noticias.php"){
	
							if(parametros==null){
								
								add_history()
							}
							
						}else if(pag=="recursos.php"){
							
							if(parametros==null){
								add_history();
							}
					

					}


					if(pag == "condicion.php" || pag == "noticia.php" || pag == "terminos.php" || pag == "politica.php"){
					
						cambiarTamanioTexto(tamanio)
					
					}

					if(pag == "noticias.php"){
					
						if(tipo == "grupo"){
					
							cambiarCombo_noticia(id)
							
						}
						
						if(tipo == "condicion"){
						
							goNoticiasCondicion('', id)
							
						}
						
						
					
					}
					
		
					
					
					cerrar_carga();		
								
			
					


			 }else{
				return;
			 }
		
		}else{
		 	return;
		}
		

	}

	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	//ajax.setRequestHeader("Content-Type", "text/xml; charset=ISO-8859-1");
	ajax.send(parametros);

}
function detener_ajax(){
	ultimo_ajax.abort()
}
function abrir_carga(mensaje){
	//document.getElementById("txt_mensaje_carga").innerHTML = mensaje;
	//document.getElementById("cargando").style.display = "block";
	document.getElementById("cargando").style.display = "block";
	return
}
function cerrar_carga(){
//	document.getElementById("cargando").style.display = "none";
	document.getElementById("cargando").style.display = "none";
	return
}


