    //document.write('<div id="loadings">carregando...</div>');

	
	function checkMail(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 VerificaData(Data)
    {
    var Tamanho = Data.length;
        if (Tamanho==10)
        {
             hoje = new Date();
             var DataCorreto = true;
             var anoAtual = hoje.getFullYear();
             var barras = Data.split("/");
                  if (barras.length == 3){
                            var dia = barras[0];
                            var mes = barras[1];
                            var ano = barras[2];
                            var  resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano >= 1900));
                              if (!resultado) 
                              {
                              DataCorreto = false;
                             
                              }
                     } else {
                             DataCorreto = false;
                            
                           }
                
                if (DataCorreto)
                {
                
                  return true;
                
                }else
                {
                  return false;
                }
    
        }
    }
    
    
  
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 telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
   // v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}
 
function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}


function data(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
   v=v.replace(/(\d{4})(\d)/,"$1")
    return v
}
 
function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}
 
function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}
 
function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}
 
function site(v){
    //Esse sem comentarios para que você entenda sozinho ;-)
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?&])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}



function mask(obj,exp,isCur){
	var C=/[a-zA-ZÂ-ÖÙ-Ýà-öù-ýÿ]/;
	var N=/[0-9]/;
	var A=/[a-zA-ZÂ-ÖÙ-Ýà-öù-ýÿ0-9]/;
	var S=/[^a-zA-ZÂ-ÖÙ-Ýà-öù-ýÿ0-9]/;
	var Z=/[.]/;
    //A=toUpperCase(A);
	if(!document.all || !obj) return;
	if(!obj.maxlength||obj.maxLength>exp.length)obj.maxLength=exp.length;
	if(isCur){
		obj.style.textAlign='right';
		obj.onkeyup=maskNumber;
	}else{
		obj.onkeypress=(maskString);
	}
	function maskString(){
		var p=getCaret();
		var k=window.event.keyCode;
		var m=exp.charAt(p);
		if(m!=''){
			var sf = String.fromCharCode(k);
			if('CNASZ'.indexOf(m)!=-1 && !eval(m).test(sf)){
				event.returnValue=false;
			}else{
				if('CNASZ'.indexOf(m)==-1){
					if(obj.value.charAt(p)!=m)
						obj.value=obj.value.substr(0,p)+m+obj.value.substr(p,obj.value.length);
					setCaret(p+1);
					maskString();
				}
			}
		}
	}
	function maskNumber() {
		var negative=(obj.value.indexOf('-') != -1)?1:0;
		var STR=obj.value.replace(/[^0-9]+/gi,'');
		var eL=exp.length-1, vL=STR.length-1, res='', c, m;
		while (vL>=0){
			c = STR.charAt(vL--);
			m = exp.charAt(eL--);
			if (m != 'N' && m != c){
				res = c + m + res;
				eL--;
			}else{
				res = c + res;
			}
		}
		obj.value = ((negative)?'-':'') + res;	
		setCaret(obj.value.length);
	}
	function setCaret(i){
		var r=obj.createTextRange();
		r.moveStart('character',i+1);
		r.moveEnd('character',i-obj.value.length);
		r.select();
	}
	function getCaret(){
		var t=document.selection.createRange().duplicate();
		t.moveEnd('character',obj.value.length);
		return(t.text=='')?obj.value.length:obj.value.lastIndexOf(t.text);
	}
}

function completaNota(obj){
	var val = obj.value;
	if (val.length == 2)
		obj.value += ',0';
}
