function validarUsuario(){
		
	if (window.document.form.Rut.value == ""){
		alert("Ingrese rut de cliente");
		window.document.form.Rut.focus();
		return;
	}

	if (window.document.form.Dv.value == ""){
		alert("Ingrese digito verificador de cliente");
		window.document.form.Dv.focus();
		return;
	}
	
	if (ValidaRut(window.document.form.Rut.value , window.document.form.Dv.value) == false) {
		alert("Rut ingresado es incorrecto");
		return ;
	}
	
	if (window.document.form.Clave.value == ""){
	 	alert("Ingrese su clave");
		window.document.form.Clave.focus();
		return;	 
	 }
	 
		if (window.document.form.Clave.value != "")
		  {
				var checkStr = window.document.form.Clave.value;
				var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
				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)
								{
									alert('Solo se permiten números y letras en el campo clave.');
									window.document.form.Clave.focus();
									return ;
								}
						}
				}
		
		$('#content-hogar').fadeOut('slow');
		window.document.form.Accion.value=1;		
		window.document.form.target="frame_sistema"
		window.document.form.method="post"
		window.document.form.action="http://wss.metrogas.cl/metrogas_sucursal_enlinea/www/asp/www_login/login.asp";
		window.document.form.submit();
		$('#sis_usuario').fadeIn('slow');
		
}

function ValidaRut(Rut, Digito){
/*AUTOR:  Ariel Manquegual
OBJETIVO: Valida Rut valido
ENTRADA:	
		Rut = valor del rut
		Digito = Digito rut
SALIDA: True si rut valida, False si rut es incorrecta
FECHA CREACION: 04/09/2003
FECHA MODIFICACION: xx/xx/xxxx
MODIFICACION: xxxxxxxxxxxxxxxxxxxxxx
*/
	
	Valor = Rut +"-"+ Digito;
	var checkStr = Valor;
	var ch = '-';
	var hayguion='0';
    var i ;
	if (checkStr == '0-0' || checkStr=='-'){return false;}

	for (ConRut=0 ; ConRut < checkStr.length; ConRut++){
		if (ch == checkStr.charAt(ConRut)){hayguion='1'}
	}

	if (hayguion == '0'){return false;}

	var checkOK = '0123456789-Kk';
	for (ConRut = 0;  ConRut < checkStr.length;  ConRut++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){
			if (ch == checkOK.charAt(j)) break;
		}
		if (j == checkOK.length){
			return false;
			break;
		}
	}

	var largo = checkStr.length;
	var m = 2, r = 0, lar = largo - 3, num;
	
	for (ConRut=lar; ConRut > -1; ConRut--){
		if (ConRut == lar){
			var d = checkStr.charAt(ConRut+2);
			if(d == 'K' ){var d = 10;}
			if(d == 'k' ){var d = 10;}
			if(d == 0 ){var d = 11;}
		}
		
		num = checkStr.charAt(ConRut);
		var r1 = num * m;
		r = r + r1;
		var m2 = m + 1;
		var m = m2;
		if (m == 8){ m = 2;}
	}
	
	var r2 = r % 11;
	var r3 = 11 - r2;
	if (largo > 0){if (d != r3){return false;}}

return true;

}
function validaCliente()
{
	if (window.document.form1.NumeroIC.value == ""){
		alert("Ingrese el nro. de cliente");
		window.document.form1.NumeroIC.focus();
		return;
	}
	
	
	$('#content-hogar').fadeOut('slow');
	window.document.form1.method="post"
	window.document.form1.action="http://wss.metrogas.cl/sitio_pago/acceso_sitio.aspx";
    window.document.form1.target="frame_cliente"
	window.document.form1.submit();
	$('#sis_cliente').fadeIn('slow');
	
}



