Mascaras = {
IsIE: navigator.appName.toLowerCase().indexOf('microsoft')!=-1,
AZ: /[A-Z]/i,
Acentos: /[Ŕ-˙]/i,
Num: /[0-9]/,
carregar: function(parte){
 
 var Tags = ['input','textarea'];
 if (typeof parte == "undefined") parte = document;
 for(var z=0;z<Tags.length;z++){
  Inputs=parte.getElementsByTagName(Tags[z]);
  for(var i=0;i<Inputs.length;i++)
   if(('button,image,hidden,submit,reset').indexOf(Inputs[i].type.toLowerCase())==-1)
    this.aplicar(Inputs[i]);
 }
},
aplicar: function(campo){
 tipo = campo.getAttribute('tipo');
 if (!tipo || campo.type == "select-one") return;
 orientacao = campo.getAttribute('orientacao');
 mascara = campo.getAttribute('mascara');
 if (tipo.toLowerCase() == "decimal"){
  orientacao = "esquerda";
  casasdecimais = campo.getAttribute('casasdecimais');
  tamanho = campo.getAttribute('maxLength');
  if (!tamanho || tamanho > 50)
   tamanho = 10;
  if (!casasdecimais)
   casasdecimais = 2;
  campo.setAttribute("mascara", this.geraMascaraDecimal(tamanho, casasdecimais));
  campo.setAttribute("tipo", "numerico");
  campo.setAttribute("orientacao", orientacao);
 }
 if (orientacao && orientacao.toLowerCase() == "esquerda") campo.style.textAlign = "right";
 if (mascara) campo.setAttribute("maxLength", mascara.length);
 if (tipo){
  campo.onkeypress = function(e){ return Mascaras.onkeypress(e?e:event); };
  campo.onkeyup = function(e){ Mascaras.onkeyup(e?e:event, campo) };
 }
 campo.setAttribute("snegativo", ((campo.value).substr(0,1) == "-" ? "s" : "n"));
},
onkeypress: function(e){
 KeyCode = this.IsIE ? event.keyCode : e.which;
 campo =  this.IsIE ? event.srcElement : e.target;
 readonly = campo.getAttribute('readonly');
// alert(event.keyCode);
 if (event.keyCode==13){
//	event.keyCode = 9;
	return true
 }
 if (readonly) return;
 maxlength = campo.getAttribute('maxlength');
 pt = campo.getAttribute('pt');
 selecao = this.selecao(campo);
 if (selecao.length > 0 && KeyCode != 0){
  campo.value = ""; return true;
 }
 if (KeyCode == 0) return true;
 Char = String.fromCharCode(KeyCode);
 valor = campo.value;
 mascara = campo.getAttribute('mascara');
 if (KeyCode != 8){
  tipo = campo.getAttribute('tipo').toLowerCase();
  negativo = campo.getAttribute('negativo');
  if(negativo && KeyCode == 45){
   snegativo = campo.getAttribute('snegativo');
   snegativo = (snegativo == "s" ? "n" : "s");
   campo.setAttribute("snegativo", snegativo);
  }else{
   valor += Char
   if (tipo == "numerico" && Char.search(this.Num) == -1) return false;
   if (KeyCode != 32 && tipo == "caracter" && Char.search(this.AZ) == -1 && Char.search(this.Acentos) == -1) return false;
  }
 }
 if (mascara){
  this.aplicarMascara(campo, valor);
  return false;
 }
 return true;
},
onkeyup: function(e, campo){
 KeyCode = this.IsIE ? event.keyCode : e.which;

 if (KeyCode != 9 && KeyCode != 16 && KeyCode != 109){
  valor = campo.value;
  if (KeyCode == 8 && !this.IsIE) valor = valor.substr(0,valor.length-1);
  this.aplicarMascara(campo, valor);
 }
},
aplicarMascara: function(campo, valor){
 mascara = campo.getAttribute('mascara');
 if (!mascara) return;
 negativo = campo.getAttribute('negativo');
 snegativo = campo.getAttribute('snegativo');
 if (negativo && valor.substr(0,1) == "-") 
  valor = valor.substr(1,valor.length-1);
 orientacao = campo.getAttribute('orientacao');
 var i = 0;
 for(i=0;i<mascara.length;i++){
  caracter = mascara.substr(i,1);
  if (caracter != "#") valor = valor.replace(caracter, "");
 }
 retorno = "";
 if (orientacao != "esquerda"){
  contador = 0;
  for(i=0;i<mascara.length;i++){
   caracter = mascara.substr(i,1);
   if (caracter == "#"){
    retorno += valor.substr(contador,1);
    contador++;
   }else
    retorno += caracter;
   if(contador >= valor.length) break;
  }
 }else{
  contador = valor.length-1;
  for(i=mascara.length-1;i>=0;i--){
   if(contador < 0) break;
   caracter = mascara.substr(i,1);
   if (caracter == "#"){
    retorno = valor.substr(contador,1) + retorno;
    contador--;
   }else
    retorno = caracter + retorno;
  }
 }
 if (negativo && snegativo == "s")
  retorno = "-" + retorno;
 campo.value = retorno;
},
geraMascaraDecimal: function(tam, decimais){
 var retorno = ""; var contador = 0; var i = 0;
 decimais = parseInt(decimais);
 for (i=0;i<(tam-(decimais+1));i++){
  retorno = "#" + retorno;
  contador++;
  if (contador == 3){
   retorno = "." + retorno;
   contador=0;
  }
 }
 retorno = retorno + ",";
 for (i=0;i<decimais;i++) retorno += "#";
 return retorno;
},
selecao: function(campo){
 if (this.IsIE)
  return document.selection.createRange().text;
 else
  return (campo.value).substr(campo.selectionStart, (campo.selectionEnd - campo.selectionStart));
},
formataValor: function (valor, decimais){
 valor = valor.split('.');
 if (valor.length == 1) valor[1] = "";
 for(var i=valor[1].length;i<decimais;i++)
  valor[1] += "0"; 
 valor[1] = valor[1].substr(0,2);
 return (valor[0] + "." + valor[1]);
}
};


