var firstrun=0;
var stop=0;
var luzverde=0;
// var toploc= new String()
// toploc=top.location.href+"";
// alert (window.top.location);
// if (toploc.search("cgi"))
//	top.location=self.location;

function load_menu()
{
return loadImages("images/menu_inicio_over.jpg", "images/menu_sexo_over.jpg", "images/menu_drogas_over.jpg", "images/menu_finesdesemana_over.jpg", "images/menu_prensayradio_over.jpg", "images/menu_tuopinas_over.jpg", "images/menu_consigueloya_over.jpg", "images/menu_contactar_over.jpg", "images/copyright_over.jpg", "images/comprar.gif");

}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function abre(a,b,c)
{
window.open(a,b,c);
}

function cargados()
{
var cargados=0;
var imagenes=document.images;
var total_imagenes=imagenes.length;
var porcentaje=0;
document.getElementById('cargados_capa').style.visibility="visible";

for (a=0;a<total_imagenes;a++)
	{
	if (imagenes[a].complete)
		cargados++;
	}

porcentaje=Math.floor((100*cargados)/total_imagenes);
document.getElementById('cargados_img').width=cargados*4;
document.getElementById('negro_mid').width=total_imagenes*4-1;
document.getElementById('porcentaje').innerHTML="<font size='2' face='Arial' color='white'> " + porcentaje + " % </font>";

if (cargados==total_imagenes)
	{
	clearInterval(intervalo_carga);
	document.getElementById('cargados_capa').style.visibility="hidden";
	document.getElementById('cargados_capa').style.zIndex=0;
	}
}


function lanza_intervalo()
{
if (!window.intervalo_carga)
	{
	intervalo_carga=setInterval('cargados()',50);
	}
}

function set_visible(objeto,valor)
{
objeto.style.visibility=valor;
}

function loadImages() {
     for (var i = 0; i < arguments.length; i++) {
         var temp = makeId(arguments[i]);
         if (!eval(temp +"= new Image()"))
		document.write("n");
         if (!eval(temp+".src ='"+ arguments[i] +"'"))
		document.write("m");
     }
 }

function makeId(path) {
    return path.substring(path.lastIndexOf("/")+1, path.lastIndexOf("."));
 }

function carga_fondos()
{
if (loadImages("images/sexo_fondo_letras.jpg", "images/consigueloya_fondo_letras.jpg", "images/tuopinas_borde.jpg",  "images/prensayradio_fondo_letras.jpg", "images/drogas_fondo_letras.jpg", "images/finesdesemana_fondo_letras.jpg", "images/finesdesemana_fondo_letras.jpg"))
	if (loadImages("images/tuopinas_borde_04.jpg", "images/tuopinas_borde_05.jpg", "images/tuopinas_borde_06.jpg", "images/tuopinas_borde_07.jpg", "images/40principales.jpg","images/consigueloya_fondo_letras.jpg"))
		return true;

}

// Pulsa aqui
function pa_start()
{
document.getElementById('pulsa_aqui').style.visibility="visible";
// document.getElementById('menu_consigueloya').src='images/menu_consigueloya.jpg';
setTimeout("pa_push()",500);
}

// Pulsa aqui
function pa_push()
{
document.getElementById('pulsa_aqui').style.visibility="hidden";
// document.getElementById('menu_consigueloya').src=menu_consigueloya_over.src;

if (!stop)	
	setTimeout("pa_start()",500);
}

// consiguelo ya intermitente
function cy_start()
{
document.getElementById('menu_consigueloya').src='images/menu_consigueloya.jpg';
//document.getElementById('menu_consigueloya').src=menu_consigueloya.src;
setTimeout("cy_push()",500);
}

// consiguelo ya intermitente
function cy_push()
{
document.getElementById('menu_consigueloya').src=menu_consigueloya_over.src;

if (stop!=0)
	setTimeout("cy_start()",500);
}

function swap_portada_contraportada(which)
{
theobject=which
document.images['imagenlibro'].src=libro_contraportada.src;
}

function swap_contraportada_portada()
{
document.images['imagenlibro'].src=libro_portada.src;
}

function swap_imagen()
{
if (document.images['imagenlibro'].src==libro_portada.src)
	document.images['imagenlibro'].src=libro_contraportada.src
else
	document.images['imagenlibro'].src=libro_portada.src
}

function high(which2){
theobject=which2
//which2.style.zIndex=3;
which2.style.visibility="visible";
highlighting=setInterval("highlightit(theobject)",1)
}

function low(which2,step1,fstrun_tmp){
theobject=which2
theobject.style.visibility="visible";
//theobject.style.zIndex=-1;

step=step1
fstrun=fstrun_tmp

if (window.highlighting)
	clearInterval(highlighting)

lowlighting=setInterval("lowlightit(theobject,step,fstrun)",1)
}

function low1(which2){
clearInterval(highlighting)
if (which2.filters)
	which2.filters.alpha.opacity=0
}

function highlightit(cur2){
cur2.style.zIndex=100;
if (cur2.filters&&cur2.filters.alpha.opacity<100)
	cur2.filters.alpha.opacity+=20
else if (window.highlighting)
	clearInterval(highlighting);

}

