var formEnviado = 0;

function validaRegistro(){
	formEnviado++;
	if($("nombre").value == ""){
		$("nombre").focus();
		formEnviado = 0;
		alert("Debes ingresar tu nombre");
		return(false);
	}else{
		if (/^\D*$/.test($("nombre").value))
		{ }
		else{
			$("nombre").focus();
			formEnviado = 0;
			alert("Tu nombre es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("apellido").value == ""){
		$("apellido").focus();
		formEnviado = 0;
		alert("Debes ingresar tu apellido");
		return(false);
	}else{
		if (/^\D*$/.test($("apellido").value))
		{ }
		else{
			$("apellido").focus();
			formEnviado = 0;
			alert("Tu apellido es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("documento").value == ""){
		$("documento").focus();
		formEnviado = 0;
		alert("Debes ingresar tu documento");
		return(false);
	}else{
		if (/^[0-9]{8,12}$/.test($("documento").value))
		{ }
		else{
			$("documento").focus();
			formEnviado = 0;
			alert("Tu documento es incorrecto, utiliza \xFAnicamente n\xFAmeros.");
			return (false);
		}
	}
	var rbSexo = document.getElementsByName("sexo");
	var rbLen = rbSexo.length;
	var conteo = 0;
	for(var i = 0; i < rbLen; i++) {
		if(!rbSexo[i].checked) {
			conteo++;
		}
	}
	if(conteo == rbLen){
		alert("Debes seleccionar tu sexo");
		formEnviado = 0;
		return(false);
	}
	if($("ciudad").selectedIndex == 0){
		$("ciudad").focus();
		formEnviado = 0;
		alert("Debes seleccionar tu ciudad");
		return(false);
	}
	if(($("fechaDia").selectedIndex == 0) || ($("fechaAno").selectedIndex == 0) || ($("fechaMes").selectedIndex == 0)){
		$("fechaAno").focus();
		formEnviado = 0;
		alert("Debes seleccionar tu fecha de nacimiento");
		return(false);
	}
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("registro").action = "formRegistroValidar.php";
	$("registro").submit();
}

function validaTrabaja(){
	formEnviado++;
	if($("nombre").value == ""){
		$("nombre").focus();
		formEnviado = 0;
		alert("Debes ingresar tu nombre");
		return(false);
	}else{
		if (/^\D*$/.test($("nombre").value))
		{ }
		else{
			$("nombre").focus();
			formEnviado = 0;
			alert("Tu nombre es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("apellido").value == ""){
		$("apellido").focus();
		formEnviado = 0;
		alert("Debes ingresar tu apellido");
		return(false);
	}else{
		if (/^\D*$/.test($("apellido").value))
		{ }
		else{
			$("apellido").focus();
			formEnviado = 0;
			alert("Tu apellido es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if($("telefono").value == ""){
		$("telefono").focus();
		formEnviado = 0;
		alert("Debes ingresar tu tel\xE9fono");
		return(false);
	}else{
		if (/^[0-9]{7,12}$/.test($("telefono").value))
		{ }
		else{
			$("telefono").focus();
			formEnviado = 0;
			alert("Tu tel\xE9fono es incorrecto, utiliza \xFAnicamente n\xFAmeros.");
			return (false);
		}
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("trabaja").action = "formTrabajaValidar.php";
	$("trabaja").submit();
}

function validaQueja(){
	formEnviado++;
	if($("nombre").value == ""){
		$("nombre").focus();
		formEnviado = 0;
		alert("Debes ingresar tu nombre");
		return(false);
	}else{
		if (/^\D*$/.test($("nombre").value))
		{ }
		else{
			$("nombre").focus();
			formEnviado = 0;
			alert("Tu nombre es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("apellido").value == ""){
		$("apellido").focus();
		formEnviado = 0;
		alert("Debes ingresar tu apellido");
		return(false);
	}else{
		if (/^\D*$/.test($("apellido").value))
		{ }
		else{
			$("apellido").focus();
			formEnviado = 0;
			alert("Tu apellido es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if($("telefono").value == ""){
		$("telefono").focus();
		formEnviado = 0;
		alert("Debes ingresar tu tel\xE9fono");
		return(false);
	}else{
		if (/^[0-9]{7,12}$/.test($("telefono").value))
		{ }
		else{
			$("telefono").focus();
			formEnviado = 0;
			alert("Tu tel\xE9fono es incorrecto, utiliza \xFAnicamente n\xFAmeros.");
			return (false);
		}
	}
	if(($("fechaDia").selectedIndex == 0) || ($("fechaAno").selectedIndex == 0) || ($("fechaMes").selectedIndex == 0)){
		$("fechaAno").focus();
		formEnviado = 0;
		alert("Debes seleccionar tu fecha de visita");
		return(false);
	}
	//if(($("hora").selectedIndex == 0) || ($("minuto").selectedIndex == 0)){
		if(($("hora").selectedIndex == 0)){
		$("hora").focus();
		formEnviado = 0;
		alert("Debes seleccionar tu hora apr\xF3ximada de visita");
		return(false);
	}
	if($("tienda").selectedIndex == 0){
		$("tienda").focus();
		formEnviado = 0;
		alert("Debes seleccionar la tienda de tu visita");
		return(false);
	}
	if($("comentario").selectedIndex == 0){
		$("comentario").focus();
		formEnviado = 0;
		alert("Tu opini\xF3n es muy importante para nosotros, d\xE9janos tus comentarios.");
		return(false);
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("queja").action = "formQuejaValidar.php";
	$("queja").submit();
}

function validaContacto(){
	formEnviado++;
	if($("nombre").value == ""){
		$("nombre").focus();
		formEnviado = 0;
		alert("Debes ingresar tu nombre");
		return(false);
	}else{
		if (/^\D*$/.test($("nombre").value))
		{ }
		else{
			$("nombre").focus();
			formEnviado = 0;
			alert("Tu nombre es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("apellido").value == ""){
		$("apellido").focus();
		formEnviado = 0;
		alert("Debes ingresar tu apellido");
		return(false);
	}else{
		if (/^\D*$/.test($("apellido").value))
		{ }
		else{
			$("apellido").focus();
			formEnviado = 0;
			alert("Tu apellido es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if($("comentario").selectedIndex == 0){
		$("comentario").focus();
		formEnviado = 0;
		alert("Tu opini\xF3n es muy importante para nosotros, d\xE9janos tus comentarios.");
		return(false);
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("contacto").action = "formContactoValidar.php";
	$("contacto").submit();
}

function validaProveedor(){
	formEnviado++;
	if($("nombre").value == ""){
		$("nombre").focus();
		formEnviado = 0;
		alert("Debes ingresar tu nombre");
		return(false);
	}else{
		if (/^\D*$/.test($("nombre").value))
		{ }
		else{
			$("nombre").focus();
			formEnviado = 0;
			alert("Tu nombre es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("apellido").value == ""){
		$("apellido").focus();
		formEnviado = 0;
		alert("Debes ingresar tu apellido");
		return(false);
	}else{
		if (/^\D*$/.test($("apellido").value))
		{ }
		else{
			$("apellido").focus();
			formEnviado = 0;
			alert("Tu apellido es incorrecto, utiliza \xFAnicamente letras.");
			return (false);
		}
	}
	if($("tipoServicio").selectedIndex == 0){
		$("tipoServicio").focus();
		formEnviado = 0;
		alert("Debes seleccionar el tipo de servicio");
		return(false);
	}
	if($("telefono").value == ""){
		$("telefono").focus();
		formEnviado = 0;
		alert("Debes ingresar tu tel\xE9fono");
		return(false);
	}else{
		if (/^[0-9]{7,12}$/.test($("telefono").value))
		{ }
		else{
			$("telefono").focus();
			formEnviado = 0;
			alert("Tu tel\xE9fono es incorrecto, utiliza \xFAnicamente n\xFAmeros.");
			return (false);
		}
	}
	/*if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}*/
	if($("pagina").value == ""){
		$("pagina").focus();
		alert("Debes ingresar tu p\xE1gina web");
		formEnviado = 0;
		return(false);
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("proveedor").action = "formProveedorValidar.php";
	$("proveedor").submit();
}

function validaNewsletter(){
	formEnviado++;
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("newsletter").action = "formNewsletterValidar.php";
	$("newsletter").submit();
}

function validaOlvidaste(){
	formEnviado++;
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("olvidaste").action = "formOlvidasteValidar.php";
	$("olvidaste").submit();
}


function validaComentar(idArticulo ,idUsuario){
	formEnviado++;
	/*if(idUsuario == ""){
		alert("Debes estar registrado para hacer tu comentario.\nSi ya est\xF3s registrado, ingresa tus datos en la parte superior derecha.");
		formEnviado = 0;
		return(false);
	}*/
	if($("email").value == ""){
		$("email").focus();
		alert("Debes ingresar tu E-mail");
		formEnviado = 0;
		return(false);
	}else{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("email").value))
		{ }
		else{
			$("email").focus();
			formEnviado = 0;
			alert("Tu direcci\xF3n de e-mail es incorrecta.\nDebe tener la estructura xxxx@xxxx.xxx");
			return (false);
		}
	}
	if($("comentario").value == ""){
		$("comentario").focus();
		alert("Debes ingresar tu comentario");
		formEnviado = 0;
		return(false);
	}
	if(formEnviado > 1){
		alert("Tus datos est\xE1n siendo enviados.");
		return(false);
	}
	$("comentar").action = "contDestComValidar.php?articuloId=" + idArticulo + "&";
	$("comentar").submit();
}