var itemGaleria = 1;

function apagaMenu(){
    
    var tiempoEspera = 4500;
    tiempoMenu = setTimeout("menuOff()",tiempoEspera);

}
function menuOff(){
    
    obj = document.getElementById('menuSegurosParaTi');
    obj.style.visibility = 'hidden';

    obj = document.getElementById('menuBlogs');
    obj.style.visibility = 'hidden';

    obj = document.getElementById('menuTeInteresa');
    obj.style.visibility = 'hidden';
    
    clearTimeout(tiempoMenu);  
}

function cargaMetadatos (titulo, descripcion, enlaceExterno, blank) {
    obj = document.getElementById('textoGaleria');
    if (blank==1) {
      obj.innerHTML ='<span class="titPlayer"><a href="'+enlaceExterno+'" target="_blank">'+titulo+'</a></h1>';  
    } else {
      obj.innerHTML ='<span class="titPlayer"><a href="'+enlaceExterno+'">'+titulo+'</a></h1>';     
    }
    
    obj.innerHTML += '<span class="descPlayer">'+descripcion+'</h2>';
    
    return;
}

function cargaImagenGaleria (id) {
    
    objBanner = document.getElementById('bannerGaleriaCarrusel');
    objBanner.style.display = 'none';
    
    objDestino = document.getElementById('imagenGaleriaCarrusel');
    objDestino.innerHTML = '<img src="/wp-content/themes/gyoung2/phpthumb/phpThumb.php?src='+id+'&w=950&h=266&q=75">';
    objDestino.style.display = "block";
    
    return;
        
}

function cargaBannerGaleria() {
    
    objDestino = document.getElementById('imagenGaleriaCarrusel');
    objDestino.style.display = 'none';
    
    objBanner = document.getElementById('bannerGaleriaCarrusel');
    objBanner.style.display = 'block';
   
   
   return;
}



function ocultaMenu(id) {
     var obj = document.getElementById(id);     
     obj.style.visibility = 'hidden';
     return;
}

function muestraMenu(id) {
     var obj = document.getElementById(id);     
     obj.style.visibility = 'visible';
     return;
}

function cargarPlayer(nombreCapa, nombreVideo, url){
    
    jwplayer(nombreCapa).setup({
        autostart: false,
        flashplayer: url+"/swf/player.swf",
        file: nombreVideo,
        width: 329, 
        height: 200,
        plugins: {
            sharing: { link: true }
        },
        skin: url+"/swf/glow/glow.zip",
        controlbar:"bottom"
    });
    
}

function cargaVideo(video) {
    
    obj = document.getElementById('visorPlayer');
    obj.innerHTML = '<iframe title="YouTube video player" width="319" height="198" src="http://www.youtube.com/embed/'+video+'" frameborder="0" allowfullscreen></iframe>';
    
}

function validarFormulario(dataform) {
    
    if (dataform.nombre.value=='') {
        alert('El campo Nombre es obligatorio, debe rellenarlo.');
        return;
    }
    
    if (dataform.apellidos.value=='') {
        alert('El campo Apellidos es obligatorio, debe rellenarlo.');
        return;
    }
    if (dataform.email.value=='') {
        alert('El campo email es obligatorio, debe rellenarlo.');
        return;
    }
    if (dataform.comentarios.value=='') {
        alert('El campo comentarios es obligatorio, debe rellenarlo.');
        return;
    }
    
    dataform.submit();
    
}

function ocultapage() {
   obj = document.getElementById('content');
   obj.style.visibility="hidden";
}
function muestrapage() {
   obj = document.getElementById('content');
   obj.style.visibility="visible";
}

function ocultapage2() {
   obj = document.getElementById('contentSpecial');
   obj.style.visibility="hidden";
}
function muestrapage2() {
   obj = document.getElementById('contentSpecial');
   obj.style.visibility="visible";
}


function sendRegistro(email) {
    re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(email))    {
        alert('Debe introducir una dirección de correo valida');
        return false;
    }else{
        window.open('http://www.premiosgyoung.com/?mail='+email,'_blank');
        return true;
    }    
    
}

function moverSlide(tiempo) {
    
}

function sendForm(texto) {
    window.open('/?s='+texto, '_self');
    return;
}

function timeMsg() {
    
    var obj = document.getElementById('item'+itemGaleria);
    str = obj.rel;
   
    itemGaleria = itemGaleria + 1;
    if (itemGaleria > 4) {itemGaleria=1;}
    
    var t = setTimeout(str + ";timeMsg()", 7000);
    
        
    return;
    
}

    function _utf8_encode(string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
 
        for (var n = 0; n < string.length; n++) {
 
            var c = string.charCodeAt(n);
 
            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
 
        }
 
        return utftext;
    }
 
    // private method for UTF-8 decoding
    function _utf8_decode(utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
 
        while ( i < utftext.length ) {
 
            c = utftext.charCodeAt(i);
 
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
 
        }
 
        return string;
    }
