// 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 = '<b>'+array_partes[0]+'</b>';
            	document.getElementById('ventanaVideo').innerHTML = array_partes[1];
            }
        }
      }
    xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function pcontador(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 = 'pcontador.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 = '<b>'+array_partes[0]+'</b>';
            	document.getElementById('ventanaVideo').innerHTML = array_partes[1];
            }
        }
      }
    xmlhttp.send(null) //Nullify the XMLHttpRequest
return;
}

function cambiar_tamano(tamano){
	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("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 = "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('#', 2); //Get rid of the y infront of our result *
                      document.getElementById('resultvotos').innerHTML = content; //Set the inner HTML of the div with the old value in it to the new value **
                      document.getElementById('graciasvotos').innerHTML = "Gracias por votar"; //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('preguntax').value == ''){
		seguir=0;
		alert('Debe escribir una pregunta');
	}
	else if(document.getElementById('nombrex').value == ''){
		seguir=0;
		alert('Debe escribir un nombre o alias');
	}
	if(seguir == 1){	
		return(true);
	}
	else{
		return(false);
	}
}

function enviopregunta(id,pregunta,alias,capt){
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 captch = '&capt_p='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + id + puntua + pregunta + sujeto + alias + captch + capt, 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 cargar_imagen(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/cargarimagen.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 == 'x' ){
                      document.getElementById('graciasvotos').innerHTML = "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('#', 2); //Get rid of the y infront of our result *
                      document.getElementById('cont_imagen').innerHTML = content; //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 carga_enmsj(idmsj){
	prefijopos = 'enmsj_';
	document.getElementById(prefijopos+idmsj).innerHTML = "<textarea class='custom_txtarea' id='txta_"+idmsj+"'></textarea>&nbsp;<a href='javascript:void(0);' onclick='enviar_msj("+idmsj+")'>Enviar</a>";
	document.getElementById(prefijopos+idmsj).style.display = "block";
	var elemento=document.getElementsByTagName('div');
	var n=0;
	while(elemento[n]){
	  if( eval('elemento[n].id.substr(0,prefijopos.length)==prefijopos') ) {
	  	if(elemento[n].id!=prefijopos+idmsj){
	  		elemento[n].innerHTML='';
	  		elemento[n].style.display='none';
	  	}
	  }
	  n++;
	}
}

function enviar_msj(idmsj){
	prefijopos = 'enmsj_';
	prefijotxt = 'txta_';
	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 = 'networking/enviarmsj.php?id='; //This is the path to the file we just finished making
        var puntua = '&msj='; //This is the path to the file we just finished making
        var elmsj  = document.getElementById(prefijotxt+idmsj).value; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + idmsj + puntua + elmsj, 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' ){
									document.getElementById(prefijopos+idmsj).innerHTML = "No ha sido posible enviar el mensaje.";
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                      //arrcontent = content.split('#', 2); //Get rid of the y infront of our result *
                      document.getElementById(prefijopos+idmsj).innerHTML = content; //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 aprobar_c(idmsj){
	if(confirm("¿Esta seguro de mostrar su email al usuario?")){
		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 = 'networking/aprobar_c.php?id='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + idmsj , 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' ){
									document.getElementById("cmp_aprob").innerHTML = "No ha sido posible aprobar el contacto.";
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                      //arrcontent = content.split('#', 2); //Get rid of the y infront of our result *
                      document.getElementById("cmp_aprob").innerHTML = content; //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 seleccionarTipo(tipoPerfil){
	prefijopos = 'enmsj_';
	prefijotxt = 'txta_';
	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 = 'networking/seleccionaPerfil.php?id='; //This is the path to the file we just finished making
    xmlhttp.open('GET', file + tipoPerfil , 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' ){
									document.getElementById("selectorP").innerHTML = "No ha sido posible cargar el perfil.";
                }
                else if( content != 'n' ){ //If the response was not "n" (meaning it worked)
                      //arrcontent = content.split('#', 2); //Get rid of the y infront of our result *
                      document.getElementById("selectorP").innerHTML = content; //Set the inner HTML of the div with the old value in it to the new value **
                }
        }
        }
        xmlhttp.send(null) //Nullify the XMLHttpRequest
	return;
	
}