	var valido = false;
	function valida(){
	usuario = document.getElementById("usu").value
	pass1 = document.getElementById("pass").value
	pass2 = document.getElementById("pass2").value
	txt = document.getElementById("mail").value
	cp = document.getElementById("cp").value
	
	if(usuario == ''){
		alert("Introdusca un usuario");
		return false;
	}
	if(pass1 == ''){
		alert("Introdusca una contraseña");
		return false;
	}
	if(pass1.length < 5){
		alert("Su contraseña debe contener de 5 a 10 caracteres");
		return false;
	}
	if(pass2 == ''){
		alert("Introdusca confirma su contraseña");
		return false;
	}
	if(pass1 != pass2){
		alert("Las contraseñas no coinciden");
		return false;
	}
	if(txt == ''){
		alert("Introdusca un correo electrónico");
		return false;
	}  
    //expresion regular   
    var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/   
    //comentar la siguiente linea si no se desea que aparezca el alert()
	if (b.test(txt) != true) {  
     alert("Email " + (b.test(txt)?"":"no ") + "válido.") 
	 return b.test(txt)  
    }
    //devuelve verdadero si validacion OK, y falso en caso contrario   
	if(cp == ''){
		alert("Introdusca un código postal");
		return false;
	}
	if(cp.length < 5){
		alert("Código Postal no válido");
		return false;
	}
	
	if(!document.getElementById("me").checked){
		alert("Acepte terminos y condiciones.")
		return false;
	}
	
	if (!enProceso && http) {
       var valor = (document.getElementById("cp").value);
	   if(valor != ''){
		   var url = "consulta_cp.asp?cpv="+ valor + "&flag=V";
		   http.open("GET", url, true);
		   http.onreadystatechange = handleHttpResponse;
		   enProceso = true;
		   http.send(null);
		    return false;
		}
    }
	
	}
	
	function onlyDigits(e,decReq) {
		var isIE = document.all?true:false;
		var isNS = document.layers?true:false;
		var key = (isIE) ? window.event.keyCode : e.which;
		var obj = (isIE) ? event.srcElement : e.target;
		var isNum = (key > 47 && key < 58) ? true:false;
		var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
		window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
		e.which = (!isNum && !dotOK && isNS) ? 0:key;
		return (isNum || dotOK);
	}
	
	
	
	
	
	
	

function handleHttpResponse() { 
    if (http.readyState == 4) { 
		//alert(http.status)
       //if (http.status == 200) {
          if (http.responseText.indexOf('invalid') == -1) {
             // Armamos un array, usando la coma para separar elementos
             //results = http.responseText.split(","); 
			 //alert(http.responseText)
              if(http.responseText == "Existe"){
			  	valido = true
				document.forma1.submit();
			  }else{
			  	valido = false
				alert("Código postal no válido")
			  }
             enProceso = false;
         // }
       }
    }
}


function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}

var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest


<!--

function PierdeCambios()
{
	// No Hay Nada que Validar
	return (true);
}


function Validaww(Campo,Campo2)
{

   if(Campo.name.substring(0,3)=="prt")
   {
   //alert(Campo.value);
     if(parseInt(Campo.value)>parseInt(Campo2.value))
        {
          alert("Debe ser menor igual a "+Campo2.value);
          Campo.value=0;
          Campo.focus();
          return;
        }
        
   }
	  // Me Aseguro que sea Numero Entero
		Numero = Campo.value;//parseInt(Campo.value);
		if (isNaN(Numero))
			{
			alert("Solo debe de capturar valores Numéricos.");
			Campo.value= 0;
			Campo.focus();
			}
		else
			{
			// Me Aseguro que se Positivo
			if ( (Numero < 0) || (Numero > 9999) )
				{
				alert("El Valor Numerico debe estar entre 0 y 9999");				
				Campo.value = 0;
				Campo.focus();
				
				}
			else
				{
						
				Campo.value = Numero; 
				}
			}
	
}

function MiTrim(QueCadena)
{
	// Elimino Blancos a la Izquierda
	indice = 0
	while (indice < QueCadena.length )
		{
			if (QueCadena.charAt(indice) != " ")
				{
				break;
				}
			indice++;
		}
	return(QueCadena.substr(indice, QueCadena.length ))
}


function recalcula(cant){
	//alert("Entro")
	var cant1 = cant;
	Valida(cant);
	document.pedido.recalculando.value = 1;
	document.pedido.submit();
	return false;
}

//-->
	