// JavaScript Document

function js_Ventana(www,ancho,alto,titulo,target)
{
	var destino=www+'#'+target;
	var ventana=window.open(destino,titulo,'status=no,scrollbars=no, resizable=yes,width='+ancho+',height='+alto);
	ventana.opener.top.name="opener";
	ventana.focus();
}

function js_calendario(texto)
	{
	//alert(texto);
	document.all.eventos.innerHTML=texto;
	//document.all.hoy.innerText=fecha;
 	document.all.calenda.style.visibility = "visible";
	}

function js_calendario_off()
	{
	document.all.eventos.innerText="";
	//document.all.hoy.innerText="";
	document.all.calenda.style.visibility = "hidden";
	}

function sumaClick(id){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'cuentaclicks/sumaClick.php?id_banner='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + id , true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}
function contador(id){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'contador.php?id='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + id, true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
            var content = xmlhttp.responseText; //The content data which has been retrieved
            if ( content == 'n' ){
            }
            else{
            	array_partes = content.split('#|#');
            	document.getElementById('ventanaTitulo').innerHTML = array_partes[1]+'<br><b>'+array_partes[0]+'</b>';
            	document.getElementById('ventanaVideo').innerHTML = array_partes[2];
            }
        }
      }
    xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

		function cambiar_tamano(tamano){
			if (document.getElementById("ppalnoticias")){
				document.getElementById("ppalnoticias").style.fontSize=tamano;
				document.getElementById("ppalnoticias").style.lineHeight="1.5";
			}
        				if (document.getElementById("cuerpo_texto")){
        					document.getElementById("cuerpo_texto").style.fontSize=tamano;
        					document.getElementById("cuerpo_texto").style.lineHeight="1.5";
        				}
			if (document.getElementById("cuerpo_descripcion")){
				document.getElementById("cuerpo_descripcion").style.fontSize=tamano;
				document.getElementById("cuerpo_descripcion").style.lineHeight="1.5";
			}
			var elemento=document.getElementsByTagName('font');
			var n=0;
			while(elemento[n]){
			  if(elemento[n].className=="estilo_texto" ) {elemento[n].style.fontSize=tamano;elemento[n].style.lineHeight="1.5";}
			  n++;
			}
			var elemento=document.getElementsByTagName('span');
			var n=0;
			while(elemento[n]){
			  if(elemento[n].className=="estilo_texto" ) {elemento[n].style.fontSize=tamano;elemento[n].style.lineHeight="1.5";}
			  n++;
			}
		}
		function reset_tamano(){
			if (document.getElementById("ppalnoticias")){
				document.getElementById("ppalnoticias").style.fontSize=tamano_original;
				document.getElementById("ppalnoticias").style.lineHeight=espaciado_original;
			}
        				if (document.getElementById("cuerpo_texto")){
        					document.getElementById("cuerpo_texto").style.fontSize=tamano_original;
        					document.getElementById("cuerpo_texto").style.lineHeight=espaciado_original;
        				}
			if (document.getElementById("cuerpo_descripcion")){
				document.getElementById("cuerpo_descripcion").style.fontSize=tamano_original_desc;
				document.getElementById("cuerpo_descripcion").style.lineHeight=espaciado_original_desc;
			}
			var elemento=document.getElementsByTagName('font');
			var n=0;
			while(elemento[n]){
			  if(elemento[n].className=="estilo_texto" ) {elemento[n].style.fontSize=tamano_original;elemento[n].style.lineHeight=espaciado_original;}
			  n++;
			}
			var elemento=document.getElementsByTagName('span');
			var n=0;
			while(elemento[n]){
			  if(elemento[n].className=="estilo_texto" ) {elemento[n].style.fontSize=tamano_original;elemento[n].style.lineHeight=espaciado_original;}
			  n++;
			}
		}

