/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$(document).ready(function () {

    try {

		if ($('input[name="profile"]').val() != "Empleadores") {
			$("#rut-acceso").blur( function () {
				$("#rut-acceso").val($("#rut-acceso").val().split(".").join(""));
				$('#msgError').html('');
				if ($("#rut-acceso").val() != '') {
					if (!Fn.validaRut($("#rut-acceso").val()))
						$('#msgError').html('El rut ingresado no es válido');
				}
			});
		}
        
    } catch(err) {}

});

function removeZeroes(valor) {
	var result = "";

	if (valor && valor.length > 0) {
		if (valor.charAt(0) == "0") {
			result = valor.substring(1);
			return removeZeroes(result);
		} else {
			result = valor;
		}
	}

	return result;
}


function validar() {

    $("#rut-acceso").val($("#rut-acceso").val().split(".").join(""));

    if ($("#rut-acceso").val() == '') {
        $('#msgError').html('Debe ingresar su Login para poder entrar al Sitio.');
        return false;
    }

    if ($("#clave-acceso").val() == '') {
        $('#msgError').html('Debe ingresar su Clave para poder entrar al Sitio.');
        return false;
    }
	
	$("#rut-acceso").val(removeZeroes($("#rut-acceso").val()));
	$("#rut-acceso").val($("#rut-acceso").val().toUpperCase());
	$("#clave-acceso").val($("#clave-acceso").val().toUpperCase());
	
	$('input[name="login"]').val($("#rut-acceso").val());
	
    return true;

}
