// JavaScript Document

$(function(){

});

function login() {

	if ($("#usuario").val() == "") {
		$("#usuario")[0].focus();
		return false;
	} else if ($("#clave").val() == "") {
		$("#clave")[0].focus();
		return false;
	} else if ($("#usuario").val().match("^@")) {
		$('#frm_login').ajaxSubmit({ 
			url: '/lda/ajax/json_login.jsp', 
			dataType:  'json', 
			success:   processLogin
		});
		return false;
	} else {
		return true;
	}
	
}

function processLogin(result) {

	if (result.message.length > 0) {
		jAlert(result.message, "Línea Directa Asistencia", function() {
			if (result.nextUrl.length > 0) {
				document.location = result.nextUrl;
			}
			$('#usuario').focus();
		});
	} else {
		if (result.nextUrl.length > 0) {
			document.location = result.nextUrl;
		}
	}
}

function home () {
	var selected = $('#home')[0].selectedIndex;	
	$.getJSON("ajax/json_actualizarConfig.jsp?parametro=home&valor="+selected, function(datos){
		if(datos.exito){			

			document.location = "/";

		}
	});
}