function lowlightit(cur2,step){
if (cur2.filters&&cur2.filters.alpha.opacity>0)
	cur2.filters.alpha.opacity-=step
else if (window.lowlighting)
	{
	clearInterval(lowlighting);
	if (firstrun==0)
		{
		swap_portada_contraportada(cur2);
		high(document.getElementById('contraportada_layer'));
		firstrun=1
		}
	else if (firstrun==2)
		{
		top.location="sexo.html";
		}
	cur2.style.visibility="hidden";
	cur2.style.zIndex=0;
	}
}

function all_visible(){
document.getElementById('capalibro').style.visibility="visible";
document.getElementById('menu').style.visibility="visible";
document.getElementById('copyright').style.visibility="visible";
pa_start();
//cy_start();
// high(portada_layer);
}

function reset_all_visible()
{
var stop=true;
clearInterval(intervalo_carga);
all_visible();

}

function all_visible_noindex(){
if (document.show_pedidos=="SI")
	return;
document.getElementById('capalibro').style.visibility="visible";
document.getElementById('menu').style.visibility="visible";
document.getElementById('copyright').style.visibility="visible";
cy_start();

}

function copyright()
{
alert('Ivan Lopez. Para cualquier informacion: ivan@minovela.com')
}

function show_pedidos()
{
document.show_pedidos="SI";
echo_select_cod_pais(); // No eliminar, evita que se vea el combo select de paises en donde.php antes de darle a comprar.
document.getElementById('body').innerHTML=document.getElementById('frame_texto').innerHTML;
}

function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function ajusta_layers()
{
if (document.all)
	return;

var capas=Array("menu", "alert_resolucion", "cargados_capa", "copyright", "portada_layer", "contraportada_layer", "capalibro", "pulsa_aqui", "40principales");
izquierda=document.getElementById('tabla_ancla').offsetLeft;

for (var a=0;a<capas.length;a++)
	if (document.getElementById(capas[a]) && document.getElementById(capas[a])!=null)
		document.getElementById(capas[a]).style.left=izquierda + document.getElementById(capas[a]).offsetLeft;
}

function show_tarjeta_box()
{
document.getElementById('tarjeta_box').style.height="250px";
document.getElementById('tarjeta_box').style.width="100%";
//document.getElementById('tarjeta_box').style.display='inline';
document.getElementById('tarjeta_box').style.display="";
return;
document.getElementById(tarjeta_box).innerHTML="<br><table border=1 cellpadding=10 cellspacing=0 bgcolor='white' width='80%'><tr><td>Titular de la tarjeta:<br><input type='text' name='titulart' id='titulart' id='numt' size='35' maxlength='35'><br><br>Número de tarjeta:<br><input type='text' name='numt' id='numt' size='35' maxlength='16'><br><br>Fecha de caducidad: &nbsp;&nbsp;&nbsp; Mes <select name='mest' id='mest'><option value='' selected>--</option><option value='01' >1</option><option value='02' >2</option><option value='03' >3</option><option value='04' >4</option><option value='05' >5</option><option value='06' >6</option><option value='07' >7</option><option value='08' >8</option><option value='09' >9</option><option value='10' >10</option><option value='11' >11</option><option value='12' >12</option></select> &nbsp;&nbsp; Año <select name='anyot' ID='anyot'><option value='' selected>--</option><option value='05' >2005</option><option value='06' >2006</option> <option value='07' >2007</option> <option value='08' >2008</option> <option value='09' >2009</option> <option value='10' >2010</option> <option value='11' >2011</option> <option value='12' >2012</option> <option value='13' >2013</option> <option value='14' >2014</option> <option value='15' >2015</option></select><br><br> Número CVV: <input type='text' name='cvvt' size='4' maxlength='4' ID='cvvt'> &nbsp;&nbsp;&nbsp;&nbsp;<a href='#cvv' onclick='javascript:show_cvv()'><small><font color='blue'>(¿Qué es el número CVV?)</font></small></a></td><tr></table>";
}

function hide_tarjeta_box()
{
document.getElementById('tarjeta_box').style.height="0px";
document.getElementById('tarjeta_box').style.width="0px";
document.getElementById('tarjeta_box').style.display="none";
//document.getElementById(tarjeta_box).style.visibility="hidden";
//document.getElementById(tarjeta_box).innerHTML="";
}

function check_forma_pago_NO()
{
checkFormaPago=setTimeout("check_forma_pago_timeout()",100);
}

function check_forma_pago_timeout()
{
}

function check_forma_pago()
{
document.getElementById("forma_pagoc").checked=true;
document.getElementById("horario_entregam").checked=true

if (document.getElementById("forma_pagot") && document.getElementById("forma_pagot").checked)
	show_tarjeta_box();
}

function show_cvv()
{
// posy=xOffsetTop("tarjeta_box");
// xMoveTo("cvv_txt",10,posy+100)
document.getElementById("cvv_txt").style.top="300px";
document.getElementById("cvv_txt").style.visibility="visible";
}

function hide_cvv()
{
document.getElementById("cvv_txt").style.visibility="hidden";
}
