/*
 * @@
 * Funções Padrões 
 * @@
 */

/*
 * @@	
 * Simples Redirecionamento de URL por Paramêtros
 * Utilizado nos eventos OnClick das TR
 * @@
 */
function redireciona(caminho) {
	document.location = caminho;
}

/* @@	
 * Mascaras
 * @@
 */
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function dta(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{2})(\d)/,"$1/$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{2})(\d)/,"$1/$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    return v
}

function soNumeros(v){
    return v.replace(/\D/g,"")
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function FormataMascara(e,src,mask) {
if(window.event) { _TXT = e.keyCode; }
else if(e.which) { _TXT = e.which; }
if(_TXT > 47 && _TXT < 58) {
var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); }
return true; } else { if (_TXT != 8) { return false; }
else { return true; }
}
}

function mascara(o,f){
v_obj=o
v_fun=f
setTimeout("execmascara()",1)
}

function execmascara(){
v_obj.value=v_fun(v_obj.value)
}

function leech(v){
v=v.replace(/o/gi,"0")
v=v.replace(/i/gi,"1")
v=v.replace(/z/gi,"2")
v=v.replace(/e/gi,"3")
v=v.replace(/a/gi,"4")
v=v.replace(/s/gi,"5")
v=v.replace(/t/gi,"7")
return v
}

function soNumeros(v){
return v.replace(/\D/g,"")
}

function Formatadata(Campo, teclapres)
{
var tecla = teclapres.keyCode;
var vr = new String(Campo.value);
vr = vr.replace("/", "");
vr = vr.replace("/", "");
vr = vr.replace("/", "");
tam = vr.length + 1;
if (tecla != 8 && tecla != 8)
{
if (tam > 0 && tam < 2)
Campo.value = vr.substr(0, 2) ;
if (tam > 2 && tam < 4)
Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2);
if (tam > 4 && tam < 7)
Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, 2) + '/' + vr.substr(4, 7);
}
}