function sair(){

	if (confirm("Deseja realmente sair do sistema?")==1){
		window.open('sair.asp','_self')
	}

}

function jwindow(url) {
  w = 800
  h = 600
  t = (screen.height / 2) -  (h / 2)
  l = (screen.width /2) - (w / 2)
var newWindow= window.open(url,"frmjwindow","toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=yes, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);
 }
 

function janela(rel) {
  w = 710
  h = 441
  t = (screen.height / 2) -  (h / 2)
  l = (screen.width /2) - (w / 2)
var newWindow= window.open("rel.asp?rel="+rel,"frmrel","toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=yes, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);
 }

function janela1(rel) {
  w = 710
  h = 441
  t = (screen.height / 2) -  (h / 2)
  l = (screen.width /2) - (w / 2)
var newWindow= window.open("rel.asp?rel="+rel,"frmrel","toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=yes, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);
 }

function janelapeq(rel) {
  w = 600
  h = 350
  t = (screen.height / 2) -  (h / 2)
  l = (screen.width /2) - (w / 2)
var newWindow= window.open(rel,"frmpeq","toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=yes, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);
 }
function janelapeqconta(rel) {
  w = 800
  h = 550
  t = (screen.height / 2) -  (h / 2)
  l = (screen.width /2) - (w / 2)
var newWindow= window.open(rel,"frmpeq","toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=yes, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);
 }

function jp(url, x, y) {
  w = x
  h = y
  t = (screen.height / 2) -  (h / 2)
  l = (screen.width /2) - (w / 2)
var newWindow= window.open(url,"frmjp","toolbar=no, location=no, directories=no, status=yes,menubar=no,scrollbars=no, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);
 }

function backup(){

msg = "Caro usuário\nEste processo deve demorar um pouco\n\nDeseja continuar?";

	if (confirm(msg) == 01){
		window.open('backup.asp','_self');
	}

}

function InStr(n, s1, s2){
	// Devuelve la posición de la primera ocurrencia de s2 en s1
	// Si se especifica n, se empezará a comprobar desde esa posición
	// Sino se especifica, los dos parámetros serán las cadenas
	var numargs=InStr.arguments.length;	
	if(numargs<3)
		return n.indexOf(s1)+1;
	else
		return s1.indexOf(s2, n)+1;
}
function dataloga(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new 
Array("Domingo","Segunda-Feira","Ter&ccedil;a-Feira","Quarta-Feira","Quinta-Feira","Sexta-Feira","S&aacute;bado")
var montharray=new 
Array("Janeiro","Fevereiro","Mar&ccedil;o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro")
document.write(""+dayarray[day]+", "+daym+" de "+montharray[month]+" de "+year+"")
}

function writeclock() {
	i_clock++
	if (document.all || document.getElementById || document.layers) {
		clockid[i_clock]="clock"+i_clock
		document.write("<span id='"+clockid[i_clock]+"' style='position:relative'>"+thistime+"</span>")
	}
}

function clockon() {
	thistime= new Date()
	hours=thistime.getHours()
	minutes=thistime.getMinutes()
	seconds=thistime.getSeconds()
	if (eval(hours) <10) {hours="0"+hours}
	if (eval(minutes) < 10) {minutes="0"+minutes}
	if (seconds < 10) {seconds="0"+seconds}
	thistime = hours+":"+minutes+":"+seconds
		
	if (document.all) {
		for (i=0;i<=clockid.length-1;i++) {
			var thisclock=eval(clockid[i])
			thisclock.innerHTML=thistime
		}
	}
	
	if (document.getElementById) {
		for (i=0;i<=clockid.length-1;i++) {
			document.getElementById(clockid[i]).innerHTML=thistime
		}
	}
	var timer=setTimeout("clockon()",1000)
}

function trocarsenha(){

w = 500
h = 350
t = (screen.height / 2) -  (h / 2)
l = (screen.width /2) - (w / 2)

var newWindow= window.open("trocasenha.asp","frmrel","toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=yes, resizable=no, copyhistory=no, width="+w+",height="+h+",top="+t+",left="+l);


}


function ajax(url, metodo, modo, tagId, parametros)
{
	
    goAjax( url+"?"+parametros+"&rnd"+ Math.random() , metodo, modo , tagId);
    if (tagId == ''){
		return retornoajax
    }
}

function goAjax(url, metodo, modo, tagRetorno, parametros) {
	
	rajax = ''
	
    if (tagRetorno != ''){
		document.getElementById(tagRetorno).innerHTML='<div align="center" class="carregando"><font size="2" face="Trebuchet MS"><img src="./Imagens/aguardando2.gif"><br><br>carregando...<br>&nbsp;</div>'
	}
	
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp=false;
		}
	}
	 
    if(metodo == "GET") {
        xmlhttp.open("GET", url, modo);
    } else {        
        xmlhttp.open("POST", url, modo);
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
        xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        xmlhttp.setRequestHeader("Pragma", "no-cache");
    }    
    
    
    
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState == 4) {
            retornoajax=xmlhttp.responseText
            if (tagRetorno != ''){
				document.getElementById(tagRetorno).innerHTML=retornoajax
			}else{
				//alert(retorno);
			}
			//alert(retornoajax)
			rajax = retornoajax
			return retornoajax
            //findScript(retorno)
        }
    }
    if(metodo == "GET") {
        xmlhttp.send(null);
    } else {        
        xmlhttp.send(parametros);
    }
    //alert(retornoajax);
    if (tagRetorno != ''){
		return rajax 
		//retornoajax
    }
}

function pause( milliseconds )
{
var date = new Date();
var curDate = null;
do
{ curDate = new Date(); }
while( curDate - date < milliseconds );
}

var clockid=new Array()
var clockidoutside=new Array()
var i_clock=-1
var thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
if (eval(hours) <10) {hours="0"+hours}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
var thistime = hours+":"+minutes+":"+seconds
var retornoajax = 'xx';
