function Form1_Validator(theForm)
{
	if (theForm.usuario.value == "") {
		alert("Introduzca el usuario correctamente. Gracias.");
		theForm.usuario.focus();
		return (false);
	}
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-";
	var checkStr = theForm.usuario.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	if (!allValid)
	{
		alert("Escriba sólo letra y dígito caracteres en el campo \"Usuario\". Gracias.");
		theForm.usuario.focus();
		return (false);
	}
	if (theForm.password.value == "") {
		alert("Introduzca la contraseña correctamente.");
		theForm.password.focus();
		return (false);
	}
	return (true);
}

function Form1_Validator_Alta(theForm)
{
	if (theForm.nombre.value == "") {

		alert("Debe introducir su NOMBRE o RAZON SOCIAL.");

		theForm.nombre.focus();

		return (false);

	}

	if (theForm.nombre.value == "Nombre o Razon Social") {

		alert("Debe introducir su NOMBRE o RAZON SOCIAL.");

		theForm.nombre.focus();

		return (false);

	}

	if ((theForm.nombre.value.length) < 5) {

		alert("La longitud introducida para el NOMBRE/RAZON SOCIAL es incorrecta.");

		theForm.nombre.focus();

		return (false);

	}

	if (theForm.cif.value == "") {

		alert("Debe introducir su NIF o CIF.");

		theForm.cif.focus();

		return (false);

	}

	if (theForm.cif.value == "NIF/CIF") {

		alert("Debe introducir su NIF o CIF.");

		theForm.cif.focus();

		return (false);

	}

	if ((theForm.cif.value.length) < 9) {

		alert("La longitud introducida para el NIF/CIF es incorrecta.");

		theForm.cif.focus();

		return (false);

	}

	if (theForm.domicilio.value == "") {

		alert("Debe introducir su DOMICILIO.");

		theForm.domicilio.focus();

		return (false);

	}

	if (theForm.domicilio.value == "Domicilio") {

		alert("Debe introducir su DOMICILIO.");

		theForm.domicilio.focus();

		return (false);

	}

	if ((theForm.domicilio.value.length) < 5) {

		alert("La longitud introducida para el DOMICILIO es incorrecta.");

		theForm.domicilio.focus();

		return (false);

	}

	if (theForm.cp.value == "") {

		alert("Debe introducir su CODIGO POSTAL.");

		theForm.cp.focus();

		return (false);

	}

	if (theForm.cp.value == "Codigo Postal") {

		alert("Debe introducir su CODIGO POSTAL.");

		theForm.cp.focus();

		return (false);

	}

	if ((theForm.cp.value.length) < 5) {

		alert("La longitud introducida para el CODIGO POSTAL es incorrecta.");

		theForm.cp.focus();

		return (false);

	}

	if (theForm.poblacion.value == "") {

		alert("Debe introducir la POBLACION.");

		theForm.poblacion.focus();

		return (false);

	}

	if (theForm.poblacion.value == "Poblacion") {

		alert("Debe introducir la POBLACION.");

		theForm.poblacion.focus();

		return (false);

	}

	if ((theForm.poblacion.value.length) < 5) {

		alert("La longitud introducida para la POBLACION es incorrecta.");

		theForm.poblacion.focus();

		return (false);

	}

	if (theForm.provincia.value == "") {

		alert("Debe introducir la PROVINCIA.");

		theForm.provincia.focus();

		return (false);

	}

	if (theForm.provincia.value == "Provincia") {

		alert("Debe introducir la PROVINCIA.");

		theForm.provincia.focus();

		return (false);

	}

	if ((theForm.provincia.value.length) < 5) {

		alert("La longitud introducida para la PROVINCIA es incorrecta.");

		theForm.provincia.focus();

		return (false);

	}

	if (theForm.pais.value == "") {

		alert("Debe introducir el nombre de su PAIS.");

		theForm.pais.focus();

		return (false);

	}

	if (theForm.pais.value == "Pais") {

		alert("Debe introducir el nombre de su PAIS.");

		theForm.pais.focus();

		return (false);

	}

	if ((theForm.pais.value.length) < 3) {

		alert("La longitud introducida para el nombre del PAIS es incorrecta.");

		theForm.pais.focus();

		return (false);

	}

	if (theForm.telefono.value == "") {

		alert("Debe introducir su TELEFONO de contacto.");

		theForm.telefono.focus();

		return (false);

	}

	if (theForm.telefono.value == "Telefono") {

		alert("Debe introducir su TELEFONO de contacto.");

		theForm.telefono.focus();

		return (false);

	}

	if (theForm.email.value == "") {

		alert("Debe introducir el EMAIL.");

		theForm.email.focus();

		return (false);

	}

	if(theForm.email.value.indexOf(".")>2 && theForm.email.value.indexOf("@")>0){

	}else{

		alert("El formato del EMAIL es incorrecto.");

		theForm.email.focus();

		return (false);

	}

	if ((theForm.email.value.length) < 5) {

		alert("La longitud introducida para el EMAIL es incorrecta.");

		theForm.email.focus();

		return (false);

	}

	if ((theForm.telefono.value.length) < 9) {

		alert("La longitud introducida para el TELEFONO es incorrecta.");

		theForm.telefono.focus();

		return (false);

	}

	if (theForm.txCantidad.value == "") {

		alert("Debe introducir una CANTIDAD.");

		theForm.txCantidad.focus();

		return (false);

	}

	if (theForm.txCantidad.value == "Cantidad") {

		alert("Debe introducir una CANTIDAD.");

		theForm.txCantidad.focus();

		return (false);

	}

	if ((theForm.txCantidad.value) < 1 && (theForm.cantidad.value) > 100) {

		alert("La CANTIDAD introducida es incorrecta.");

		theForm.txCantidad.focus();

		return (false);

	}

	if (theForm.lopd.checked == false) {

		alert("Debes aceptar la politica de privacidad");

		theForm.lopd.focus();

		return (false);

	}

	return (true);
}

