
image1 = new Image();
image1.src = "http://www.publicidad.net/img/comun/m_anun_cast_off.png";
image2 = new Image();
image2.src = "http://www.publicidad.net/img/comun/m_edi_cast_off.png";
image3 = new Image();
image3.src = "http://www.publicidad.net/img/comun/m_qs_cast_off.png";
image4 = new Image();
image4.src = "http://www.publicidad.net/img/comun/m_blog_cast_off.png";
image5 = new Image();
image5.src = "http://www.publicidad.net/img/comun/m_rs_cast_off.png";
image6 = new Image();
image6.src = "http://www.publicidad.net/img/comun/m_cont_cast_off.png";                                              
image7 = new Image();
image7.src = "http://www.publicidad.net/img/comun/m_anun_cast_over.png";
image8 = new Image();
image8.src = "http://www.publicidad.net/img/comun/m_edi_cast_over.png";
image9 = new Image();
image9.src = "http://www.publicidad.net/img/comun/m_qs_cast_over.png";
image10 = new Image();
image10.src = "http://www.publicidad.net/img/comun/m_blog_cast_over.png";
image11 = new Image();
image11.src = "http://www.publicidad.net/img/comun/m_rs_cast_over.png";
image12 = new Image();
image12.src = "http://www.publicidad.net/img/comun/m_cont_cast_over.png";

image21 = new Image();
image21.src = "http://www.publicidad.net/img/comun/m_anun_cast_offEN.png";
image22 = new Image();
image22.src = "http://www.publicidad.net/img/comun/m_edi_cast_offEN.png";
image23 = new Image();
image23.src = "http://www.publicidad.net/img/comun/m_qs_cast_offEN.png";
image24 = new Image();
image24.src = "http://www.publicidad.net/img/comun/m_blog_cast_offEN.png";
image25 = new Image();
image25.src = "http://www.publicidad.net/img/comun/m_rs_cast_offEN.png";
image26 = new Image();
image26.src = "http://www.publicidad.net/img/comun/m_cont_cast_offEN.png";                                              
image27 = new Image();
image27.src = "http://www.publicidad.net/img/comun/m_anun_cast_overEN.png";
image28 = new Image();
image28.src = "http://www.publicidad.net/img/comun/m_edi_cast_overEN.png";
image29 = new Image();
image29.src = "http://www.publicidad.net/img/comun/m_qs_cast_overEN.png";
image210 = new Image();
image210.src = "http://www.publicidad.net/img/comun/m_blog_cast_overEN.png";
image211 = new Image();
image211.src = "http://www.publicidad.net/img/comun/m_rs_cast_overEN.png";
image212 = new Image();
image212.src = "http://www.publicidad.net/img/comun/m_cont_cast_overEN.png";                                                 


function image_menu_on(imagen,num,idi){ 
    //alert(idi);
    if(idi!="EN"){
        var idi="";
    }
    if(num==1){
        imagen.src='http://www.publicidad.net/img/comun/m_anun_cast_over'+idi+'.png';
    }
    if(num==2){
        imagen.src='http://www.publicidad.net/img/comun/m_edi_cast_over'+idi+'.png'; 
    }
    if(num==3){
        imagen.src='http://www.publicidad.net/img/comun/m_qs_cast_over'+idi+'.png'; 
    }
    if(num==4){
        imagen.src='http://www.publicidad.net/img/comun/m_blog_cast_over'+idi+'.png'; 
    }
    if(num==5){
        imagen.src='http://www.publicidad.net/img/comun/m_rs_cast_over'+idi+'.png'; 
    }
    if(num==6){
        imagen.src='http://www.publicidad.net/img/comun/m_cont_cast_over'+idi+'.png'; 
    } 
    //alert(imagen.src);
}

function image_menu_out(imagen,num,idi){
    //alert(idi);
    if(idi!="EN"){
        var idi="";
    }
    if(num==1){
        imagen.src='http://www.publicidad.net/img/comun/m_anun_cast_off'+idi+'.png';
    }
    if(num==2){
        imagen.src='http://www.publicidad.net/img/comun/m_edi_cast_off'+idi+'.png'; 
    }
    if(num==3){
        imagen.src='http://www.publicidad.net/img/comun/m_qs_cast_off'+idi+'.png'; 
    }
    if(num==4){
        imagen.src='http://www.publicidad.net/img/comun/m_blog_cast_off'+idi+'.png'; 
    }
    if(num==5){
        imagen.src='http://www.publicidad.net/img/comun/m_rs_cast_off'+idi+'.png'; 
    }
    if(num==6){
        imagen.src='http://www.publicidad.net/img/comun/m_cont_cast_off'+idi+'.png'; 
    }
    //alert(imagen.src);
}

