function validatePerfil(form) {
	var pass1 = form.pass1.value;
	var pass2 = form.pass2.value;
	var email = form.email.value;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	var messageRegex = new RegExp(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);
	
	if(!email.match(emailRegex)) {
		inlineMsg('email','Ingrese un email v&aacute;lido',2);
		return false;
	}
	if (pass1 != "") {
		if(pass1 == "" || pass1.length < 6) {
			inlineMsg('pass1','Ingrese una contraseņa de al menos 6 caracteres',2);
			return false;
		}
		if(pass1 != pass2) {
			inlineMsg('pass2','La contrase&ntilde;a y su verificacion no coinciden',2);
			return false;
		}
	}
	return true;
}

function validateContacto(form) {
	var nombre = form.nombre.value;
	var email = form.email.value;
	var mensaje = form.mensaje.value;

	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	if(nombre == "" || nombre.length < 4) {
		inlineMsg('nombre','Ingrese un nombre / Enter name',2);
		return false;
	}
	if(!email.match(emailRegex)) {
		inlineMsg('email','Ingrese un email v&aacute;lido / Enter valid email address',2);
		return false;
	}
	if(mensaje == "" || mensaje.length < 6) {
		inlineMsg('mensaje','Ingrese un mensaje / Enter a message',2);
		return false;
	}
	
	form.submit();
}

function validateLogin(form) {
	var email = form.email.value;
	var password = form.password.value;
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	if(email.length < 4) {
		inlineMsg('email','Ingresa tu nombre de usuario (email)',2);
		return false;
	}
	if(password == "" || password.length < 4) {
		inlineMsg('password','Ingrese la contrase&ntilde;a',2);
		return false;
	}
	
	return true;
}

function validateRemember(form) {
	var email = form.email.value;
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	if(!email.match(emailRegex)) {
		inlineMsg('email','Ingrese un email v&aacute;lido',2);
		return false;
	}
	
	return true;
}

function validateLogin2(form) {
	var username2 = form.username.value;
	var password2 = form.password.value;
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	
	if(username2.length < 4) {
		inlineMsg('username','Ingresa tu nombre de usuario (email)',2);
		return false;
	}
	if(password2 == "" || password2.length < 4) {
		inlineMsg('password','Ingrese la contrase&ntilde;a',2);
		return false;
	}
	
	return true;
}

function showcontactinfo(toshow, title) {
	$('#contactdata').hide();
	$('#contactdistribuitors').hide();
	$('#'+toshow).show();
	$('#contacttitle').text(title);
	$('#contactype').val(title);
}

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