function vote(id,puntos){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'votar.php?id='; //This is the path to the file we just finished making
        var puntua = '&puntuacion='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + id + puntua + puntos, true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved
                if ( content == 'x' ){
                      document.getElementById('graciasvotos').innerHTML = "&nbsp;&nbsp;Su voto fue recogido con anterioridad"; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                      arrcontent = content.split('#', 3); //Get rid of the y infront of our result *
                      document.getElementById('resultvotos').innerHTML = arrcontent[0]; //Set the inner HTML of the div with the old value in it to the new value **
                      document.getElementById('cuantosvotos').innerHTML = arrcontent[1]; //Set the inner HTML of the div with the old value in it to the new value **
                      document.getElementById('graciasvotos').innerHTML = arrcontent[2]; //Set the inner HTML of the div with the old value in it to the new value **
                }
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function comp_enter(e){
	if(window.event) // IE
	  {
	  keycode = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keycode = e.which;
	  }	
	//alert(keycode);
	// pulsamos el enter
	if(keycode == 13)
	{
	  document.getElementById('enviar_pregunt').focus();
	}
}

function validar_formu(){
	seguir=1;
	if(document.getElementById('message').value == ''){
		seguir=0;
		alert('Debe escribir una pregunta');
	}
	else if(document.getElementById('author_name2').value == ''){
		seguir=0;
		alert('Debe escribir un nombre o alias');
	}
	else if(document.getElementById('author_email').value == ''){
		seguir=0;
		alert('Debe escribir un email');
	}
	if(seguir == 1){	
		return(true);
	}
	else{
		return(false);
	}
}

function enviopregunta(id,pregunta,alias,email){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'noticias/comentar.php?id_p='; //This is the path to the file we just finished making
        var puntua = '&pregunta_p='; //This is the path to the file we just finished making
        var sujeto = '&nombre_p='; //This is the path to the file we just finished making
        var direcc = '&direcc_p='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + id + puntua + escape(pregunta) + sujeto + escape(alias) + direcc + email , true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved
                /*if ( content == 'x' ){
                      document.getElementById('formulario_div').innerHTML = "Sólo se permite un comentario cada hora."; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if ( content == 'y' ){
                      document.getElementById('formulario_div').innerHTML = "No se permiten comentarios anónimos."; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if ( content == 'z' ){
                      document.getElementById('formulario_div').innerHTML = "Código de confirmación incorrecto.<br><a class='btn_navega' href='javascript:document.location.reload();'>Volver a intentar</a>"; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                			document.location = "#comentarios";
                      document.location.reload(); //Set the inner HTML of the div with the old value in it to the new value **
                }*/
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function solicitud_informacion()
{
	var enviar=1;
	if (document.inform.mi_nombre.value=="" && enviar){
		alert("Escriba su nombre");
		enviar=0;
	}
	if (document.inform.mi_email.value=="" && enviar){
		alert("Escriba su email");
		enviar=0;
	}
	if (enviar)
		document.inform.submit();
}
function mercado(cat){
	if (document.getElementById('historico'))	
		anuncios(0,1,cat)
		
	var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
         xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
               document.getElementById('categorias').innerHTML  = xmlhttp.responseText; //The content data which has been retrieved
            }
        	}        
       xmlhttp.open('GET', "noticias/mercado.php?seccion="+seccion+"&categoria="+cat+"&tipo=categorias" , true); //Open the file through GET, and add the id we want to retrieve as a GET variable
   		 xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
}
function anuncios(pagina,scrol,cat){
	var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
         xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
              var content = xmlhttp.responseText; //The content data which has been retrieved
              arrcontent = content.split('###', 2); //Get rid of the y infront of our result *
              if (arrcontent[1]==0){
              	location.assign('mercado.php');
              }
              else{
              	document.getElementById('historico').innerHTML= arrcontent[0]; //The content data which has been retrieved
              	if (scrol){window.scrollTo(0,0);}
              }
            }
        	}        
       xmlhttp.open('GET', "noticias/mercado.php?seccion="+seccion+"&pagina="+pagina+"&categoria="+cat+"&tipo=historial" , true); //Open the file through GET, and add the id we want to retrieve as a GET variable
   		 xmlhttp.send(null) //Nullify the XMLHttpRequest
		return;
}

function quitarpregunta(id){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'noticias/descomentar.php?id_p='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + id , true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved
                /*if ( content == 'x' ){
                      document.getElementById('formulario_div').innerHTML = "Sólo se permite un comentario cada hora."; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if ( content == 'y' ){
                      document.getElementById('formulario_div').innerHTML = "No se permiten comentarios anónimos."; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if ( content == 'z' ){
                      document.getElementById('formulario_div').innerHTML = "Código de confirmación incorrecto.<br><a class='btn_navega' href='javascript:document.location.reload();'>Volver a intentar</a>"; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                			document.location = "#comentarios";
                      document.location.reload(); //Set the inner HTML of the div with the old value in it to the new value **
                }*/
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function envia_app(){
var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
        var file = 'noticias/enviaapp.php?id_p='; //This is the path to the file we just finished making
        var email = document.getElementById("emailapp").value;
    xmlhttp.open('GET', file + escape(email) , true); //Open the file through GET, and add the id we want to retrieve as a GET variable
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4) { //Check if it is ready to recieve data
                var content = xmlhttp.responseText; //The content data which has been retrieved
                if ( content == 'x' ){
                	alert("Su email no es valido");
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                  document.getElementById('enviodeapp').innerHTML = "<b>Se ha enviado un correo a "+email+" con el enlace a la aplicación.</b>"; //Set the inner HTML of the div with the old value in it to the new value **                	
                }
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

