
function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}



/*
	----funcion que controla el numero de ususarios que se han suscrito al RSS de las
	----noticias.
*/
function contarRss1()
{
	
		
		var ajax=nuevoAjax();		
		ajax.open("POST"," procesos/contar_rssnoticia.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		ajax.send(null);
		
				ajax.onreadystatechange=function()
				{
					
					if (ajax.readyState==4)
					{			
						//alert("Gracias");
					
								
					}
				}
		
	
}

function contarVisitaNoticia()
{//

		
		var ajax=nuevoAjax();	
		var noticia=document.getElementById('noticia2').value;
		ajax.open("GET"," procesos/contarVisitaNoticia.php?noticia="+noticia, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		ajax.send(null);
		
				ajax.onreadystatechange=function()
				{
					
					if (ajax.readyState==4)
					{			
					//document.getElementById('noticia').value=ajax.responseText;
					//alert(ajax.responseText);
					
								
					}
				}
		
	
}

function actualizarNumCompartidos()
{
	
	var noticia=document.getElementById('noticia').value;
	
		
		var ajax=nuevoAjax();	
	
		
		ajax.open("GET"," procesos/contarArticuloCompartido.php?noticia="+noticia, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		ajax.send(null);
		
				ajax.onreadystatechange=function()
				{
					
					
					if (ajax.readyState==4)
					{			
					
				  //	document.getElementById('noticia').value=ajax.responseText;
					
								
					}
				}
		
	
}
function existe_archivo(archivo){//

	 //confirm(archivo);
	
		var ajax=nuevoAjax();	
		ajax.open("GET"," ../../existe_archivo.php?file="+archivo, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		ajax.send(null);
		
				ajax.onreadystatechange=function()
				{					
					if (ajax.readyState==4)
					{
						//confirm(ajax.responseText);
				      if(ajax.responseText=='-1'){
					  //confirm("subiendo");
					  var form=document.getElementById("formulario");
			              form.submit();					  
					  }else if(ajax.responseText=='1'){
					   var sobreescribir=confirm("Ya existe un archivo con el mismo nombre, desea sobreescribirlo?");                      // confirm("Selecciono--->"+sobreescribir);
					   if(sobreescribir){
						    var form=document.getElementById("formulario");
			              form.submit();	
						   
						   }
					   
					   
					   
					   }
					   
					   }
				}
		//alert("Selecciono--->"+bandera);
		
}
function  cargarVistaNoticia(id){
	    var ajax=nuevoAjax();	
		//var noticia=document.getElementById('noticia2').value;
		ajax.open("GET"," procesos/cargar_vista_noticia.php?evento="+id, true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");		
		ajax.send(null);
		
				ajax.onreadystatechange=function()
				{
					
					if (ajax.readyState==4)
					{			
					 var i=0,array=ajax.responseText.split("**");
					  if(array[0]==1){
						  
						  
						//franja(area);		
						   document.getElementById("fecha").innerHTML=array[1];
						   document.getElementById("hora").innerHTML=array[2];					   
						   document.getElementById("foto").innerHTML="<img src='cms/noticias/"+array[3]+"'/>";
						   document.getElementById("nombre_hora").innerHTML="Hora:&nbsp;";	
						   document.getElementById("nombre_fecha").innerHTML="Fecha:&nbsp;";
						  }
					 
					 
					 
					 
					//alert(ajax.responseText);
					
								
					}
				}
		
	
}

