function validarEmail(mail){var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);if(typeof(mail)=="string"){if(er.test(mail)){return true;}}else if(typeof(mail)=="object"){if(er.test(mail.value)){return true;}}else {return false;}}function clkfn(){c--;if(c<0){c=59;b--;if(b<=9)b="0"+b;}if(b=="0-1"){b=59;a--;if(a<=9)a="0"+a;}if(c<=9)c="0"+c;if(a=="0-1"){a="00";b="00";c="00";$("#horaPromocaoAtual").html(a);$("#minutoPromocaoAtual").html(b);$("#segundoPromocaoAtual").html(c);self.location='http://www.regateio.com.br';}else{$("#horaPromocaoAtual").html(a);$("#minutoPromocaoAtual").html(b);$("#segundoPromocaoAtual").html(c);setTimeout('clkfn()',1000);}}function alerta(msg){$(".alerta").hide();$(".alerta").html(msg);$(".alerta").slideDown('normal');setTimeout("$('.alerta').slideUp('normal');",4000);}$(".alerta").live('click',function(){$(".alerta").hide();});
function goAjax(a,b,c) {
	$("#"+c).html("<img src='"+_ROOT+"/img/carregando.gif' style='width:16px;height:16px;' align='absmiddle' /> Aguarde...");
	$.post(_ROOT+"/ajax/"+a+".php",
		   {dados: $("#"+b).serialize()},
		   function(data) {
			   $("#"+c).hide();
			   $("#"+c).html(data);
			   $("#"+c).show();
		   });
}
function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) {
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { 
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;

  
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) {
      if (sMask.charAt(i-1) == "9") {
        return ((nTecla > 47) && (nTecla < 58)); }
      else {
        return true;
      }
    }
    else {
      return true;
    }
}

function number_format( number, decimals, dec_point, thousands_sep ) {
    // %        nota 1: Para 1000.55 retorna com precisão 1 no FF/Opera é 1,000.5, mas no IE é 1,000.6
    // *     exemplo 1: number_format(1234.56);
    // *     retorno 1: '1,235'
    // *     exemplo 2: number_format(1234.56, 2, ',', ' ');
    // *     retorno 2: '1 234,56'
    // *     exemplo 3: number_format(1234.5678, 2, '.', '');
    // *     retorno 3: '1234.57'
    // *     exemplo 4: number_format(67, 2, ',', '.');
    // *     retorno 4: '67,00'
    // *     exemplo 5: number_format(1000);
    // *     retorno 5: '1,000'
    // *     exemplo 6: number_format(67.311, 2);
    // *     retorno 6: '67.31'
 
    var n = number, prec = decimals;
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
    var dec = (typeof dec_point == "undefined") ? '.' : dec_point;
 
    var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
 
    var abs = Math.abs(n).toFixed(prec);
    var _, i;
 
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;
 
        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
 
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }
 
    return s;
}