var ie=(document.all) ? 1:0;
var n4=(document.layers) ? 1:0;
var n6=(document.getElementById) ? 1:0;  


function setHttpRequest(){
   var http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
    }
   } else if (window.ActiveXObject) { // IE
    try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
           try {
              http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {
           }
    }
   }
   return http_request;
}

function makePOSTRequest(url, parameters) {
    http_request = setHttpRequest();
    if (!http_request) {
        alert('Cannot create XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('POST', url+"?"+parameters, true);
    http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http_request.setRequestHeader("Content-length", parameters.length);
    http_request.setRequestHeader("Connection", "close");
    
    http_request.send(parameters);
}

function validarEmail(valor) {
     if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){
         return true;
     }else{
         return false;
     }
}

function alertContents(){
  if (http_request.readyState == 4) {
     if (http_request.status == 200) {
        result = http_request.responseText;
        if(ie){    
            document.all['spanMsg'].innerHTML=result;
        }else{
            if(n4){
                document.layers['spanMsg'].innerHTML=result;
            }else{
                if(n6){      
                    document.getElementById('spanMsg').innerHTML=result;
                }
            }
        }
     } else {
        //alert('No se ha podido enviar el correo.');
     }
  }
}

function valFormContactAnu(frm){
    var error=false;
    var msg="";
    
    if (frm.nombre.value==""){
        document.getElementById("nombreImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("nombreImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (frm.empresa.value==""){
        document.getElementById("empresaImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("empresaImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    /*var telefono = /^9[0-9]{8}$/;
    var movil = /^6[0-9]{8}$/;
    if(!telefono.test(frm.telf.value) && !movil.test(frm.telf.value)) {
        document.getElementById("telfImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
    } else {
        document.getElementById("telfImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    } */    
    
    if (!validarEmail(frm.email.value)){
        document.getElementById("emailImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("emailImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (frm.comentario.value==""){
        document.getElementById("comentarioImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("comentarioImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (frm.conocer.value==""){
        document.getElementById("conocerImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("conocerImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (frm.acepto.checked==""){ 
        document.getElementById("aceptoImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{ 
        document.getElementById("aceptoImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (error){
        document.getElementById("spanMsg").innerHTML="Se han producido errores, revise el formulario.";
        //"los siguientes errores: <br>"+msg
        return false;  
    } 
    
    var poststr = "conocer="+frm.conocer.value+"&nombre="+frm.nombre.value+"&email="+frm.email.value+"&empresa="+frm.empresa.value+"&telefono="+frm.telf.value+"&comentario="+frm.comentario.value+"&formulario=anunciantes";
    makePOSTRequest("/ajx/cont-0001.ajax.php", poststr);
    return false;
}

function bordeon(frm){
    frm.style.border = "2px solid #2D9BD0";    
    return true;
}

function bordeoff(frm){
    frm.style.border = "2px solid #FFFFFF";
    return true;
}

function valFormContact(inp,nombre){
    if (inp.value==""){
        document.getElementById(nombre).src="http://www.publicidad.net/img/comun/ico_alert.png";
    }else{
        document.getElementById(nombre).src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    return true;
}

function valFormContactSel(inp,nombre){
    if (inp.value=="-1"){
        document.getElementById(nombre).src="http://www.publicidad.net/img/comun/ico_alert.png";
    }else{
        document.getElementById(nombre).src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    return true;
}


function valFormContactTELF(inp,nombre){
    /*if (inp.value!=""){
        var telefono = /^9[0-9]{8}$/;
        var movil = /^6[0-9]{8}$/;
        if(!telefono.test(inp.value) && !movil.test(inp.value)) {
            document.getElementById("telfImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        } else {*/
            document.getElementById("telfImg").src="http://www.publicidad.net/img/comun/ico_check.png";
       /* }
    } else {
        document.getElementById("telfImg").src="http://www.publicidad.net/img/trans.gif"; 
    }*/
    return true;
}

/*var infoActual=0;
var totalInfo = 0;
function muestra_oculta_InfoSite(id){
    for(var x=0;x<InfoSitesCreados;x++){
        document.getElementById("Info"+x).style.display='none';
        document.getElementById("InfoMini"+x).style.display='';
    }
    document.getElementById("Info"+id).style.display='';
    document.getElementById("InfoMini"+id).style.display='none';
    infoActual = id;
    
}
var  = 0;
function addInfoSite(){
    if(document.getElementById('url'+infoActual).value==""){
        alert("Tienes que informar la URL");
        return false;
    }  
    document.getElementById('TitMini'+InfoSitesCreados).innerHTML=document.getElementById('url'+InfoSitesCreados).value;
    InfoSitesCreados++;
    if(InfoSitesCreados==(totalInfo)){
        document.getElementById("Info"+(InfoSitesCreados-1)).style.display='none';
        document.getElementById("InfoMini"+(InfoSitesCreados-1)).style.display='';
        document.getElementById('addSite').style.display="none";
    }else{
        muestra_oculta_InfoSite(InfoSitesCreados);    
    }
    infoActual=InfoSitesCreados;
}*/

var infoSites = new Array();
var infoActual=0;
var InfoSitesCreados=0;
var mod = "";
function eliminaInfoSite(id){
    infoSites.splice(id,1);
    refreshInfos();
}
function modificaInfoSite(id){
    document.getElementById("url").value=infoSites[id][0];
    document.getElementById("usuGlob").value=infoSites[id][1];
    document.getElementById("pagGlob").value=infoSites[id][2];
    document.getElementById("usuIp").value=infoSites[id][3];
    document.getElementById("pagIp").value=infoSites[id][4];
    document.getElementsByName("usuReg").value=infoSites[id][5];
    document.getElementById("usuNum").value=infoSites[id][6];
    modificando=true; 
    mod = id;  
    refreshInfos();  
}
var modificando=false;
function refreshInfos(){
    var str="";
    if(infoSites.length>0){
        document.getElementById("InfoMini").style.display="";    
    }
    var arr = new Array();
    for(var x=0;x<infoSites.length;x++){
        str+="<div class='div1js'>"+infoSites[x][0]+"</div><div class='div2js'><a href='javascript:void(0);' onclick='modificaInfoSite("+x+")'><img class='imgjs' src='/img/comun/ico_modif.png'/></a></div><div class='div3js'><a href='javascript:void(0);' onclick='eliminaInfoSite("+x+");'><img class='imgjs' src='/img/comun/ico_borrar.png'/></a></div><hr class='lineaforma1anu2'/>";
    }
    document.getElementById("InfoMini").innerHTML = str;
}


function addInfoSite(url){
    if(document.getElementById('url').value==""){
        alert("Tienes que informar la URL");
        document.getElementById('url').focus();
        return false;
    }else{
        
        var info = new Array();
        info[0]=document.getElementById("url").value;
        info[1]=document.getElementById("usuGlob").value;
        info[2]=document.getElementById("pagGlob").value;
        info[3]=document.getElementById("usuIp").value;
        info[4]=document.getElementById("pagIp").value;
        info[5]=document.getElementsByName("usuReg").value;
        info[6]=document.getElementById("usuNum").value;
        if(modificando) {
            modificando = false;
            infoSites[mod]=info;
            mod=0;
        }else{
            infoSites[infoSites.length]=info;
        }
        
        
        document.getElementById("url").value="";
        document.getElementById("urlImg").src="http://www.publicidad.net/img/comun/trans.gif";
        document.getElementById("usuGlob").value="";
        document.getElementById("pagGlob").value="";
        document.getElementById("usuIp").value="";
        document.getElementById("pagIp").value="";
        document.getElementsByName("usuReg").value="";
        document.getElementById("usuNum").value="";
        document.getElementById("comentarioImg").src="http://www.publicidad.net/img/comun/trans.gif";
        
        //document.getElementById("InfoMini").innerHTML = "";
        
        refreshInfos();      
    }
}
/*var infoSite=0;
var infoVisible=0;
function addInfoSite(){
    var infoMiniAntiguo = document.getElementById('InfoMini'+infoVisible);
    var infoAntiguo = document.getElementById('Info'+infoVisible);
    infoMiniAntiguo.style.display='';
    infoAntiguo.style.display='none';
     
    
    
    infoSite++;
    //obtenemos el contenedor en el que vamos a insertar las capas
    var contenedor = document.getElementById('infoSites');
    //creamos div de info DESPLEGADO
    
    var info = document.createElement('div');
    info.id = "Info"+infoSite;
    info.name = "Info"+infoSite;
    
    var titUrl = document.createElement('div');
    titUrl.id = "TitUrl"+infoSite;
    titUrl.name = "TitUrl"+infoSite;
    titUrl.style.color="red";
    titUrl.InnerHTML = "URL del site";
    
    
    
    //Creamos input URL
    ele = document.createElement('input');
    ele.type = 'text';
    ele.name = 'url'+infoSite;
    //contenedor del input url
    var inpUrl = document.createElement('div');
    inpUrl.id = "TitUrl"+infoSite;
    inpUrl.name = "TitUrl"+infoSite;
    inpUrl.style.color="red";
    inpUrl.appendChild(ele);
    
    
    
    //creamos div de info PLEGADO
    var infoMini = document.createElement('div');
    infoMini.id = "InfoMini"+infoSite;
    infoMini.name = "InfoMini"+infoSite;  
    infoMini.style.display="none";
    
    
    
    


    
    infoVisible = infoSite;
    
    
    
}   */

function mostraregistrados(){
    if(document.getElementById("101").style.display==''){
        document.getElementById("101").style.display='none';        
    }else{
        document.getElementById("101").style.display='';
    }
    if(document.getElementById("102").style.display==''){
        document.getElementById("102").style.display='none';
    }else{
        document.getElementById("102").style.display='';
    }
}

function valFormEditores(frm){
    var error=false;
    var msg="";
    
    if (frm.nombre.value==""){
        document.getElementById("nombreImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("nombreImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (frm.pais.value=="-1"){
        document.getElementById("paisImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("paisImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (!validarEmail(frm.email.value)){
        document.getElementById("emailImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }
     
    if(frm.comentario.value==""){
        if(frm.url.value!=""){
            addInfoSite(); 
        } else if (infoSites.length==0){
            document.getElementById("urlImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
            document.getElementById("comentarioImg").src="http://www.publicidad.net/img/comun/ico_alert.png"; 
            error=true;
        }
    }
    
    if (frm.acepto.checked==""){
        frm.acepto.focus();
        document.getElementById("aceptoImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{ 
        document.getElementById("aceptoImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }    
    
    if (error){
        document.getElementById("spanMsg").innerHTML="Se han producido errores, revise el formulario.";
        //"los siguientes errores: <br>"+msg
        return false;  
    } 
    
    var cuantos = infoSites.length;
    var par = "&total="+cuantos;
    for(var x=0;x<cuantos;x++){
        par+="&url"+x+"="+infoSites[x][0];
        par+="&usuGlob"+x+"="+infoSites[x][1];
        par+="&pagGlob"+x+"="+infoSites[x][2];
        par+="&usuIp"+x+"="+infoSites[x][3];
        par+="&pagIp"+x+"="+infoSites[x][4];
        par+="&usuNum"+x+"="+infoSites[x][6];
    }
    var poststr = "formulario=editores&comentario="+frm.comentario.value+"&nombre="+frm.nombre.value+"&email="+frm.email.value+"&pobla="+frm.pobla.value+"&pais="+frm.pais.value+"&telf="+frm.telf.value+"&estadisticas="+frm.estadisticas.value+par;
    makePOSTRequest("/ajx/cont-0001.ajax.php", poststr);
    return false;
}

function valFormContactTra(frm){
    var error=false;
    var msg="";
    
    if (frm.nombre.value==""){
        document.getElementById("nombreImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("nombreImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    /*var telefono = /^9[0-9]{8}$/;
    var movil = /^6[0-9]{8}$/;
    if(!telefono.test(frm.telf.value) && !movil.test(frm.telf.value)) {
        document.getElementById("telfImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
    } else {
        document.getElementById("telfImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    } */
    
    
    if (!validarEmail(frm.email.value)){
        document.getElementById("emailImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("emailImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    /*if(frm.adjunto.value==""){
        document.getElementById("adjuntoImg").src="/img/comun/ico_alert.png";
        error=true;
    }else{
        document.getElementById("adjuntoImg").src="/img/comun/ico_check.png";    
    }*/
    
    if (frm.acepto.checked==""){ 
        document.getElementById("aceptoImg").src="http://www.publicidad.net/img/comun/ico_alert.png";
        error=true;
    }else{ 
        document.getElementById("aceptoImg").src="http://www.publicidad.net/img/comun/ico_check.png";
    }
    
    if (error){
        document.getElementById("spanMsg").innerHTML="Se han producido errores, revise el formulario.";
        //"los siguientes errores: <br>"+msg
        return false;  
    }
    
    var poststr = "formulario=curriculum1&nombre="+frm.nombre.value+"&email="+frm.email.value+"&telefono="+frm.telf.value+"&archivo="+frm.ruta.value;
    makePOSTRequest("/ajx/cont-0001.ajax.php", poststr);
    return false;
}

function ocultarMostrarAnos(ano,divs){
    for(var x=0;x<divs;x++){ 
        document.getElementById(x).style.display='none';
    }
    document.getElementById(ano).style.display='';
}

function compCurri(frm){
    
    alert("entra");
    /*if(frm.adjunto.value==""){
        alert("Debe de seleccionar la ubicación del documento.");
        return false;    
    } else {
        document.getElementById("adj2").innerHTML=frm.adjunto.value;
        var poststr = "curriculum1="+frm.adjunto.value;
        makePOSTRequest("/ajx/cont-0001.ajax.php", poststr);
        return false;   
    }            */
    return false;
}

function capamail(){
    if(document.getElementById("capamail").style.display==''){
        document.getElementById("capamail").style.display='none';   
    } else {
        document.getElementById("capamail").style.display=''; 
    }
}

function compEnvioMail(frm,titulo,contenido){
    var error=false;
    if(frm.nombre.value==""){
        error = true;
    }
    
    if (!validarEmail(frm.mail.value)){
        error = true;
    }
    
    if(!error){
        var poststr = "nombre="+frm.nombre.value+"&mail="+frm.mail.value+"&titulo="+titulo+"&contenido="+contenido;
        document.getElementById("spanMsg1").innerHTML="Envío correcto."
        makePOSTRequest("/responsabilidad-social/", poststr);
        return false;
    } else {
        document.getElementById("spanMsg1").innerHTML="Revise los campos."
    }       
}

function compEnvioMail2(frm,titulo,contenido,imagen){
    var error=false;
    if(frm.nombre.value==""){
        error = true;
    }
    
    if (!validarEmail(frm.mail.value)){
        error = true;
    }
    
    if(!error){
        var poststr = "nombre="+frm.nombre.value+"&mail="+frm.mail.value+"&titulo="+titulo+"&contenido="+contenido+"&imagen="+imagen;
        document.getElementById("spanMsg1").innerHTML="Envío correcto."
        makePOSTRequest("/ajx/envioAmigo.ajax.php", poststr);
        return false;
    } else {
        document.getElementById("spanMsg1").innerHTML="Revise los campos."
    }       
}

function compEnvioMail3(frm,titulo,contenido,fecha){
    var error=false;
    if(frm.nombreremi.value==""){
        error = true;
    }
    
    if(!validarEmail(frm.mailremi.value)){
        error = true;
    }
    
    if(frm.nombre.value==""){
        error = true;
    }
    
    if (!validarEmail(frm.mail.value)){
        error = true;
    }
    
    if(!error){
        var poststr = "nombre="+frm.nombre.value+"&mail="+frm.mail.value+"&nombreremi="+frm.nombreremi.value+"&mailremi="+frm.mailremi.value+"&titulo="+titulo+"&contenido="+contenido+"&fecha="+fecha;
        makePOSTRequest("/ajx/envioNoticia.ajax.php", poststr);
        document.getElementById("spanMsg1").innerHTML="Envío correcto."
        return false;
    } else {
        document.getElementById("spanMsg1").innerHTML="Revise los campos."
    }       
}

function muestra_inicio(){
    if(window.pageYOffset){
        pos = window.pageYOffset;
    }else {
        pos = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    }
    if(document.getElementById("interstt17").style.display=="none"){
        document.getElementById("interstt17").style.display="";    
        document.getElementById("interstt18").style.display="";    
    }else{
        document.getElementById("interstt17").style.display="none";   
        document.getElementById("interstt18").style.display="none";   
    }
    document.getElementById("interstt17").style.top=pos+"px";
    document.getElementById("interstt18").style.top=pos+"px";
    window.onscroll=scrollIt;
}
function scrollIt(ev){
    var pos = "";
    if(window.pageYOffset){
        pos = window.pageYOffset;
    }else {
        pos = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
    }
    if(document.getElementById('interstt17'))
        document.getElementById('interstt17').style.top  = pos + "px";
    if(document.getElementById('interstt18'))
        document.getElementById('interstt18').style.top  = pos + "px";
}
