/*
Document   : utilidades.js
Created on : 2009/04/12
Author     : José R. Bobes Bascarán
Description: Librería de utilidades Javascript
*/

// Establece el foco en un elemento
//
// Parametros:
//  idElemento (String): id del elemento
function setFoco(idElemento) {
    if (document.getElementById(idElemento)) {
        document.getElementById(idElemento).focus();
    }
}

function getElementById(idElemento) {
    return document.getElementById(idElemento);
}

function noVacio(valor) {

    if (valor != null && valor != '') {
        return true;
    }
    return false;
}

function redondea(sVal, nDec){
    var n = parseFloat(sVal);
    var s = "0.00";
    if (!isNaN(n)){
     n = Math.round(n * Math.pow(10, nDec)) / Math.pow(10, nDec);
     s = String(n);
     s += (s.indexOf(".") == -1? ".": "") + String(Math.pow(10, nDec)).substr(1);
     s = s.substr(0, s.indexOf(".") + nDec + 1);
    }
    return s;
}

