// Confirm delete
function boton_borrar() {
var agree=confirm("Estas seguro que queres borrar?");
if (agree)
return true ;
else
return false ;
}

// menu select
function gothere(mname)
{
var thisform = mname;
 if (thisform.selectsite.options[thisform.selectsite.options.selectedIndex].value != "nolink") {location.href=thisform.selectsite.options[thisform.selectsite.options.selectedIndex].value;}
}

function initMenus() {
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		$('#' + this.id + '.expandfirst ul:first').show();
	});
	$('ul.menu li a').click(
		function() {
			var checkElement = $(this).next();
			var parent = this.parentNode.parentNode.id;

			if($('#' + parent).hasClass('noaccordion')) {
				$(this).next().slideToggle('normal');
				return false;
			}
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				if($('#' + parent).hasClass('collapsible')) {
					$('#' + parent + ' ul:visible').slideUp('normal');
				}
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + parent + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		}
	);
}
$(document).ready(function() {initMenus();});

function setFocus(aField) {
document.forms[1][aField].focus();
}
function isAnEmailAddress(aTextField) {
// 1+@3+ [or x@x.x] is as close as we will test

if (document.forms[1][aTextField].value.length<5) {
return false;
}
else if (document.forms[1][aTextField].value.indexOf("@") < 1) {
return false;
}
else if (document.forms[1][aTextField].value.length - document.forms[0][aTextField].value.indexOf("@") < 4) {
return false;
}
else { return true; }
}

function isEmpty(aTextField) {
if ((document.forms[1][aTextField].value.length==0) || (document.forms[1][aTextField].value==null)) {
return true;
}
else { return false; 
}
}

function validate() {

// Step 1: check that required fields are
// filled in, alert and exit without
// submitting if not

// check that the name field is valued
if (isEmpty("nombre")) {
	alert("Ingrese su Nombre y Apellido");
	setFocus("nombre");
	return false;
}
if (isEmpty("empresa")) {
	alert("Ingrese su Empresa");
	setFocus("empresa");
	return false;
}
if (isEmpty("tel")) {
	alert("Ingrese su Teléfono");
	setFocus("tel");
	return false;
}
if (isEmpty("pais")) {
	alert("Ingrese su País");
	setFocus("pais");
	return false;
}
if (isEmpty("email")) {
	alert("Ingrese su email");
	setFocus("email");
	return false;
}
// Step 2: check that the email address is
// even close, alert and exit without
// submitting if not
if (!isAnEmailAddress("email")) {
	alert("Esto es una dirección inválida, Ingrese su Email");
	setFocus("email");
	return false;
}

// check that the email field is valued

if (isEmpty("consulta")) {
	alert("Ingrese su Consulta o Comentario");
	setFocus("consulta");
	return false;
}
document.formulario.submit()
// if we get this far everthing is ok, so
// let the form submit
return true;
}
