	function llenarComboPaisInicio() {
		if (document.getElementById("comboPaisesHeader").length>1) {
			return ;
		}
		primer_tope();
	}
	
    function obtenerUrl(url,cod_pais){
        if(url.indexOf('todosPaises=')>0)
        	url_aux =  url.substring(0,url.indexOf('todosPaises=') - 1);
        else
        	url_aux =  url;
        if(url.indexOf('cod_pais_header=') >= 0){
            url_aux = url_aux.substring(0,url.indexOf('cod_pais_header=') - 1);
           }	
		
        if(url_aux.indexOf("?") >= 0) url_aux = url_aux + "&cod_pais_header=" + cod_pais;
        else url_aux = url_aux + "?cod_pais_header=" + cod_pais;

        //Nuevo c?digo 2007-04-13
        var buscarPor = document.busqueda_sencilla.buscarPor.value;
        var txtBuscar = document.busqueda_sencilla.txtBusqueda.value;
 
        if(txtBuscar==null || txtBuscar==""){
        	indexBuscar = url.indexOf('buscarPor=');
        	indexTxt= url.indexOf('&txtBusqueda=');
	        if(indexBuscar>0){
	        	if(indexTxt>0){
			        buscarPor = url.substring(indexBuscar+10,indexTxt);
			        if(url.indexOf('todosPaises=')>0)
			        	txtBuscar = url.substring(indexTxt+13,url.indexOf('todosPaises=')-1);
			        else
			        	txtBuscar = url.substring(indexTxt+13,url.length);
			    }else{
			        buscarPor = url.substring(indexBuscar+10,url.length);
			    }
	        }
		}else{
	        buscarPor = document.busqueda_sencilla.buscarPor.value;
	        txtBuscar = document.busqueda_sencilla.txtBusqueda.value;
		}

        if(txtBuscar!=null && txtBuscar!=""){
	        url_aux = url_aux + "&buscarPor="+buscarPor+"&txtBusqueda="+txtBuscar;
	    }
	    //Fin nuevo c?digo
	    if(url_aux.indexOf('cod_pais_header_ip=') <= 0)
	    	url_aux = url_aux + "&cod_pais_header_ip=<%=cod_pais_ip%>";
	    url_aux=url_aux+"&todosPaises=false";
        return url_aux;
    }
    
    function obtenerUrlIP(url,cod_pais)
    {
        url_aux = url;
        if(url.indexOf('cod_pais_header_ip=') >= 0)
        {
            url_aux = url_aux.substring(0,url.indexOf('cod_pais_header_ip=') - 1);
        }
        if(url_aux.indexOf("?") >= 0) url_aux = url_aux + "&cod_pais_header_ip=" + cod_pais;
        else url_aux = url_aux + "?cod_pais_header_ip=" + cod_pais;

	    if(url_aux.indexOf('cod_pais_header=') <= 0)
	    	url_aux = url_aux + "&cod_pais_header=<%=cod_pais_header%>";

        return url_aux;
    }
    
    function obtenerUrlUbicacion(url,cod_pais) {
	    	//closebar();
	    	document.location = obtenerUrlIP(url,cod_pais);
	    }
	    
    // Detect if the browser is IE or not.
    // If it is not IE, we assume that the browser is NS.
    var IE = document.all?true:false

    // If NS -- that is, !IE -- then set up for mouse capture
    if (!IE) document.captureEvents(Event.MOUSEMOVE)

    // Set-up to use getMouseXY function onMouseMove
    document.onmousemove = getMouseXY;

    // Temporary variables to hold mouse x-y pos.s
    var tempX = 0;
    var tempY = 0;

    // Main function to retrieve mouse x-y pos.s

    function getMouseXY(e) {
      if (IE) { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft
        tempY = event.clientY + document.body.scrollTop
      } else {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX
        tempY = e.pageY
      }
      // catch possible negative values in NS4
      if (tempX < 0){tempX = 0}
      if (tempY < 0){tempY = 0}
      return true;
    }

    function findObj(theObj, theDoc) {
      var p, i, foundObj;

      if(!theDoc) theDoc = document;
      if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
      {
        theDoc = parent.frames[theObj.substring(p+1)].document;
        theObj = theObj.substring(0,p);
      }
      if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
      for (i=0; !foundObj && i < theDoc.forms.length; i++)
        foundObj = theDoc.forms[i][theObj];
      for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
        foundObj = findObj(theObj,theDoc.layers[i].document);
      if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

      return foundObj;
    }

    function showToolTip(mensaje,width,orientacion) {
        eldiv = findObj('tooltip');
        x = tempX;
        y = tempY;
        //alert("(X,Y) = (" + x + ", " + y + ")");
        if (orientacion = 'derecha') {
            eldiv.style.left = (x - width) + "px";
        } else {
            eldiv.style.left = (x + 10) + "px";
        }

        eldiv.style.top = (y -10) + "px";
        eldiv.style.width= width + "px";
        eldiv.innerHTML = "<FONT class='toolTipClass'>" + mensaje + "</FONT>";
        eldiv.style.display="";
    }

    function hideToolTip() {
        eldiv = findObj('tooltip');
        eldiv.style.display="none";
    }

	function llenarComboPaisInicio() {
		if (document.getElementById("comboPaisesHeader").length>1) {
			return ;
		}
		primer_tope();
	}

	var actual = "";
    function llenarComboPais(valor) {
		var paises = valor;
		paises = paises.split("\n");
		var ele = document.getElementById("comboPaisesHeader");
		var myEle;
		var x ;

		actual = (ele.value!=""?ele.value:actual);

		if (ele.length>1) {
			return ;
		}
		for (var q=ele.length;q>=0;q--) {
			//ele.options[q]=null;
		}

		var datos = new Array();
		var arr;
		var cont = 0;
		for(var i = 0; i < paises.length; i++) {
alert(paises[i]);
			arr = paises[i].split(":");
			if (arr[1]!=null) {
				datos[cont++] = arr;
			}
		}
		var nuevo_Control = 0;
		for ( x = 0 ; x < datos.length  ; x++ ){
			myEle = document.createElement("option");
			myEle.value = datos[x][0];
			myEle.text = trim(datos[x][1]);
			//if (myEle.value == actual) {
			//	myEle.selected = true;
			//}
			ele.length = (nuevo_Control);
			ele[nuevo_Control] = myEle;
			nuevo_Control++
		}
		ele.value = actual;


	}



		 var _objetus = null;
		 //funcion encargada de crear el objeto
	 function objetus() {
		 try {
		 	 objetus = new ActiveXObject("Msxml2.XMLHTTP");         }
		 catch (e) {
		 	 try {
		 		objetus= new ActiveXObject("Microsoft.XMLHTTP");                 }
		 	 catch (E) {
		 		objetus= false;
		 	 }
		 }
		 if (!objetus && typeof XMLHttpRequest!='undefined') {
		 	objetus = new XMLHttpRequest();
		 }
		 return objetus
	}

	function primer_tope() {
		if (_objetus==null) {
			_objetus=objetus()
		}
		_values_send="funcion=pt"
		_URL_="/views/common/frontend/paises.html?"
		_objetus.open("GET",_URL_+"&"+_values_send,true);
		_objetus.onreadystatechange=function() {
			if (_objetus.readyState==4) {
				llenarComboPais(_objetus.responseText);
			}
		}
		_objetus.send(null);
	}

    function verificarParametros(theForm, titulo_exacto)
    {
    	theForm.cant_pagina.value=0;
    	theForm.num_pagina.value=1;
    	theForm.orden.value="libro";
        if(theForm.txtBuscarLibro.value == '')
        {
            if(theForm.buscarLibroPor.value == 'titulo') alert('Debe escribir el titulo del libro que desea buscar');
            if(theForm.buscarLibroPor.value == 'autor') alert('Debe escribir el autor del libro que desea buscar');
            if(theForm.buscarLibroPor.value == 'isbn') alert('Debe escribir el ISBN del libro que desea buscar');            
            //return false;
        }else{
	        var s =theForm.txtBuscarLibro.value;
	    	s=eliminarAcentos(s);
	    	if(theForm.buscarLibroPor.value == 'titulo'){
	    		s=s.replace(/_-_/gi,"-");
	    		s=s.replace(/-/gi,"_-_");	    	
	    	}
	    	theForm.txtBuscarLibro.value=s;
        	if(theForm.buscarLibroPor.value != 'isbn' && theForm.txtBuscarLibro.value.length<4){
				alert("El texto debe contener por lo menos 4 caracteres");
	        	//return false;
        	}else{
        		//document.frmSeccionBuscarLibro.cod_pais_header.value="";
        		theForm.todosPaises.value="true";
        		theForm.titulo_exacto.value=titulo_exacto;
				theForm.submit();
				//return true;
			}
        }
    }
    
    function submitenter(myfield,e){
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		if (keycode == 13){
		   verificarParametros(document.busqueda_sencilla, false);
		   return false;
		}
		else
		   return true;
	}
    
    function resetPagina(theForm){
    	theForm.cant_pagina.value=0;
    	theForm.num_pagina.value=1;
    }    
    
    function eliminarAcentos(Text){
		var cadena="";
		for (var j = 0; j < Text.length; j++){
			var Char=Text.charCodeAt(j);
			switch(Char){
				case 225:
				cadena+="a";
				break;
				case 233:
				cadena+="e";
				break;
				case 237:
				cadena+="i";
				break;
				case 243:
				cadena+="o";
				break;
				case 250:
				cadena+="u";
				case 224:
				cadena+="a";
				break;
				case 232:
				cadena+="e";
				break;
				case 236:
				cadena+="i";
				break;
				case 242:
				cadena+="o";
				break;
				case 249:
				cadena+="u";
				break;
				case 193:
				cadena+="A";
				break;
				case 201:
				cadena+="E";
				break;
				case 205:
				cadena+="I";
				break;
				case 211:
				cadena+="O";
				break;
				case 218:
				cadena+="U";
				break;
				case 192:
				cadena+="A";
				break;
				case 200:
				cadena+="E";
				break;
				case 204:
				cadena+="I";
				break;
				case 210:
				cadena+="O";
				break;
				case 217:
				cadena+="U";
				break;
				case 241:
				cadena+="n";
				break;
				case 209:
				cadena+="n";
				break;
				default:
				cadena+=Text.charAt(j);
				break;
			}			
		}
		return cadena;
	}
    
