var wMailused;
wMailused=0;

var txtpal;
var txtpalE;
var txtpalI;

txtpalE="<b>Leer con atención</b>"
txtpalE=txtpalE+"<br><br>"
txtpalE=txtpalE+"Una vez finalizado el proceso de pago<br>"
txtpalE=txtpalE+"por favor no cerrar el navegador, terminar<br>"
txtpalE=txtpalE+"correctamente con la opción: [finalizar]<br>"
txtpalE=txtpalE+"para volver a CIMOC y ya poder leer el cómic<br>"
txtpalE=txtpalE+"en línea."

txtpalI="<b>Read with atention</b>"
txtpalI=txtpalI+"<br><br>"
txtpalI=txtpalI+"Once the payment process is complete<br>"
txtpalI=txtpalI+"please do not close your browser,<br>"
txtpalI=txtpalI+"properly terminate the option: [finalizar]<br>"
txtpalI=txtpalI+"to return to CIMOC and read the comic<br>"
txtpalI=txtpalI+"online."

txtmoveE="¿Mover comic a archivo?"
txtmoveI="Move comic to archived?"

txtretrieveE="¿Recuperar comic desde archivo?"
txtretrieveI="Retrieve comic from archived?"

txtinfoE="Información del cómic<br><br>Fecha de la compra: <b>FECHACOMPRA</b><br>Número de compra: <b>NUMEROCOMPRA</b>"
txtinfoI="Comic information<br><br>Date of purchase: <b>FECHACOMPRA</b><br>Purchase Number: <b>NUMEROCOMPRA</b>"

/**************************
CANVI DE SOLAPA
**************************/


function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

/**************************
ALERT REGISTE REQUERIT
**************************/
function muestra_mascomics(id){

try
{
if (document.getElementById){ //se obtiene el id
var elbloc = document.getElementById(id); //se define la variable "el" igual a nuestro div
elbloc.style.display = (elbloc.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
}

window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_mascomics('menu-esquerra_destacados_bottom');/* "contenido_a_mostrar" es el nombre que le dimos al DIV */
}
	
}
catch (err)
{
}

}





/**************************
AMPLIA A 10
**************************/
function muestra_maslibros(id){

try
{
if (document.getElementById){ //se obtiene el id
var elbloc = document.getElementById(id); //se define la variable "el" igual a nuestro div
elbloc.style.display = (elbloc.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
}

window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_mascomics('menu-esquerra_destacados_bottomLIBRO');/* "contenido_a_mostrar" es el nombre que le dimos al DIV */
}
	
}
catch (err)
{
}

}





var ima=false;
function cambiar(obj) {
  obj.src = (ima) ? 'images/up.png' : 'images/down.png';
  ima = !ima;
}

var ima2=false;
function cambiar2(obj) {
  obj.src = (ima2) ? 'images/up.png' : 'images/down.png';
  ima2 = !ima2;
}


var imat=false;
function abrircerrar(obj) {
  obj.src = (imat) ? 'images/allarga.gif' : 'images/redueix.gif';
  imat = !imat;
}

var imat2=false;
function abrircerrar2(obj) {
  obj.src = (imat2) ? 'images/lista.gif' : 'images/nolista.gif';
  imat2 = !imat2;
}




/**************************
CANVI D'IDIOMA
**************************/
function SwapIdioma(id,ale) {
 
	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  jAlert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML=""
	  document.getElementById("SwapLang").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  document.getElementById("SwapLang").innerHTML=xmlhttp.responseText;
	  history.go(0);
	  }
	}
 
	xmlhttp.open("GET","includes/AJXSwapIdioma.asp?idi="+id+"&rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;
}


/**************************
CORREO JA EXISTE
**************************/
function Mailused(id,ale) {
 
	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  jAlert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML=""
	  document.getElementById("correo").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  document.getElementById("correo").innerHTML=xmlhttp.responseText;
	  wMailused=(xmlhttp.responseText);
	  //alert(wMailused);
	  }
	}
 
	xmlhttp.open("GET","includes/AJXMailused.asp?id="+id+"&rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;
}


