function ltrim(s) {
   return s.replace(/^\s+/, "");
}

function rtrim(s) {
   return s.replace(/\s+$/, "");
}

function trim(s) {
   return rtrim(ltrim(s));
}

/* Validaciones del formulario de contactenos */
function sendForm() {
	var s = "";
	if( trim(document.form.asunto.value) == "" ) {
		s = s + "Debe ingresar el asunto\n";
		//document.form.asunto.focus();
	}	
	if( trim(document.form.nombre.value) == "" ) {
		s = s + "Debe ingresar el nombre\n";
		//document.form.nombre.focus();
	}
	if( trim(document.form.telefono.value) == "" ) {
		s = s +  "Debe ingresar el telefono\n";
		//document.form.telefono.focus();
	}
	if( trim(document.form.email.value) == "" ) {
		s = s +  "Debe ingresar el email\n";
		//document.form.email.focus();
	}
	if( trim(document.form.comentarios.value) == "" ) {
		s = s +  "Debe ingresar los comentarios\n";
		//document.form.comentarios.focus();
	}
	var c = trim(document.form.comentarios.value);
	if( c.length > 400 ) {
		s = s +  "Los comentarios no pueden tener mas de 400 caracteres\n";
		//document.form.comentrios.focus();
	}
	if( s != "" ){
		alert(s);
		return false;
	}
	document.form.send.value=1;
	document.form.submit();
}

/* Funciones para manejo de submenus */
/* global_ciclo : controla numero de items del submenu en cada pagina donde se reqiera */
function hide(n) {
	if( n != 0 ) {
		document.getElementById( 'a_0' ).style.display="none";
	}
	for(i=1; i<= global_ciclo; i++ ) {
		if( n != i ) {
			document.getElementById( String('a_' + i) ).style.display="none";
		}
	}
}

function show(n) {
	document.getElementById( String('a_' + n) ).style.display="";
	hide(n);
}

/* Funciones para mostrar imagenes */
function display(myimage) {
	var html = "<HTML><HEAD><TITLE>Photo</TITLE>" +
	"</HEAD><BODY LEFTMARGIN=0 " +
	"MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0 BOTTONMARGIN=0><CENTER>" +
	"<A HREF='javascript:window.close();'><IMG SRC='" + myimage + "' BORDER=0 NAME=image " +
	"onload='window.resizeTo(document.image.width+40,document.image.height+55)' alt='Cerrar'></A></CENTER>" +
	"</BODY></HTML>";
 popup=window.open
	 ('Image','image','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
 popup.document.open();
 popup.document.write(html);
 popup.focus();
 //popup.document.close()
 };

/* Funciones para manejo de mapa */
function showInfo(o) {
	switch(o) {
		case 1: document.getElementById("map-bta").style.display="block"; break;
		case 2: document.getElementById("map-med").style.display="block"; break;
		case 3: document.getElementById("map-cali").style.display="block"; break;
		case 4: document.getElementById("map-hond").style.display="block"; break;
	}
	
}

function hideInfo() {
	document.getElementById("map-bta").style.display="none";
	document.getElementById("map-med").style.display="none";
	document.getElementById("map-cali").style.display="none";
	document.getElementById("map-hond").style.display="none";
}