function mouseLeaves (element, evt) {
if (typeof evt.toElement != 'undefined' && typeof element.contains !=
'undefined') {
return !element.contains(evt.toElement);
}
else if (typeof evt.relatedTarget != 'undefined' && evt.relatedTarget) {
return !contains(element, evt.relatedTarget);
}
}

function contains (container, containee) {
while (containee) {
if (container == containee) {
return true;
}
containee = containee.parentNode;
}
return false;
}

function hideElement (element) {
//if (element.style) {
//element.style.visibility = 'hidden';
//}


var IfrRef = document.getElementById('iframedeatras');
IfrRef.style.display = "none";     
element.style.display="none";

}

function showElement (element) {
if (element.style) {
element.style.visibility = 'visible';
}
}

/***********************************************
* Drop Down/ Overlapping Content- ? Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/



function getposOffset(overlay, offsettype){

var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

var ie=document.all;
var ns6=document.getElementById && !document.all;

function overlay(curobj, subobjstr, opt_position){

if (document.getElementById){

var subobj=document.getElementById(subobjstr)
var IfrRef=document.getElementById('iframedeatras')


//oculto los otros divs que puedan estar abiertos
var item1=document.getElementById('subcontent2');
var item2=document.getElementById('subcontent3');
var item3=document.getElementById('subcontent4');
var item4=document.getElementById('subcontent5');
var item5=document.getElementById('subcontent6');

if(item1==subobj) {
	item2.style.display="none";
	item3.style.display="none";
	item4.style.display="none";
	item5.style.display="none";
	}
else if(item2==subobj) {
	item1.style.display="none";
	item3.style.display="none";
	item4.style.display="none";
	item5.style.display="none";
	}
else if(item3==subobj) {
	item1.style.display="none";
	item2.style.display="none";
	item4.style.display="none";
	item5.style.display="none";
	}
else if(item4==subobj) {
	item1.style.display="none";
	item2.style.display="none";
	item3.style.display="none";
	item5.style.display="none";
	}
else {
	item1.style.display="none";
	item2.style.display="none";
	item3.style.display="none";
	item4.style.display="none";
}


 
//************************************************


var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)

if(item5==subobj) {
	xpos=xpos-400;
}
if(item4==subobj) {
	xpos=xpos-300;
}

subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
subobj.style.zIndex = 1;

IfrRef.style.display = "block";
subobj.style.display=(subobj.style.display!="block")? "block" : "none"


//para el iframe que aparece justo detras del div. 
//Esto es para evitar el problema de IE de los div sobre las listas desplegables

IfrRef.style.width = subobj.offsetWidth;
IfrRef.style.height = subobj.offsetHeight;
IfrRef.style.top = subobj.style.top;
IfrRef.style.left = subobj.style.left;
IfrRef.style.zIndex = 0; //subobj.style.zIndex - 1;



return false
}
else
return true
}

//****************************************
function overlaymini(num_cat,cat,curobj, subobjstr, opt_position){

if (document.getElementById){

var subobj=document.getElementById(subobjstr)
var IfrRef=document.getElementById('iframedeatras')

var subnombre="";
//oculto los otros div que puedan estar abiertos
for(i=0;i<num_cat;i++)
{
	subnombre = "sub_"+cat+i ;
	var actual=document.getElementById(subnombre);
	if(actual != subobj )
		actual.style.display="none";
}


var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)

xpos=xpos-200;
ypos=ypos-280;

subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
subobj.style.zIndex = 1;

IfrRef.style.display = "block";
subobj.style.display=(subobj.style.display!="block")? "block" : "none"


//para el iframe que aparece justo detras del div. 
//Esto es para evitar el problema de IE de los div sobre las listas desplegables

/*
IfrRef.style.width = subobj.offsetWidth;
IfrRef.style.height = subobj.offsetHeight;
IfrRef.style.top = subobj.style.top;
IfrRef.style.left = subobj.style.left;
IfrRef.style.zIndex = 0; //subobj.style.zIndex - 1;
*/

return false
}
else
return true
}



function overlayclose(subobj){

var IfrRef = document.getElementById('iframedeatras');
IfrRef.style.display = "none";
     
document.getElementById(subobj).style.display="none";
   


}
