﻿/*##############################################################################
################################################################################
###  Author: Alejandro "Saynomore" Tuomas                                    ###
###  Date: 27/09/2010                                                        ###
###  Project: SmartProject                                                   ###
################################################################################
##############################################################################*/


function CheckLogin(msgUser, msgPass) {
    var IsEmpty = false;
    var msg = "";
    $('#pnl_message').html(msg);
    if ($("input:text").val() == "") {
        msg = msg + msgUser +"<br />";
        IsEmpty = true;
    }
    if ($("input:password").val() == "") {
        msg = msg + msgPass + "<br />";
        IsEmpty = true;
    }
    $('#pnl_message').html(msg);
    return IsEmpty;
}
function printMessage(texto, ctrl_output) {
    if (texto != '') {
        $('#' + ctrl_output + '').html(texto);
    }
}
function CheckValues(campo, valor) {
    var Ok = true;
    if ($.isArray(campo)) {
        if (campo.length == valor.length) {

            $.each(campo, function(index, value) {
                if (valor[index] == $('#' + value + '').val()) {
                    Ok = false;
                }
            });
        }
        else {
            Ok = false;
        }
        return Ok;
    }
}
function CheckEmpty(campos) {
    var msg = "";
    if ($.isArray(campos)) {
        $.each(campos, function(index, value) {
            var campo = value.substring(value.lastIndexOf("_tb") + 3, value.length);
            alert(campo);
            if ($('#' + value + '').val() == "") {
                msg = msg + $('#val' + campo).text() + "<br />";
            }
        });
    }
    return msg;
}
/*
Recibe un array con los id de los controles a chequear de esta forma: [control1, control2]
comprueba con sus value no esten vacios
devuevle un string tomando de los controles el atributo title (para compatibilidad de idioma)
encerrados en <li></li> para armar una lista que forma el mensaje de campos a completar
*/
function CheckEmptyList(campos) {
    var msg = "";
    if ($.isArray(campos)) {
        $.each(campos, function(index, value) {
            var campo = $('#' + value + '').attr("title");
            if ($('#' + value + '').val() == "") {
                msg = msg + "<li>" + campo + "</li>";
            }
        });
    }
    return msg;
}

