// cambio de pestanas

function mostrarOcultar(capa, capa2){
document.getElementById(capa).style.display =""
document.getElementById(capa2).style.display ="none"
}

// mostrar / ocultar capas comparador

function mostrarOcultarComp(col) {
 document.getElementById('rivales1').style.display ="none";
 //document.getElementById('rivales2').style.display ="none";
 //document.getElementById('rivales3').style.display ="none";
if (col==1) {
 pos="7em";
 document.getElementById('rivales1').style.display =""
 document.getElementById('rivales1').style.left = pos
}
if (col==2) {
 pos="28.7em";
 document.getElementById('rivales2').style.display =""
 document.getElementById('rivales2').style.left = pos
}
if (col==3) {
 pos="50.3em";
 document.getElementById('rivales3').style.display =""
 document.getElementById('rivales3').style.left = pos
}


}


function mostrarOcultarComp2(col) {
if (col==1) pos="7em";
if (col==2) pos="28.7em";
if (col==3) pos="50.3em";

document.getElementById('cambiar_coche').style.display =""
document.getElementById('cambiar_coche').style.left = pos
}

function abrir(pagina,tamano){
window.open(pagina,'Foto_Ampliada',tamano);
}

/* cerrar popup */
function cerrar(url) {
window.opener.location=url;
window.close();
}

//comprobar coockies

var k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var cTIDR,cTIDA,dp=document,gotoP=escape(document.location.href);

function d64(i)
{
var o="";var ch1,ch2,ch3="";var en1,en2,en3,en4="";
var x=0;
var base64test=/[^A-Za-z0-9\+\/\=]/g;
i=i.replace(/[^A-Za-z0-9\+\/\=]/g, "");
do{
 en1=k.indexOf(i.charAt(x++));
 en2=k.indexOf(i.charAt(x++));
 en3=k.indexOf(i.charAt(x++));
 en4=k.indexOf(i.charAt(x++));
 ch1=(en1 << 2) | (en2 >> 4);
 ch2=((en2 & 15) << 4) | (en3 >> 2);
 ch3=((en3 & 3) << 6) | en4;
 o=o+String.fromCharCode(ch1);
 if(en3 != 64){o=o+String.fromCharCode(ch2);}
 if (en4 != 64){o=o + String.fromCharCode(ch3);}
 ch1=ch2=ch3="";en1=en2=en3=en4="";
} while (x < i.length);
return o;
}
function isCookie(C){
 r=new RegExp("[ ]?"+C+"=([^;]*)","i");
 C=r.exec(dp.cookie);
 C=(C && C.length==2?d64(unescape(C[1])):null);
 return (C?C.replace(/@.*/,""):C);
}


//formulario comentarios

function sacaFormulario()
{
 new Effect.BlindDown(document.getElementById('form_coment'));
 setTimeout("document.fComenta.comentario.focus()",500);

}
function ocultaFormulario()
{
 new Effect.BlindUp(document.getElementById('form_coment'));
}

 function MuestraFormulario()
 {
 var URLLogin = "https://login.terra.es/amserver/UI/Login?org=ssoterra&module=LDAP&goto="+gotoP;
 cTIDA=isCookie('TIDA');
 cTIDR=isCookie('TIDR');
 if(cTIDA&&cTIDR) { k=1; /* alert('está logado'); */ }
 else{
 if(cTIDR) { k = 2/* alert('está recordado'); */ }
 else{
// alert('no esta');
// location.href=URLLogin;
 }
 }


 sacaFormulario();
// document.getElementById('mostrar').style.visibility="hidden";
 }



function muestraformularioenload()
{
sURL = parent.document.URL;
var parametro='';
if (sURL.indexOf('?')!=-1){
 parametro=sURL.substring(sURL.indexOf('?')+1,sURL.length);
}
if (parametro.length!=0){
 sacaFormulario();}
}

/* votaciones */

function llamada(xDiv, xURL){
 $(document).ready(function(){
 $("#"+xDiv).load(xURL);
 });

}