		function SetCookie (name, value, expires) {
				document.cookie = name + "=" + value + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()));
		}

		function isempty(variable){
				alert ('La variable ' + variable + ' no ha sido llenada');
				}

		function validaarroba(tipofono,checkStr){
		  var allValid = true;
		  var esta1 = false;
		  var esta2 = false;

		  for (i = 0;  i < checkStr.length;  i++)
			 {
			 var allValid2=false;
			 for (j = 0;  j < tipofono.length;  j++)
				 {
				  if (checkStr.charAt(i) == tipofono.charAt(j))
					  {
					   if(checkStr.charAt(i)=='@'&&esta1==true)
						 {
						  esta2=true;
						 }
					   if(checkStr.charAt(i)=='@'&&esta1==false)
						 {
						  esta1=true;
						 }
					   allValid2=true;
					  }
				 }

				if (allValid2==false || esta2==true)
						{
						allValid=false;
						break;
						}

				}
		  if (!allValid||esta1==false){
			return (false);
			}
		  return (true);
		}

		function validatipo(tipofono,checkStr){
		  var allValid = true;
		  var esta1 = false;
		  var esta2 = false;

		for (i = 0;  i < checkStr.length;  i++){
				var allValid2=false;
				for (j = 0;  j < tipofono.length;  j++){
						if (checkStr.charAt(i) == tipofono.charAt(j))
								{
								if(tipofono.charAt(j)=="@"&&esta1==true)
								  {esta2=true;}
								if(tipofono.charAt(j)=="@"&&esta1==false)
								  {esta1=true;}
								allValid2=true;
								break;
								}
						}
				if (allValid2==false || esta2==true){
						allValid=false;
						break;
						}

				}
		  if (!allValid){
			return (false);
			}
		  return (true);
		}

		function valida(theForm)
			{

				// revisamos que no hayan campos vacios :P

				if (theForm.nombre.value == "")
					{
						isempty("Nombre");
						focus(theForm.nombre.value);
						return(false);
					}
				if (theForm.nombre.value.length < 4)
					{
						alert("El nombre debe tener al menos 4 caracteres");
						focus(theForm.nombre.value);
						return(false);
					}
				if (theForm.direccion.value == "")
					{
						isempty("Direccion");
						focus(theForm.direccion.value);
						return(false);
					}
			
				if (theForm.ciudad.value == "")
					{
						isempty("Ciudad");
						focus(theForm.ciudad.value);
						return(false);
					}

				if (theForm.region.options[theForm.region.selectedIndex].value == "none")
				{
				  alert("Debe seleccionar una Region");
				  return (false);
				}
			
				if (theForm.telefono.value == "")
					{
						isempty("Telefono");
						focus(theForm.telefono.value);
						return(false);
					}
				
				if (theForm.email.value == "")
					{
						isempty("Correo");
						focus(theForm.email.value);
						return(false);
					}
				if (theForm.login.value == "")
					{
						isempty("Login");
						focus(theForm.login.value);
						return(false);
					}
				if (theForm.pass.value == "")
					{
						isempty("Password");
						focus(theForm.pass.value);
						return(false);
					}
				if (theForm.pass2.value == "")
					{
						isempty("Repita Password");
						focus(theForm.pass2.value);
						return(false);
					}
				
				if (validatipo("abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890éúíóáüÁÉÍÓÚÜ. ",theForm.nombre.value) == false)
					{
						alert("Solo puede usar letras y números en el Nombre o Razón Social");
						focus(theForm.nombre.value);
						return(false);
					}
				if (validatipo("abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890éúíóáüÁÉÍÓÚÜ#. ",theForm.direccion.value) == false)
					{
						alert("Solo puede usar letras y números en su dirección");
						focus(theForm.direccion.value);
						return(false);
					}
				
				if (validatipo("abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890éúíóáüÁÉÍÓÚÜ. ",theForm.ciudad.value) == false)
					{
						alert("Solo puede usar letras y números en su ciudad");
						focus(theForm.ciudad.value);
						return(false);
					}
				
				if (validatipo("0123456789()-. ",theForm.telefono.value) == false)
					{
						alert("Solo puede usar números en su telefono");
						focus(theForm.telefono.value);
						return(false);
					}
				if (validatipo("0123456789()-. ",theForm.fax.value) == false)
					{
						alert("Solo puede usar números en su fax");
						focus(theForm.fax.value);
						return(false);
					}
				if (validatipo("abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZéúíóáüÁÉÍÓÚÜ. ",theForm.contacto.value) == false)
					{
						alert("Solo puede usar letras en el nombre de su contacto");
						focus(theForm.contacto.value);
						return(false);
					}
				if (validaarroba("abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ0123456789éúíóáüÁÉÍÓÚÜ-.@_",theForm.email.value)==false)
					{
						alert("Escriba un e-mail valido en el campo \"correo electronico\".");
						theForm.email.focus();
						return false;
					}
				if (validatipo("abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890éúíóáüÁÉÍÓÚÜ%&/()=_.- ",theForm.login.value) == false)
					{
						alert("Solo puede usar letras y numeros en el Login");
						focus(theForm.login.value);
						return(false);
					}
				if (theForm.login.value.length < 4)
					{
						alert("El nombre de usuario debe tener al menos 4 caracteres");
						focus(theForm.login.value);
						return(false);
					}
				// Ahora revisamos los password que sean iguales
				if (theForm.pass.value.length < 4 || theForm.pass.value.length > 15)
					{
						alert("Su password debe tener 4 o mas caracteres y menos de 16 caracteres");
						focus(theForm.pass.value);
						return(false);
					}
				if (theForm.pass.value != theForm.pass2.value)
					{
						alert("Los passwords no coinciden, debe repetir el mismo password");
						focus(theForm.pass.value);
						return(false);
					}
				return(true);
			}

