function getElement(id) {
    if (document.getElementById(id) != null) return document.getElementById(id);
    else if (document.all != null) return document.all[id];
    else if (document.layers != null) return document.layers[id];
    else return null;
}

function SetVisibility(id, show) {
    getElement(id).style.display = (show ? 'block': 'none');
}

function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if (isNaN(num)) num = "0";
    
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100+0.50000000001);
    cents = num % 100;
    num = Math.floor(num / 100).toString();
    if (cents < 10) cents = "0" + cents;
    
    for (var lup = 0; lup < Math.floor((num.length - (1 + lup)) / 3); lup++) num = num.substring(0 , num.length - (4 * lup + 3)) + ',' + num.substring(num.length - (4 * lup + 3));
    
    return (((sign) ? '' : '-') + num + '.' + cents);
}

