﻿function noKeyPress(obj, msg)
{
    alert(msg);
    document.getElementById(obj).value = "";
}

function GotoURL(param){
    eval('window.location.href = ('+"param"+')');
}
function FormatoMoedaUS(valor)
{
  valor = valor.toString(); 
  if(valor=='')  
    return 0;
  
  valor = parseFloat(valor.replace(".","").replace(",","."));
  valor = CCur(valor);
  return valor;
}
function FormatoMoedaBR(valor)
{
  valor = valor.toString();   
  if(valor=='')  
    return 0;

  valor = CCur(valor);
  valor = valor.replace(",","").replace(".",",");
  valor = DotFormatted(valor);
  return valor;
}
function validateEmail(email) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (reg.test(email) == false) {
        return false;
    }
    return true;
}
function CCur(Q)
{
    var i = parseFloat(Q);
    if(isNaN(i)) { i = 0.00; }
    var minus = '';
    if(i < 0) { minus = '-'; }
    i = Math.abs(i);
    i = parseInt((i + .005) * 100);
    i = i / 100;
    s = new String(i);
    if(s.indexOf('.') < 0) { s += '.00'; }
    if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
    s = minus + s;
    return s;
}
String.prototype.trim = function()
{
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function get_cookie(cookie_name) {
    var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');

    if (results)
        return (unescape(results[2]));
    else
        return null;
}