/**************************
CANVI DE MONEDA
**************************/
function SwapMoneda(id,ale) {
 
	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  alert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML=""
	  document.getElementById("SwapLang").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  document.getElementById("SwapLang").innerHTML=xmlhttp.responseText;
	  history.go(0);
	  }
	}
 
	xmlhttp.open("GET","includes/AJXSwapMoneda.asp?mon="+id+"&rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;
}


/**************************
OBRE EL VISOR
**************************/
function playIt(val,idi)
{

	var xmlhttp;
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  jAlert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML=""
	  document.getElementById("support").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
		  document.getElementById("support").innerHTML=xmlhttp.responseText;
		  //alert(xmlhttp.responseText);

		  
		  if (xmlhttp.responseText=="0")
				{
			    PlayOk(val);
				}  
		  else
		  {
				if (xmlhttp.responseText=="1" && idi=="E")
				{
				jAlert("Sólo es posible un usuario conectado");
				}
				if (xmlhttp.responseText=="1" && idi=="I")
				{
				jAlert("Only one user can be connected");
				}
				if (xmlhttp.responseText=="3" && idi=="E")
				{
				jAlert("!Vaya! En estos momentos el servidor está ocupado.<br>Por favor inténtalo más tarde.<br><br>Disculpa las molestias.");
				}
				if (xmlhttp.responseText=="3" && idi=="I")
				{
				jAlert("Ooops! Right now the server is busy. <br> Please try it again later.<br><br>Sorry for the inconvenience");
				}

		  }
 	  }
	}
 
	xmlhttp.open("GET","includes/AJXAbuso.asp?val="+val,true);
	xmlhttp.send(null);

}

/**************************
play visor
**************************/
function PlayOk(val)
{

window.open("http://e.cimoc.com/ebook/v.asp?"+val,"","");
}


/**************************
FALLA EL VISOR
**************************/
function Fail(idi)
{
	if (idi=="E")
	{
    jAlert("Sólo es posible un usuario conectado");
	}
	else
	{
    jAlert("Only one user can be connected");
	}
}


/**************************
ALERT REGISTE REQUERIT
**************************/
function regRequired(idi)
{

if (idi=="E")
{
	jAlert("Es necesario estar registrado, <a href='login.asp' style='color:#666666'>Iniciar sesión</a>","CIMOC")
}
else
{
	jAlert("Registration required, <a href='login.asp' style='color:#666666'>Sign in?</a>","CIMOC")
}

}




/**************************
BUY STATUS
**************************/
function BuyStatus(id,ale) {
 
	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  alert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML="<div style='width:50px;height:50px;padding:10px 0 0 30px;'><img src='images/5-0white.gif'></div>"
	  document.getElementById("CompraStatus").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  document.getElementById("CompraStatus").innerHTML=xmlhttp.responseText;
	  }
	}
 
	xmlhttp.open("GET","includes/BuyStatus.asp?id="+id+"&rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;
}

/**************************
BUY NOW
**************************/
function BuyNow(id,ale) {
 
	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  alert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML="<div style='width:232px;height:50px;'><div style='padding:5px 0 0 0;'><img src='images/5-0white.gif'></div></div>"
	  document.getElementById("CompraStatus").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  //alert(xmlhttp.responseText);
	  if (xmlhttp.responseText=="1")
	  {
		  BuyStatus(id,ale);
	  }
	  else
	  {
	  document.getElementById("CompraStatus").innerHTML="<div style='width:200px; margin-top:4px; float:center; background-color:#cde7ec; padding:10px 0 10px 0;'><a href='javascript:PayPal(idi)'><img src='images/paypal.jpg' title='Pago por Paypal' style='padding-right:12px;' border=0></a><a href='javascript:Visa(idi)'><img src='images/visa.jpg' title='Pago con VISA' border=0></a></div>";
	  }
	  }
	}
 
	xmlhttp.open("GET","buynow.asp?id="+id+"&rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;
}


/**************************
PAY PAL
**************************/
function PayPal(widi) {

if (widi=="E") {
txtpal=txtpalE;
}
else {
txtpal=txtpalI;
}

jAlert(txtpal, 'CIMOC', function(r) {
CASH.location.href="paypalbridge.asp"
});
}

/**************************
VISA
**************************/
function Visa(widi) {

if (widi=="E") {
txtpal=txtpalE;
}
else {
txtpal=txtpalI;
}

jAlert(txtpal, 'CIMOC', function(r) {
CASH.location.href="visabridge.asp"
});
}




