function ValidarRutLogin(){
	    if (window.document.frm.rut.value == "")
	    {
		    alert("Debe ingresar el RUT");
		    window.document.frm.rut.select();
	        window.document.frm.rut.focus();
		    return false;
	    }
            
  	    if (!RutCorrecto(window.document.frm.rut))
        {
		    alert("El número de RUT ingresado no es válido.");
			window.document.frm.rut.select();
			window.document.frm.rut.focus();
			return false;
       	}	
       	return true;
	}
function OlvidoClave(){
		var url="";
		var pro="";
		var ven="";
		
		
		if (ValidarRutLogin()){
				AsignaDatos();
				
				url =  "http://200.1.143.10:9080/pin_Cliente-web/index.jsp";   
				document.frm.olvido.value   = "1";
				document.frm.target = "top";
				document.frm.action = url;
				document.frm.submit();
				document.frm.reset();
		
		}
	}
	function ValidaRutLogon()
	{
		var srut = window.document.frm.rut;
	    browserName = navigator.appName;
	    browserVer = parseInt(navigator.appVersion);
		var msj="";
	
		if (!RutCorrecto(srut))
	    {
	        msj = "EL RUT ingresado no es correcto. \n"
	        alert( msj + "Por favor, verif\xEDquelo e ingr\xE9selo nuevamente.");
	        if ((browserName == "Microsoft Internet Explorer" || browserName == "Netscape")&& (browserVer >= 4)){
				srut.focus();
				srut.select();
	            return false;
		    }
		    return false;
	    }
        return true;
    }
	
	
  	  function ValidarLogin()
	{
		if (window.document.frm.rut.value == "")
	    {
		    alert("Debe ingresar su RUT")
		    window.document.frm.rut.select();
  		    window.document.frm.rut.focus();
  		   return false;
	    }
		if (!ValidaRutLogon()){
			return false;
			
		}
       	
       	if (window.document.frm.contrasena.value == "")
	    {
		    alert("Debe ingresar su Contrase\xF1a")
		    window.document.frm.contrasena.select();
  		    window.document.frm.contrasena.focus();
  		   return false;
	    }
        return true;            
    }
       
	
	  function Ingresar(paso){
		 if (ValidarLogin()){
			  var url=""
			  url = "http://200.1.143.10:9080/PIN_Acceso-Intermediarios-web/scripts/index.jsp?origen=productosCorredores&producto=" + paso;   
			 

			 //asignar valores de login  
			  AsignaDatos();
			 document.frm.target = "_top"
			  document.frm.action = url
			  document.frm.submit();
			  document.frm.reset();
		 }
	}
	function AsignaDatos(){
		document.frm.Rute.value     = document.frm.rut.value;
		document.frm.txtClave.value = document.frm.contrasena.value;
		document.frm.IdRut.value    = document.frm.rut.value;
		document.frm.IdPass.value   = document.frm.contrasena.value;
				  
		document.frm.code.value     = Trim(document.frm.rut.value);
		document.frm.code.value     = document.frm.code.value.replace(/-/g,"").replace(/\./g,"");
		document.frm.key.value	    = document.frm.contrasena.value;
		document.frm.type.value     = "EXT"
		document.frm.olvido.value   = "0"
		document.frm.metodo.value   = "login"
		document.frm.token.value	= ""	
	}
	
	function ValidarFormulario(){
	var sNomx = document.contacto.nombre;
    var eMailCli = document.contacto.email;
	var sfono = document.contacto.fono;
	var ciudad= document.contacto.ciudad;
	var sProducto=document.contacto.prod;
	var tema
    
	document.contacto.ciudad.value		=	Trim(document.contacto.ciudad.value);
	document.contacto.nombre.value		=	Trim(document.contacto.nombre.value);
	document.contacto.email.value		=	Trim(document.contacto.email.value);
	document.contacto.fono.value	    =	Trim(document.contacto.fono.value);
	document.contacto.prod.value	    =	Trim(document.contacto.prod.value);
	
	if (Trim(sNomx.value) == '')
	{
		alert("No olvides ingresar nombre.");
		sNomx.focus();
		return false;
	}
	if (!OnlyChar(sNomx.value) ) 
        { 
			alert('Existen caracteres no v\xE1lidos en nombre.'); 
            sNomx.focus();
            return  
          }  	
	
	
	if(Trim(eMailCli.value) == '')
	{
		alert('No olvides ingresar e-mail.');
		eMailCli.select();
		eMailCli.focus();
		return false;
	}
	
	if (!validaEmail(eMailCli.value))
	{
		alert('E-mail err\xF3neo ingresa nuevamente.');
		eMailCli.select();
		eMailCli.focus();
		return false;
	}
	
	if(Trim(sfono.value) == '')
	{
		alert('No olvides ingresar fono.');
		sfono.select();
		sfono.focus();
		return false;
	}
	if(! OnlyNumber(sfono.value))
	{
		alert('Ingrese solo  n\xFAmeros en fono.');
		sfono.select();
		sfono.focus();
		return false;
	}
	
	if (sfono.value.length < 6) // if too long...trim it!
	{
		alert("Ingrese m\xEDnimo 6  n\xFAmeros en tel\xE9fono.");
		sfono.select();
		sfono.focus();
		return ;
	}
	
	
	return true;
}


function isFloat( Number ){
   var numfloat= /^-?([0-9]+\.[0-9]+|[0-9]+)$/;
   if(!numfloat.test(Number)){
       return false
   }else {
       return true;
   }
}

	
function Enviar(){
	
	if (ValidarFormulario())
	{
		document.contacto.submit();
	}
}
