$(document).ready(function(){
   var x;
   var y;
   var m;
   var n;
   var conexion;
   
   x=$("#zonaContenido a.linkEnlaceNota");
   
   if(x){
	   x.each(function(index) {
				 
			var nombre="#noticia"+(index+1);
			var noticia_web="#noticia_web"+(index+1);
			var pagina_web="#pagina_web"+(index+1);
			//alert(nombre);
			var valor=$(nombre).val();
			var valor_web=$(noticia_web).val();
			var valor_pagina_web=$(pagina_web).val();
			
			y=$(this);
			y.click(function(evento){
					evento.preventDefault();

					if(valor_web==1)
					{
						window.location.href=valor_pagina_web;
					}	
					//inicioEnvio();
					/*
					$.ajax({
					   async:true,
					   type: "POST",
					   dataType: "html",
					   contentType: "application/x-www-form-urlencoded",
					   url:"Usuario/ContenidoDetallePrensa.php",
					   data:"numero="+valor,
					   beforeSend:inicioEnvio,
					   success:llegadaDatos,
					   timeout:4000,
					   error:problemas
					}); */
					
					
					conexion = new crearXMLHttpRequest(); 
					conexion.open('POST', 'Usuario/ContenidoDetallePrensa.php', true);
					conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					conexion.send("numero="+valor);
					
					conexion.onreadystatechange = function(){
						
					 var zonaContenido =$("#zonaContenido");
					 //var zonaGrupo = document.getElementById("zonaGrupo");
					  
					  if(conexion.readyState == 4){

						zonaContenido.html(conexion.responseText);
				
						//alert(detalles);
					  } 
					  else{
						inicioEnvio();
					  }
					  
					}
					
				
				//$.post("Usuario/ContenidoDetallePrensa.php",{numero:valor},llegadaDatos); 
				//$("#zonaContenido").load("Usuario/ContenidoDetallePrensa.php");
				});
		});
   }
   
   
   m=$("#zonaContenido a.linkEnlaceEvento");
   
   if(m){
	   m.each(function(index) {
				 
			var nombre="#evento"+(index+1);
			//alert(nombre);
			var valor=$(nombre).val();
			
			n=$(this);
			n.click(function(evento){
					evento.preventDefault();
			  		inicioEnvio();
					/*$.ajax({
					   async:true,
					   type: "POST",
					   dataType: "html",
					   contentType: "application/x-www-form-urlencoded",
					   url:"Usuario/ContenidoDetalleEvento.php",
					   data:"numero="+valor,
					   beforeSend:inicioEnvio,
					   success:llegadaDatos,
					   timeout:4000,
					   error:problemas
					}); */
				
					conexion = new crearXMLHttpRequest(); 
					conexion.open('POST', 'Usuario/ContenidoDetalleEvento.php', true);
					conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					conexion.send("numero="+valor);
					
					conexion.onreadystatechange = function(){
						
						 var zonaContenido =$("#zonaContenido");
						 //var zonaGrupo = document.getElementById("zonaGrupo");
						  
						  if(conexion.readyState == 4){
	
							zonaContenido.html(conexion.responseText);
					
							//alert(detalles);
						  } 
						  else{
							inicioEnvio();
						  }
					}
					
				});
		});
   }
   
   
    function inicioEnvio(){
	  var x=$("#zonaContenido");
	  
	  x.html('<img src="img/load.gif">');
	}
	
	function llegadaDatos(datos){
	  $("#zonaContenido").html(datos);
	}
	
	function problemas(){
	  $("#zonaContenido").text('Problemas en el servidor.');
	}
	
	function crearXMLHttpRequest() {
	  var xmlHttp=null;
	  if (window.ActiveXObject) 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  else 
		if (window.XMLHttpRequest) 
		  xmlHttp = new XMLHttpRequest();
	  return xmlHttp;
	}

})



