function userreg_valid(theForm)
{
  if (theForm.ssubject.value == "SA")
  {
    alert("Por favor Seleccione un Valor para el campo \"Asunto\" ");
    theForm.Name.focus();
    return (false);
  }
  if (theForm.Name.value == "")
  {
    alert("Por favor Inserte un Valor para el campo \"Nombre\" ");
    theForm.Name.focus();
    return (false);
  }
  if (theForm.Name.value.length > 50)
  {
    alert("El campo \"Nombre\" no debe contener mas de 50 caracteres.");
    theForm.Name.focus();
    return (false);
  }
  if (theForm.Ape.value == "")
  {
    alert("Por favor Inserte un Valor para el campo \"Apellidos\" ");
    theForm.Ape.focus();
    return (false);
  }
   if (theForm.email.value == "")
  {
    alert("Por favor inserta un valor en el campo \"Email\".");
    theForm.email.focus();
    return (false);
  }
  if (theForm.email.value.length > 50)
  {
    alert("Inserta una cadena menor de 50 caracteres en el campo\"Email\".");
    theForm.email.focus();
    return (false);
  }
// Email valitacion
	if(theForm.email.value!="")
		{
			 if ((theForm.email.value.indexOf(" ")!=-1)) {
	   	    	alert("Lo siento, pero el Email no debe contener espacios en blanco");
				theForm.email.select();
				theForm.email.focus();
			    return false;
			    }
		 	if ((theForm.email.value.indexOf("@")==-1)) {
				 alert("Lo siento, pero el Email debe contener el caracter @");
			   	 theForm.email.select();
			   	 theForm.email.focus();
			  	 return false;
			 	}
		 	if (theForm.email.value.indexOf("@")<2) {
			   	 alert("Lo siento, pero esta es una direccion invalida"+ "\n"+ "Por favor verifica el texto antes de '@'");
				 theForm.email.select();
				 theForm.email.focus();
				 return false ;
                 }	
		 	 if ((theForm.email.value.indexOf(".",theForm.email.value.indexOf("@")) - theForm.email.value.indexOf("@")) < 2 ) {
				 	alert("Lo siento, pero esta es una direccion invalida" + "\n"+ "el dominio no esta especificado")
				    theForm.email.select();
				    theForm.email.focus();
				    return false;
					}
 			if ((theForm.email.value.length - theForm.email.value.indexOf(".",theForm.email.value.indexOf("@"))) < 2 ) {
				 	alert("Lo siento, pero esta es una direccion invalida")
			 		theForm.email.select();
					theForm.email.focus();
				 	return false;
				    }
			if (theForm.email.value.charAt(theForm.email.value.length-1) == "." ) {
		 			alert("Lo siento, pero esta es una direccion invalida " + "\n"+ "el punto no puede ser el ultimo caracter")
				    theForm.email.select();
				    theForm.email.focus();
				    return false;
				   }
		 }
  if (theForm.comments.value == "")
  {
    alert("Introduce un valor en el campo \"Comentarios\".");
    theForm.comments.focus();
    return (false);
  }
  return (true);
}
function validate(f) {
	var msg = '';

	if (f.login.value == '') msg = 'Por Favor Indroduce tu Nombre de Usuario';
	if (msg != '') {
		f.login.focus();
		alert(msg);
		return false;
	} 
	if (f.pass.value == '') msg = 'Por Favor Indroduce tu Contraseņa';
	if (msg != '') {
		f.pass.focus();
		alert(msg);
		return false;
	} 
		return true;
}

function forgotten() {
	window.open("Servicios/Forgoten.php", "Envio_Contraseņa", "scrollbars=no,status=no,width=360,height=200,resizable=yes,top=0");
}

function loginhelp() {
	window.open("Servicios/AyudaLogin.php", "Ayuda", "scrollbars=no,status=no,width=400,height=300,resizable=yes,top=0");
}
function checkAll(chkbox){
	for (var j=0;j < document.forms.length;j++){
		for (var i=0;i < document.forms[j].elements.length;i++){
			var elemento = document.forms[j].elements[i];
			if (elemento.type == "checkbox"){
				elemento.checked = chkbox.checked
			}
		}
	}
}