function CompruebaDatos(elCIF)
{

  var resul = false;
  // pasar a mayúsculas
  var temp = elCIF.value.toUpperCase();

  if (!/^[A-Za-z0-9]{9}$/.test(temp)) // Son 9 dígitos?
   alert ("Longitud incorrecta, un CIF consta de 9 dígitos");
  else if (!/^[ABCDEFGHKLMNPQS0-9]/.test(temp))
   // Es una letra de las admitidas ?
   alert("El primer dígito es  incorrecto, debe ser una letra de las siguientes: A,B,C,D,E,F,G,H,K,L,M,N,P,Q,S    ");
  else
   resul = true;
   return resul;
}


function Form1_Validator_Contactar(theForm)
{
	if (theForm.from.value == "") {

		alert("Debe introducir su NOMBRE.");

		theForm.from.focus();

		return (false);

	}

	if ((theForm.from.value.length) < 5) {

		alert("La longitud introducida para el NOMBRE es incorrecta.");

		theForm.from.focus();

		return (false);

	}

	if (theForm.email.value == "") {

		alert("Debe introducir el EMAIL.");

		theForm.email.focus();

		return (false);

	}

	if(theForm.email.value.indexOf(".")>2 && theForm.email.value.indexOf("@")>0){

	}else{

		alert("El formato del EMAIL es incorrecto.");

		theForm.email.focus();

		return (false);

	}

	if ((theForm.email.value.length) < 5) {

		alert("La longitud introducida para el EMAIL es incorrecta.");

		theForm.email.focus();

		return (false);

	}

	if (theForm.mensaje.value == "") {

		alert("Debe introducir el MENSAJE.");

		theForm.mensaje.focus();

		return (false);

	}

	if ((theForm.mensaje.value.length) < 5) {

		alert("La longitud introducida para el MENSAJE es incorrecta.");

		theForm.mensaje.focus();

		return (false);

	}

	return (true);
}

function Form1_Validator_Soporte(theForm)
{
	if (theForm.from.value == "") {

		alert("Debe introducir su NOMBRE.");

		theForm.from.focus();

		return (false);

	}

	if ((theForm.from.value.length) < 5) {

		alert("La longitud introducida para el NOMBRE es incorrecta.");

		theForm.from.focus();

		return (false);

	}

	if (theForm.empresa.value == "") {

		alert("Debe introducir la EMPRESA.");

		theForm.empresa.focus();

		return (false);

	}

	if ((theForm.empresa.value.length) < 5) {

		alert("La longitud introducida para EMPRESA es incorrecta.");

		theForm.empresa.focus();

		return (false);

	}

	if (theForm.cargo.value == "") {

		alert("Debe introducir el CARGO.");

		theForm.cargo.focus();

		return (false);

	}

	if ((theForm.cargo.value.length) < 5) {

		alert("La longitud introducida para el CARGO es incorrecta.");

		theForm.cargo.focus();

		return (false);

	}

	if (theForm.email.value == "") {

		alert("Debe introducir el EMAIL.");

		theForm.email.focus();

		return (false);

	}

	if(theForm.email.value.indexOf(".")>2 && theForm.email.value.indexOf("@")>0){

	}else{

		alert("El formato del EMAIL es incorrecto.");

		theForm.email.focus();

		return (false);

	}

	if ((theForm.email.value.length) < 5) {

		alert("La longitud introducida para el EMAIL es incorrecta.");

		theForm.email.focus();

		return (false);

	}

	if (theForm.mensaje.value == "") {

		alert("Debe introducir el MENSAJE.");

		theForm.mensaje.focus();

		return (false);

	}

	if ((theForm.mensaje.value.length) < 5) {

		alert("La longitud introducida para el MENSAJE es incorrecta.");

		theForm.mensaje.focus();

		return (false);

	}

	return (true);
}