/**************************
SAVE CHANGES
**************************/
function saveChanges(from,idi)
{
	var ok;
	var fieldtext;
	var mailtext;
	var matchtext;
	var slidertext;
	ok=0;
	//prepara literal de error
	if (idi=="E")
	{
		fieldtext="Campo requerido";
		mailtext="El correo ya está registrado";
		matchtext="Las contraseñas no son iguales";
		slidertext="Error control de seguridad";
	}
	else
	{
		fieldtext="Field required";
		mailtext="This e-mail is already registred";
		matchtext="passwords doesn't match";
		slidertext="Error on security control";
	}
	//control de slider
	if (document.forms["misdatos"].sliderValue1.value!="100")
	{
		jAlert(slidertext,'CIMOC');
	}
	else
	{
		//ok slider DATOS
		if (from=="datos"){
			//nombre
			if (document.forms["misdatos"].NO2.value=="") {
				document.forms["misdatos"].NO2.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//NIK
			if (document.forms["misdatos"].NIK.value=="" && ok==0) {
				document.forms["misdatos"].NIK.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
            document.forms["misdatos"].action="includes/savechange.asp";
		}
		if (from=="pass") {
			//password
			if (document.forms["misdatos"].PAS.value=="") {
				document.forms["misdatos"].PAS.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//new password 1
			if (document.forms["misdatos"].PA1.value=="" && ok==0) {
				document.forms["misdatos"].PA1.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//new password 2
			if (document.forms["misdatos"].PA2.value=="" && ok==0) {
				document.forms["misdatos"].PA2.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			document.forms["misdatos"].action="includes/savepass.asp";
		}
		if (from=="new") {
			//email
			if (document.forms["misdatos"].EM2.value=="") {
				document.forms["misdatos"].EM2.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			if (wMailused==1 && ok==0) {
				document.forms["misdatos"].EM2.focus();
				jAlert(mailtext,'CIMOC');
				ok=1;
			}
			//nom
			if (document.forms["misdatos"].NO2.value=="" && ok==0) {
				document.forms["misdatos"].NO2.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//nik
			if (document.forms["misdatos"].NIK.value=="" && ok==0) {
				document.forms["misdatos"].NIK.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//pass 1
			if (document.forms["misdatos"].PA1.value=="" && ok==0) {
				document.forms["misdatos"].PA1.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//pass 2
			if (document.forms["misdatos"].PA2.value=="" && ok==0) {
				document.forms["misdatos"].PA2.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			//pass 1=pass 2
			if (document.forms["misdatos"].PA1.value!=document.forms["misdatos"].PA2.value && ok==0) {
				document.forms["misdatos"].PA1.focus();
				jAlert(matchtext,'CIMOC');
				ok=1;
			}
			selpais=document.getElementById("pais");
			//pais
			if (selpais.value=="" && ok==0) {
				document.forms["misdatos"].pais.focus();
				jAlert(fieldtext,'CIMOC');
				ok=1;
			}
			document.forms["misdatos"].action="includes/savenew.asp";
		}

		if (ok==0 && wMailused==0)
		{
        document.forms["misdatos"].submit();
		}
	}

}

/**************************
LOGOFF
**************************/
function logOff()
{
	/*
	if (idi=="E")
	{
		if (confirm("Estas seguro?"))
		{
			top.location.href="logoff.asp";
		}
	}
	else
	{
		if (confirm("Are you sure?"))
		{
	*/
			top.location.href="logoff.asp";
	/*
		}
	}
	*/

}

/**************************
ES100
**************************/
function Es100()
{
	if (document.forms["misdatos"].sliderValue1.value=="100")
	{
		//alert("SI");
	}
	else
	{
		//alert("NO");
	}
	
}



function BuscadorG()
 {
								var tecla;
								var str;
								var somi;
								somi=1;
								var e = document.getElementById("seek");
								var t = document.getElementById("tipo");

								//alert(t.value);
								
								if (e.value!='')
								{
									str=e.value;

												str=str.replace("á","a")
												str=str.replace("é","e")
												str=str.replace("í","i")
												str=str.replace("ó","o")
												str=str.replace("ú","u")
												str=str.replace("à","a")
												str=str.replace("è","e")
												str=str.replace("ì","i")
												str=str.replace("ò","o")
												str=str.replace("ù","u")
												str=str.replace("Á","A")
												str=str.replace("É","E")
												str=str.replace("Í","I")
												str=str.replace("Ó","O")
												str=str.replace("Ú","U")
												str=str.replace("Ñ","N")
												str=str.replace("ñ","n")


												top.location="seek.asp?word="+str;

							    }
}

function abc()
{
var t = document.getElementById("tipo");
top.location="abc.asp?"+t.value;
}

/****
MOVE CIMOC TO ARCHIVE
****/
function move(TIT,val,pri,seg,seq,ale,typ,idi)
{
var goon;
goon=0;

if (idi=="E" && typ=="D")
{
	txtmove=txtmoveE
}
if (idi=="I" && typ=="D")
{
	txtmove=txtmoveI
}
if (idi=="E" && typ=="R")
{
	txtmove=txtretrieveE
}
if (idi=="I" && typ=="R")
{
	txtmove=txtretrieveI
}

jConfirm(txtmove,"CIMOC", function(r) {
	if (r==true)
	{
    jConfirmMove(TIT,val,pri,seg,seq,ale,typ);
	}
});
}

/****
MOVE CIMOC TO ARCHIVE
****/
function jConfirmMove(TIT,val,pri,seg,seq,ale,typ)
{



container=document.getElementById("container"+val);
//container.style.visibility='hidden';
container.style.filter="alpha(opacity=90)";
container.style.opacity="0.2";


	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  jAlert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML=""
	  document.getElementById("support").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  document.getElementById("support").innerHTML=xmlhttp.responseText;
	  //jAlert("Movido","CIMOC")
      top.location="move.asp?"+pri+"/"+seg;
	  }
	}
 
	xmlhttp.open("GET","includes/AJXPED_SEQ.asp?seq="+seq+"&typ="+typ+"&rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;



}

function showcont(val)
{
var e=document.getElementById("CONT"+val)
e.style.visibility="visible";
var e=document.getElementById("container"+val)
e.style.backgroundColor="#eaeaea";
}
function hiddcont(val)
{
var e=document.getElementById("CONT"+val)
e.style.visibility="hidden";
var e=document.getElementById("container"+val)
e.style.backgroundColor="#fff";
}

function showinfo(idi,k,c,d)
{
	if (idi=="E")
	{
		  var txtinfo=txtinfoE;
		  txtinfo=txtinfo.replace("FECHACOMPRA",d)
		  txtinfo=txtinfo.replace("NUMEROCOMPRA",c)
		  jAlert(txtinfo,"CIMOC.com");
	}
	else
	{
		  var txtinfo=txtinfoI;
		  txtinfo=txtinfo.replace("FECHACOMPRA",d)
		  txtinfo=txtinfo.replace("NUMEROCOMPRA",c)
		  jAlert(txtinfo,"CIMOC.com");
	}
}






function Only1Player()
{


	var xmlhttp;
 
	//alert(si);
 
	if (window.XMLHttpRequest)
	  {
	  // código para IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else if (window.ActiveXObject)
	  {
	  // código para IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	else
	  {
	  jAlert("Tu navegador no soporta XMLHTTP!:"+window.XMLHttpRequest);
	  }
	xmlhttp.onreadystatechange=function()
	{
 
	// en proceso
	if(xmlhttp.readyState!=4)
	{
	  txtHTML=""
	  document.getElementById("support").innerHTML=txtHTML;
	}
 
	// finalizado 
	if(xmlhttp.readyState==4)
	  {
	  document.getElementById("support").innerHTML=xmlhttp.responseText;
	  //jAlert("Movido","CIMOC")
      top.location="move.asp?"+pri+"/"+seg;
	  }
	}
 
	xmlhttp.open("GET","includes/AJXONLY1PLAYER.asp?rnd="+ale,true);
	xmlhttp.send(null);
 
	si=1;



}


/*
order by
*/
function orderby(pag,des,cod,seg,npa)
{
var t = document.getElementById("orden");

top.location=pag+"?"+des+"-"+cod+"-"+npa+"/"+seg+"/"+t.value

}








