function mostrar(capa){
obj=document.getElementById(capa);
obj.style.display=obj.style.display=='none'?'block':'none';
}


function ocultar(capa2){
obj2=document.getElementById(capa2);
obj2.style.display='none';
}
/*
function enviar(f){ //q puede ser 1, 2 ó 3
	var formu = document.getElementById('formu'+f);
	if(formu.palabra.value==""){
		alert("Ingrese palabra clave a Buscar");
		formu.palabra.focus();
	} else {	
			formu.valor_radio.value="site";
			formu.submit();
	}
}
*/




function enviar(f,page){ //q puede ser 1, 2 ó 3
var x=document.getElementById("palabra_bus"+f).value;
var y=document.getElementById("valor_radio").value;
var formu = document.getElementById('formu'+f);
// if(formu.palabra.value==""){
if(x==""){
alert("Ingrese palabra clave a Buscar");

document.getElementById("palabra").focus();
} else {

document.getElementById("valor_radio").value="site";
var url = "palabra=" + x + "&valor_radio=" + y;
location.href=page + "?" + url;
}
}
function iSubmitEnter(oEvento,page,d){
	

var iAscii;
if (oEvento.keyCode)
iAscii = oEvento.keyCode;
else if (oEvento.which)
iAscii = oEvento.which;
else
return false;
if (iAscii == 13)
{
enviar(d,page);
}
return true;
} 








function orden(){
	document.search.subcatbib_id.value=0;
	document.search.submit();
}
	
function orden_2(){
	document.search.submit();
}

function orden_dir(){
	document.search.subcatdir_id.value=0;
	document.search.submit();
}

function orden_2_dir(){	
	document.search.submit();
}

function orden_prod(){
	var url1 = document.form_prod.combo_prod.value;
	parent.location.href=url1;
}

function check_consulta(){
	if(Trim(document.form_consulta.nombre.value)=="")
	{
		alert("Debes ingresar su nombre");
		document.form_consulta.nombre.value="";
		document.form_consulta.nombre.focus();
		return;
	}
	else {
		if(Trim(document.form_consulta.email.value)=="")
		{
			alert("Debe ingresar su correo electrónico");
			document.form_consulta.email.value="";
			document.form_consulta.email.focus();
			return;
		}
		else 
		{
			if(Trim(document.form_consulta.mensaje.value)=="")
			{
				alert("Debe ingresar su consulta");
				document.form_consulta.mensaje.value="";
				document.form_consulta.mensaje.focus();
				return;
			}
			else
			{
				document.form_consulta.submit();
			}
		}
	}	
}

function check_contactanos() {
	if(Trim(document.form_contactanos.nombre.value)=="")
	{
		alert("Debe ingresar su nombre");
		document.form_contactanos.nombre.value="";
		document.form_contactanos.nombre.focus();
		return;
	}
	if(Trim(document.form_contactanos.ciudad.value)=="")
	{
		alert("Debe ingresar su país y ciudad");
		document.form_contactanos.ciudad.value="";
		document.form_contactanos.ciudad.focus();
		return;
	}
	if(Trim(document.form_contactanos.email.value)=="")
	{
		alert("Debe ingresar su correo electrónico");
		document.form_contactanos.email.value="";
		document.form_contactanos.email.focus();
		return;
	}
	if(Trim(document.form_contactanos.mensaje.value)=="")
	{
		alert("Debe ingresar su consulta");
		document.form_contactanos.mensaje.value="";
		document.form_contactanos.mensaje.focus();
		return;
	}
		document.form_contactanos.submit();
}

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;
	if (str+"" == "undefined" || str == null)	
		return null;
	str += "";	
	if (str.length == 0) 
		resultStr = "";
	else {
		i = str.length - 1;
		while ((i >= 0) && (str.charAt(i) == " "))
			i--;
		resultStr = str.substring(0, i + 1);
	}  	
	return resultStr;  	
}
function Trim(str) {
	var resultStr = "";
	resultStr = TrimRight(str);
	return resultStr;
}

function combo_productos() {
	combo = document.form_productos.combo1;
	value = combo.options[combo.selectedIndex].value;
	if(value!="") {
		self.location=value;
		return true;
	} else {
		return false;
	}
}

function mostrar_depar(){
	combo = document.form_departamentos.combo1;
	var opciones = "fullscreen=0" +
                 ",toolbar=0" +
                 ",location=0" +
                 ",status=0" +
                 ",menubar=0" +
                 ",scrollbars=0" +
                 ",resizable=0" +
                 ",width=203" + 
                 ",height=282";
	var url = "mapa.php?depar_id="+combo.options[combo.selectedIndex].value;
	if(combo.options[combo.selectedIndex].value!=0) {
	    window.open(url,"lado",opciones);
	}
}

function cambia_href(){
	var combo = document.form_departamentos.combo1;
	var id = combo.options[combo.selectedIndex].value
	if(id==0) {
		//document.getElementById("mapa_ibox").href='';
		//document.getElementById("mapa_ibox").rel='';
		document.getElementById("mapa_ibox").onclick = function() { return false; };
	} else {
		//document.getElementById("mapa_ibox").rel="ibox&height=294&width=203";
		//document.getElementById("mapa_ibox").href="mapa.php?depar_id="+id;
		document.getElementById("mapa_ibox").onclick = function() { iBox.showURL("mapa.php?depar_id="+id,'',{width: '203', height: '294'}); return false; };
		//document.getElementById("mapa_ibox").onclick = function() {};
	}
}

function cambia_href1(){
	var combo = document.form_departamentos.combo1;
	var id = combo.options[combo.selectedIndex].value
	if(id==0) {
		//document.getElementById("mapa_ibox").href='';
		//document.getElementById("mapa_ibox").rel='';
		document.getElementById("mapa_ibox").onclick = function() { return false; };
	} else {
		//document.getElementById("mapa_ibox").rel="ibox&height=294&width=203";
		//document.getElementById("mapa_ibox").href="mapa.php?depar_id="+id;
		document.getElementById("mapa_ibox").onclick = function() { iBox.showURL("../mapa.php?depar_id="+id,'',{width: '203', height: '294'}); return false; };
		//document.getElementById("mapa_ibox").onclick = function() {};
	}
}
