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 x=document.getElementById("palabra").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");

//		formu.palabra.focus();
		document.getElementById("palabra").focus();

	} else {	

		//if(formu.radio[1].checked) {

		//	formu.valor_radio.value="google";

		//	var especificaciones="top=0,left=0,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=550";

		//	var titulo="";

		//	window.open('http://www.google.com.pe/search?hl=es&q='+formu.palabra.value+'&meta=',titulo,especificaciones); 

		//	formu.palabra.value="";

		//	formu.radio[0].checked=true;

		//} else {

//			formu.valor_radio.value="site";

			document.getElementById("valor_radio").value="site";

			var url = "palabra=" + x + "&valor_radio=" + y;
			location.href="http://www.infobosques.com/buscador.php?" + url;



//			formu.submit();


		//}		

	}

}


function iSubmitEnter(oEvento){
     var iAscii;

     if (oEvento.keyCode)
         iAscii = oEvento.keyCode;
     else if (oEvento.which)
         iAscii = oEvento.which;
     else
         return false;

     if (iAscii == 13)
	 {
	 enviar(1);
	 }
     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 validardatos(){

    var nom=document.form_consulta.nombres_apellidos;

    var gen=document.form_consulta.genero;

    var ints=document.form_consulta.institucion;

    var tipoinst=document.form_consulta.tipo_institucion;

  

    if(document.form_consulta.nombres_apellidos.value=="")

    {      

        alert("Debe de ingresar sus nombres y apellidos");

        document.form_consulta.nombres_apellidos.focus();

        return;      

    }

    

    if(document.form_consulta.genero.value=="")

    {

        alert("Debe de ingresar el género");

        document.form_consulta.genero.focus();

        return;

    }

    if(document.form_consulta.institucion.value=="")

    {

        alert("Debe de ingresar la institución");

        document.form_consulta.institucion.focus();

        return;

    }

    

    if(document.form_consulta.tipo_institucion.selectedIndex==0)

    {

        alert("Debe de ingresar el tipo de institución");

        document.form_consulta.tipo_institucion.focus();

        return;     

    }

    

    if(document.form_consulta.tipo_institucion.selectedIndex==18 && document.form_consulta.otro_tipo_institucion.value=="")

    {

        alert("Debe de ingresar el tipo de institución");

        document.form_consulta.otro_tipo_institucion.focus();

        return;     

    }



    if(document.form_consulta.ocupacion.selectedIndex==0)

    {

        alert("Debe de ingresar el tipo de ocupación");

        document.form_consulta.ocupacion.focus();

        return;     

    }

    

    if(document.form_consulta.ocupacion.selectedIndex==24 && document.form_consulta.otro_ocupacion.value=="")

    {

        alert("Debe de ingresar el tipo de ocupación");

        document.form_consulta.otro_ocupacion.focus();

        return;     

    }

    

    if(document.form_consulta.pais.selectedIndex==0)

    {

        alert("Debe de ingresar el país de procedencia");

        document.form_consulta.pais.focus();

        return;     

    }

    

    if(document.form_consulta.ciudad.value=="")

    {

        alert("Debe de ingresar la ciudad de procedencia");

        document.form_consulta.ciudad.focus();

        return;     

    }

    

    if(document.form_consulta.direccion.value=="")

    {

        alert("Debe de ingresar la dirección");

        document.form_consulta.direccion.focus();

        return;     

    }

    

     if(document.form_consulta.mail.value=="")

    {

        alert("Debe de ingresar el e-mail");

        document.form_consulta.mail.focus();

        return;     

    }

    

     if(document.form_consulta.telefono.value=="")

    {

        alert("Debe de ingresar el telefono");

        document.form_consulta.telefono.focus();

        return;     

    }

        

    if(document.form_consulta.uso_info.selectedIndex==0)

    {

        alert("Debe de ingresar el uso de información");

        document.v.uso_info.focus();

        return;     

    }

    

    if(document.form_consulta.uso_info.selectedIndex==11 && document.form_consulta.otro_uso_info.value=="")

    {

        alert("Debe de ingresar el uso de información");

        document.form_consulta.otro_uso_info.focus();

        return;     

    }

    

    if(document.form_consulta.benef.selectedIndex==0)

    {

        alert("Debe de ingresar A quien beneficiaria esta información");

        document.form_consulta.benef.focus();

        return;     

    }

    

    if(document.form_consulta.benef.selectedIndex==10 && document.form_consulta.otro_benef.value=="")

    {

        alert("Debe de ingresar A quien beneficiaria esta información");

        document.form_consulta.otro_benef.focus();

        return;     

    }

    

    if(document.form_consulta.benef_status.selectedIndex==0)

    {

        alert("Debe de ingresar status de los beneficiarios");

        document.form_consulta.benef_status.focus();

        return;

    }

    

    if(document.form_consulta.benef_pais.selectedIndex==0)

    {

        alert("Debe de ingresar el país de los beneficiarios");

        document.form_consulta.benef_pais.focus();

        return;     

    }

    

    if(document.form_consulta.benef_numero.selectedIndex==0)

    {

        alert("Debe de ingresar el numero de beneficiarios");

        document.form_consulta.benef_numero.focus();

        return;     

    }

    

    if(document.form_consulta.consulta.value=="")

    {

        alert("Debe de ingresar la consulta");

        document.form_consulta.consulta.focus();

        return;     

    }

    

    document.form_consulta.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(opcion){

	var combo, enlace;	

	switch(opcion) {	

		case 0: combo = document.form_departamentos.combo1; 

				enlace = "mapa_ibox"; break;

		case 1: combo = document.form_departamentos4.combo1; 

				enlace = "mapa_ibox4"; break;

		case 2: combo = document.form_departamentos5.combo1; 

				enlace = "mapa_ibox5"; break;

		default: combo = document.form_departamentos.combo1; 

				enlace = "mapa_ibox";break;

	}

	var id = combo.options[combo.selectedIndex].value;

	if(id==0) {

		document.getElementById(enlace).onclick = function() { return false; };

	} else {

		document.getElementById(enlace).onclick = function() { iBox.showURL("mapa.php?depar_id="+id,'',{width: '203', height: '294'}); return false; };

	}

}



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() {};

	}

}
