	//TROCA COR OVER OUT
	function corOverOut(alvo,estilo) {
		document.getElementById(alvo).className=estilo;
	}
	
	// Oculta/Exibe Boxes
	function ocultaBox(box){
		getObj(box).className = 'ocultaBox';
	}
	
	function exibeBox(box){
		getObj(box).className = '';
	}
	// fim oculta/exibe boxes

	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	function nome_janela(nome) {
		self.name = nome;
	}
	
	function fechar() {
		window.close()
	}
	
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
	
	function apagatxt(txtbox) {
		txtbox.value = '';
	}
	
	function rotulotxt(txtbox,txt) {
		if (txtbox.value == ''){
			txtbox.value = txt;
		}
	}
	
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}
	
	function retorna() {
		history.go(-1);
	}
	//-->
	
	function direciona(destino){
		document.location.href = destino;
	}

	function AbrePopUp(url, nomeJanela, extras){
		window.open(url, nomeJanela, extras);
	}
	
	function fechaJanelasLogoff(){
		inicio.close();	
	}
	
	function showHide(rowIndex, idImg, imgOn, imgOff) {
		var table = document.getElementById(rowIndex);
		
		if (table.style.display == 'none'){
			table.style.display = '';
			
			if (idImg != ''){
				var img = document.getElementById(idImg);
				img.src = imgOn;
			}
		}
		else{
			table.style.display = 'none';
			
			if (idImg != ''){
				var img = document.getElementById(idImg);
				img.src = imgOff;
			}
		}
	}
	
	function hide(rowIndex){
		var table = document.getElementById(rowIndex);
		
		table.style.display = 'none';
	}
	
	function getObj(idObj){
		return document.getElementById(idObj);
	}
	
	function campo_numerico(){
		if (event.keyCode < 45 || event.keyCode > 57 || event.keyCode == 46)
			event.returnValue = false;
	}

	function currencyFormat(fld, milSep, decSep, e) {
		var sep = 0;
		var key = '';
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		
		if (whichCode == 13) return true;  // Enter
		if (whichCode == 8) return true;  // Delete (Bug fixed)
		
		key = String.fromCharCode(whichCode);  // Get key value from key code
		
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
		
		len = fld.value.length;
		
		for(i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
		
		aux = '';
		
		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
		
		aux += key;
		len = aux.length;
		
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		
		if (len > 2) {
			aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--) {
				if (j == 3) {
					aux2 += milSep;
					j = 0;
				}
				aux2 += aux.charAt(i);
				j++;
			}
			
			fld.value = '';
			len2 = aux2.length;
			
			for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
			
			fld.value += decSep + aux.substr(len - 2, len);
		}
		
		return false;
	}

    function CheckAll(e){
        try{var element = e.target;         }catch(er){};
        try{var element = event.srcElement; }catch(er){};
        
        if (element.checked){
            var arrayElements = document.getElementsByTagName('input');
            
            for(var i=0; i<arrayElements.length; i++){
                if (arrayElements[i].type == 'checkbox'){                    
                    arrayElements[i].checked = true;
                }
            }
        }
		else{
            var arrayElements = document.getElementsByTagName('input');
            
            for(var i=0; i<arrayElements.length; i++){
                if (arrayElements[i].type == 'checkbox'){                    
                    arrayElements[i].checked = false;
                }
            }
		}
    }	

	function currencyFormat(fld, milSep, decSep, e) {
		var sep = 0;
		var key = '';
		var i = j = 0;
		var len = len2 = 0;
		var strCheck = '0123456789';
		var aux = aux2 = '';
		var whichCode = (window.Event) ? e.which : e.keyCode;
		
		if (whichCode == 13) return true;  // Enter
		if (whichCode == 8) return true;  // Delete (Bug fixed)
		
		key = String.fromCharCode(whichCode);  // Get key value from key code
		
		if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
		
		len = fld.value.length;
		
		for(i = 0; i < len; i++)
			if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
		
		aux = '';
		
		for(; i < len; i++)
			if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
		
		aux += key;
		len = aux.length;
		
		if (len == 0) fld.value = '';
		if (len == 1) fld.value = '0'+ decSep + '0' + aux;
		if (len == 2) fld.value = '0'+ decSep + aux;
		
		if (len > 2) {
			aux2 = '';
			for (j = 0, i = len - 3; i >= 0; i--) {
				if (j == 3) {
					aux2 += milSep;
					j = 0;
				}
				aux2 += aux.charAt(i);
				j++;
			}
			
			fld.value = '';
			len2 = aux2.length;
			
			for (i = len2 - 1; i >= 0; i--)
				fld.value += aux2.charAt(i);
			
			fld.value += decSep + aux.substr(len - 2, len);
		}
		
		return false;
	}
	
	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;
			}
	}
	

// MÁSCARAS FORMULÁRIO
// O CARACTER '#' DEFINE QUE SÓ SERÁ PERMITIDO NÚMEROS
// O CARACTER '!' DEFINE QUE É PERMITIDO QUALQUER CARACTER
//
// Uso:
// <input type="text" name="cep" id="telefone" onKeyPress="return formata(this, '#####-###', event)"> // formata o campo para cep
//

function formata(campo, mask, evt) { 
  
 if(document.all) { // Internet Explorer 
    key = evt.keyCode; } 
    else{ // Nestcape 
       key = evt.which; 
     } 

 string = campo.value;  
 i = string.length;

 if (i < mask.length) {
  if (mask.charAt(i) == '#') {
       return (key > 47 && key < 58);
      } else {
       if (mask.charAt(i) == '!') {  return true;  }
   for (c = i; c < mask.length; c++) {
         if (mask.charAt(c) != '#' && mask.charAt(c) != '!')
         campo.value = campo.value + mask.charAt(c);
      else if (mask.charAt(c) == '!'){
                return true;
       } else {
         return (key > 47 && key < 58);
          }
       }
    }
  } else return false;
}

// FIM MÁSCARAS FORMULÁRIOS

	//altera tamanho da fonte
	var fs = new Array( '12px','14px','16px','18px','20px','22px' );
	
	var contador = 0;
	function tamanhoFonte(x, obj){
		if(x == 0){
			if(contador < fs.length - 1){
				contador++;
				getObj(obj).style.fontSize = fs[contador];
				getObj(obj).style.lineHeight = fs[contador];			
			}
		}
		if(x == 1){
			if(contador > 0){	
				contador--;
				getObj(obj).style.fontSize = fs[contador];
				getObj(obj).style.lineHeight = fs[contador];			
			}
		}
	}
	//fim altera tamanho da fonte
	
// JavaScript Document
/*	********************************************************************	
	####################################################################
	Assunto = Validação de CPF e CNPJ
	Autor = Marcos Regis
	Data = 24/01/2006
	Versão = 1.0
	Compatibilidade = Todos os navegadores.
	Pode ser usado e distribuído desde que esta linhas sejam mantidas
	====------------------------------------------------------------====
	
	Funcionamento = O script recebe como parâmetro um objeto por isso 
	deve ser chamado da seguinte forma:
	E.: no evento onBlur de um campo texto
	<input name="cpf_cnpj" type="text" size="40" maxlength="18" 
	onBlur="validarCpfCnpj(this);">
	Ao deixar o campo o evento é disparado e chama validar() com o 
	argumento "this" que representa o próprio objeto com todas as 
	propriedades.
	A partir daí a função validar() trata a entrada removendo tudo que
	não for caracter numérico e deixando apenas números, portanto
	valores escritos só com números ou com separadores como '.' ou mesmo
	espaços são aceitos
	ex.: 111222333/44, 111.222.333-44, 111 222 333 44 serão tratadoc como
	11122233344 (para CPFs)
	De certa forma até mesmo valores como 111A222B333C44 será aceito mas
	aconselho a usar a função soNums() que encotra-se aqui mesmo para
	que o campo só aceite caracteres numéricos.
	Para usar a função soNums() chame-a no evento onKeyPress desta forma
	onKeyPress="return soNums(event);"
	Após limpar o valor verificamos seu tamanho que deve ser ou 11 ou 14
	Se o tamanho não for aceito a função retorna false e [opcional] 
	mostra uma mensagem de erro.
	Sugestões e comentários marcos_regis@hotmail.com
	####################################################################
	********************************************************************	*/

// a função principal de validação
function validarCpfCnpj(obj) { // recebe um objeto
	var s = (obj.value).replace(/\D/g,'');
	var tam=(s).length; // removendo os caracteres não numéricos
	
	if ((tam > 0 && tam < 11) || (tam > 11 && tam < 14)){ // validando o tamanho
		obj.className = 'inputErro';
		obj.focus();
		
		return false;
	}
	
	if (!(tam==11 || tam==14)){ // validando o tamanho
		return false;
	}
	
// se for CPF
	if (tam==11 ){
		if (!validaCPF(s)){ // chama a função que valida o CPF
			obj.className = 'inputErro';
			obj.focus();
			return false;
		}
		obj.value=maskCPF(s);	// se validou o CPF mascaramos corretamente
		return true;
	}
	
// se for CNPJ			
	if (tam==14){
		if(!validaCNPJ(s)){ // chama a função que valida o CNPJ
			obj.className = 'inputErro';
			obj.focus();
			return false;			
		}
		obj.value=maskCNPJ(s);	// se validou o CNPJ mascaramos corretamente
		return true;
	}
}
// fim da funcao validar()

// função que valida CPF
// O algorítimo de validação de CPF é baseado em cálculos
// para o dígito verificador (os dois últimos)
// Não entrarei em detalhes de como funciona
function validaCPF(s) {
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (var i=0; i<9; i++) {
		d1 += c.charAt(i)*(10-i);
 	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1){
		return false;
	}
	d1 *= 2;
	for (var i = 0; i < 9; i++)	{
 		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1){
		return false;
	}
    return true;
}

// Função que valida CNPJ
// O algorítimo de validação de CNPJ é baseado em cálculos
// para o dígito verificador (os dois últimos)
// Não entrarei em detalhes de como funciona
function validaCNPJ(CNPJ) {
	var a = new Array();
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++){
		a[i] = CNPJ.charAt(i);
		b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	b = 0;
	for (y=0; y<13; y++) {
		b += (a[y] * c[y]);
	}
	if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
		return false;
	}
	return true;
}


	// Função que permite apenas teclas numéricas
	// Deve ser chamada no evento onKeyPress desta forma
	// return (soNums(event));
function soNums(e)
{
	if (document.all){var evt=event.keyCode;}
	else{var evt = e.charCode;}
	if (evt <20 || (evt >47 && evt<58)){return true;}
	return false;
}

//	função que mascara o CPF
function maskCPF(CPF){
	return CPF.substring(0,3)+"."+CPF.substring(3,6)+"."+CPF.substring(6,9)+"-"+CPF.substring(9,11);
}

//	função que mascara o CNPJ
function maskCNPJ(CNPJ){
	return CNPJ.substring(0,2)+"."+CNPJ.substring(2,5)+"."+CNPJ.substring(5,8)+"/"+CNPJ.substring(8,12)+"-"+CNPJ.substring(12,14);	
}

function geraLoading(msg){
	return '<p align="center" class="txtAzulEscuro10px"><img src="../imagens/carregando3.gif" align="absmiddle" />&nbsp;' + msg + '</p>';
}

var NUM_DIGITOS_CNPJ = 14;
var NUM_DIGITOS_CPF  = 11;


String.prototype.lpad = function(pSize, pCharPad)
{
	var str = this;
	var dif = pSize - str.length;
	var ch = String(pCharPad).charAt(0);
	for (; dif>0; dif--) str = ch + str;
	return (str);
} 



String.prototype.trim = function()
{
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
} 
function unformatNumber(pNum)
{
	return String(pNum).replace(/\D/g, "").replace(/^0+/, "");
} 

function formatCpfCnpj(pCpfCnpj, pUseSepar, pIsCnpj)
{
	if (pIsCnpj==null) pIsCnpj = false;
	if (pUseSepar==null) pUseSepar = true;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var numero = unformatNumber(pCpfCnpj);

	numero = numero.lpad(maxDigitos, '0');
	if (!pUseSepar) return numero;

	if (pIsCnpj)
	{
		reCnpj = /(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/;
		numero = numero.replace(reCnpj, "$1.$2.$3/$4-$5");
	}
	else
	{
		reCpf  = /(\d{3})(\d{3})(\d{3})(\d{2})$/;
		numero = numero.replace(reCpf, "$1.$2.$3-$4");
	}
	return numero;
} 

function dvCpfCnpj(pBase, pIsCnpj)
{
	if (pIsCnpj==null) pIsCnpj = false;
	var i, j, k, soma, dv;
	var cicloPeso = pIsCnpj? 8: NUM_DIGITOS_CPF;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var calculado = formatCpfCnpj(pBase, false, pIsCnpj);
	calculado = calculado.substring(2, maxDigitos);
	var result = "";

	for(j = 1; j <= 2; j++)
	{
		k = 2;
		soma = 0;
		for (i = calculado.length-1; i >= 0; i--)
		{
			soma += (calculado.charAt(i) - '0') * k;
			k = (k-1) % cicloPeso + 2;
		}
		dv = 11 - soma % 11;
		if (dv > 9) dv = 0;
		calculado += dv;
		result += dv
	}

	return result;
} 

function isCpf(pCpf,alerta)
{
	var numero = formatCpfCnpj(pCpf, false, false);
	var base = numero.substring(0, numero.length - 2);
	var digitos = dvCpfCnpj(base, false);
	var algUnico, i;


	if (numero != base + digitos)
	{
		alert(alerta);
		return false;
	}


	algUnico = true;
	for (i=1; i<NUM_DIGITOS_CPF; i++)
	{
		algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
	}
	
	return (!algUnico);
	
} 


function isCnpj(pCnpj,alerta)
{
	var numero = formatCpfCnpj(pCnpj, false, true);
	var base = numero.substring(0, 8);
	var ordem = numero.substring(8, 12);
	var digitos = dvCpfCnpj(base + ordem, true);
	var algUnico;

	if (numero != base + ordem + digitos)
	{
		alert(alerta);
		return false;
	}

	algUnico = numero.charAt(0) != '0';
	for (i=1; i<8; i++)
	{
		algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
	}
	if (algUnico) return false;

	if (ordem == "0000") return false;
	return (base == "00000000"
		|| parseInt(ordem, 10) <= 300 || base.substring(0, 3) != "000");
} 

function isCpfCnpj(pCpfCnpj)
{
	var numero = pCpfCnpj.replace(/\D/g, "");
	if (numero.length > NUM_DIGITOS_CPF)
		return isCnpj(pCpfCnpj)
	else
		return isCpf(pCpfCnpj);
} 

// FILTRO DE NÚMEROS
function valida_numeros(s)
{
	var i; 
	var dif = 0;
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (!((c >= "0") && (c <= "9")||(c == ".")||(c == ",")||(c == "-")))
		{
			dif = 1;
		}
	}
	if (dif == 1)
	{
		return false;
	}
	return true;
}  

function valida_numeros_moeda(s,alerta)
{
	var i; 
	var dif = 0;
	for (i = 0; i < s.value.length; i++)
	{
		var c = s.value.charAt(i);
		if (!((c >= "0") && (c <= "9")||(c == ",")))
		{
			dif = 1;
		}
	}
	if (dif == 1)
	{
		alert(alerta);
		s.focus();
		return true;
	}
	//alert(alerta);
	return false;
	
} 

function formata_a_moeda(campo) {
	if (campo.indexOf(",",0) == -1 && campo.indexOf(".",0) == -1){
		campo = campo + ",00" ;
		return campo ;
	} else  {
		if (campo.indexOf(".",0) != -1) {
			decimal = campo.substring(campo.indexOf(".",0)+1,campo.length)
		}
		if (campo.indexOf(",",0) != -1) {
			decimal = campo.substring(campo.indexOf(",",0)+1,campo.length)
		}
		if (decimal.length == 1 && decimal != 0) {
			campo = eval(campo) + "0" ;
		} 
		if (decimal.length == 1 && decimal == 0) {
			campo = campo + "0" ;
		} 
		if (decimal.length == 0 && decimal == 0) {
			campo = campo + "00" ;
		} 
		return campo ;
	}
}

function valida_numeros_cpf(s,alerta)
{
	var i; 
	var dif = 0;
	for (i = 0; i < s.value.length; i++)
	{
		var c = s.value.charAt(i);
		if (!((c >= "0") && (c <= "9")||(c == ".")||(c == "/")||(c == "-")))
		{
			dif = 1;
		}
	}
	if (dif == 1)
	{
		alert(alerta);
		s.focus();
		return true;
	}
	//alert(alerta);
	return false;
	
} 

function valida_numeros_apenas(s,alerta)
{
	var i; 
	var dif = 0;
	for (i = 0; i < s.value.length; i++)
	{
		var c = s.value.charAt(i);
		if (!((c >= "0") && (c <= "9")))
		{
			dif = 1;
		}
	}
	if (dif == 1)
	{
		alert(alerta);
		s.focus();
		return true;
	}
	//alert(alerta);
	return false;
	
} 

function valida_letra_apenas(s,alerta)
{
	var i; 
	var dif = 0;
	for (i = 0; i < s.value.length; i++)
	{
		var c = s.value.charAt(i);
		if (((c >= "0") && (c <= "9")))
		{
			dif = 1;
		}
	}
	if (dif == 1)
	{
		alert(alerta);
		s.focus();
		return true;
	}
	//alert(alerta);
	return false;
	
} 


// QUANTIDADE NO CAMPO
function conta_espaco(campo,num1,num2,alerta)
{
	var dif_new=0;
	var i;
	for (i = num1; i <= num2; i++)
	{
		if (campo.value.length == i)
			{dif_new=1}
	}
	if (dif_new != 1)
	{
		alert(alerta);
		campo.focus();
		return true;
	}
}

// LIMITA VALOES
function entre_numeros(campo,num1,num2,alerta)
{
	if (campo.value<num1 || campo.value>num2)
	{
		alert(alerta);
		campo.focus();
		return true;
	}
}

// DATA DE SAIDA MAIOR QUE A DATA DE ENTRADA
function saida_menor(dia1,mes1,ano1,dia2,mes2,ano2,alerta)
{
	if (ano2.value<ano1.value)
	{
		alert(alerta);
		ano2.focus();
		return true;
	}
	else
	{
		if (ano2.value==ano1.value)
		{
			if (mes2.value<mes1.value)
			{
				alert(alerta);
				mes2.focus();
				return true;
			}
			else
			{
				if (mes2.value==mes1.value)
				{
					if (dia2.value<dia1.value)
					{
						alert(alerta);
						dia2.focus();
						return true;
					}
				}
			}
		}
	}
}

// PASSA CAMPO
function passa_campo(campo1,campo2,limite)
{
	if (campo1.value.length>=limite)
	{
		campo2.focus();
		return true;
	}
}

// CONFERE INVALIDOS CARCTERES
function problema(campo)
{
	invalidChars = "~"
	for (i=0; i<invalidChars.length; i++)
	{
		badChar = invalidChars.charAt(i)
		if (campo.value.indexOf(badChar) != -1)
		{
			//alert(mens2+badChar+mens2A)
			campo.select();
			return true;
		}
	}	
}

// CONFERE FORMULÁRIOS MOEDA
function confere_moeda (campo)
{
	if (campo.value.indexOf(".")!=-1)
	{
		alert("Não é necessário inserir pontos.\nCaso esteja usando para separar os centavos, substitua o '.'(ponto) por ','(vírgula).");
		campo.focus();
		return true;
		return;
	}
	if (campo.value.indexOf(",")==-1)
	{
		alert("Ponha a vírgula e depois os centavos. Ex: ',00'.");
		campo.focus();
		return true;
		return;
	}
	pos01=campo.value.indexOf(",")+1
	str=campo.value.substring(pos01,campo.value.length)
	if (str.indexOf(",")!=-1)
	{
		alert("Não é permitido mais que 01 vírgula no preço.");
		campo.focus();
		return true;
		return;
	}
}


// CONFERE FORMULÁRIOS SEM FOCUS
function confereSemFocus(campo,alerta)
{
	if (campo.value == "")
	{
		alert(alerta);
		return true;
		return;
	}
	if (problema(campo) == true)
	{
		alert(alerta+" com caracteres válidos.");
		return true;
		return;
	}
}

// CONFERE FORMULÁRIOS
function confere (campo,alerta)
{
	if (campo.value == "")
	{
		alert(alerta);
		campo.focus();
		return true;
		return;
	}
	if (problema(campo) == true)
	{
		alert(alerta+" com caracteres válidos.");
		campo.focus();
		return true;
		return;
	}
}

// CONFERE DOIS CAMPOS
function confereCampos(campo, campo2, alerta)
{
	if (campo.value == "" && campo2.value == "")
	{
		alert(alerta);
		return true;
		return;
	}
}

function confere_0 (campo,alerta)
{
	if (campo.value.length == 0)	{
		alert(alerta);
		campo.focus();
		return true;
		return;
	}
}

// COMPARA CAMPOS
function compara (campo1,campo2,alerta)
{
	if (campo1.value != campo2.value)
	{
		alert(alerta);
		campo2.focus();
		return true;
		return;
	}
}

// CONFERE E-MAIL
function conferemail (campo)
{
	mens1="Por favor, coloque o seu e-mail. Você precisará dele para acessar o acesso restrito."
	mens2="Caracter "
	mens2A=" inválido no seu e-Mail."
	mens2c="Carater inválido na sua senha."
	mens3="O e-mail digitado deve possuir @"
	mens4="Mais de uma @ no seu e-Mail"
	mens5="O '.' não pode estar logo após a @ "
	mens6="Por favor, confira o seu e-mail, deve haver pelo menos um '.' após a '@'."
	mens7="Por favor, confira o seu e-mail, deve haver algum complemento após o primeiro ponto (exemplo@nomedosite.com)."
	mens10="e-Mails não podem ter espaços."
	if (campo.value=="")
	{
	  alert(mens1);
	  campo.select();
	  return true;
	}
	invalidChars = "/:,;><^~{}]='%\"[¨&*|+()"
	for (i=0; i<invalidChars.length; i++)
	{
	badChar = invalidChars.charAt(i)
	
	if (campo.value.indexOf(badChar) != -1)
	
	{
	  alert(mens2+badChar+mens2A)
	  campo.select();
	  return true;
	}
	}		
	atPos = campo.value.indexOf("@")
	if (atPos == -1)
	{
	alert(mens3);
	  campo.select();
	  return true;
	}
	x = campo.value.indexOf("@");
	variavel = campo.value;
	aux_email = variavel.substring(x+1,variavel.length);
	if ( aux_email.indexOf("@") != -1)
	{
	alert(mens4);
	  campo.select();
	 return true;
	}
	
	x = campo.value.indexOf("@");
	variavel = campo.value;
	aux_email = variavel.substring(x+1,x+2);
	if ( aux_email == ".")
	{
	alert(mens5);
	  campo.select();
	  return true;
	}
	
	x = campo.value.indexOf(" ");
	if ( x != "-1")
	{
	alert(mens10);
	  campo.select();
	  return true;
	}
	
	periodPos = campo.value.indexOf(".",atPos)
	if (periodPos == -1)
	{
	alert(mens6);
	  campo.select();
	  return true;
	}
	if (periodPos+3 > campo.value.length)
	{
	alert(mens7);
	  campo.select();
	  return true;
	}
}
	
// TROCA IMAGEM
function muda_img(qual,para) {
	document.getElementById(qual).src=para;
}

// MUDA FORM
function muda_form(acao,quem) {
	if (acao == "ativa") {
		quem.style.backgroundColor = "#EDEDED" ;
	} else {
		quem.style.backgroundColor = "#FFFFFF" ;
	}
}

// TIRA SEU E-MAIL
function esvazia(quem) {
	if (quem.value == "seu e-mail" || quem.value == "senha") {
		quem.value = "" ;
	} 
}

// TROCA COR 
function troca_cor(dequem,qualcor) {
	document.getElementById(dequem).style.backgroundColor=qualcor;
}

// ABRE POP-UP
function abre_a_foto(pagina,nome,sb,larg,altu) {
	window.open(pagina,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+sb+",width="+larg+",height="+altu)
}

// AUMENTAR / DIMINUIR - CAIXA DE TEXTO
function alter_box_height(boxid, pixelvalue)
{
	var box = fetch_object(boxid);
	var boxheight = parseInt(box.style.height);
	var newheight = boxheight + pixelvalue;
	if (newheight > 0)
	{
		box.style.height = newheight + "px";
	}
	return false;
}

function posBg(local) {
	if (document.body.clientWidth > 777) {
		posEsq = (document.body.clientWidth - 777) / 2 ;
		document.getElementById("conInternoEsq").style.left = posEsq - 250;
		document.getElementById("conInternoDir").style.left = posEsq + 776 ;
		document.getElementById("conInternoDir").style.width = posEsq + "px";
	}

}

// AJAX
function createXMLHttpRequest() {
   try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){}
   try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
   try{ return new XMLHttpRequest(); }catch(e){}
   alert("XMLHttpRequest not supported");
   return null;
}

var xmlhttp = createXMLHttpRequest();

function loadXMLDoc(url,funcao) {
	if (window.XMLHttpxmlhttpuest) {
		xmlhttp = new XMLHttpxmlhttpuest();
	} else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = funcao;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

function cadastraFaleConosco() {
	if (xmlhttp.readyState==4) {
		if (xmlhttp.status==200) {
			var txt = xmlhttp.responseText;
			window.location.href = txt ;
			
		} else {
			alert("Problemas no carregamento da página\nMensagem: ' " + xmlhttp.statusText + " '\nInforme a mensagem aos Administradores do Site.")
		}
	}
}

function cadastraCliente() {
	if (xmlhttp.readyState==4) {
		if (xmlhttp.status==200) {
			var txt = xmlhttp.responseText;
			if(txt == "Operação realizada com sucesso!") {
				//window.location.href = "cadastro_ok.asp" ;
				alert("Cadastro realizado com sucesso!");
				document.formulario.email.value = "";
			} else {
				alert(txt) ;
			}
		} else {
			alert("Problemas no carregamento da página\nMensagem: ' " + xmlhttp.statusText + " '\nInforme a mensagem aos Administradores do Site.")
		}
	}
}

/*-----------------------------------------------------------------------
Máscara para o campo data dd/mm/aaaa hh:mm:ss
Exemplo: <input maxlength="16" name="datahora" onKeyPress="DataHora(event, this)">
-----------------------------------------------------------------------*/
function DataHora(evento, objeto){
	var keypress=(window.event)?event.keyCode:evento.which;
	campo = eval (objeto);
	if (campo.value == '00/00/0000 00:00:00')
	{
		campo.value=""
	}

	caracteres = '0123456789';
	separacao1 = '/';
	separacao2 = ' ';
	separacao3 = ':';
	conjunto1 = 2;
	conjunto2 = 5;
	conjunto3 = 10;
	conjunto4 = 13;
	conjunto5 = 16;
	if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length < (19))
	{
		if (campo.value.length == conjunto1 )
		campo.value = campo.value + separacao1;
		else if (campo.value.length == conjunto2)
		campo.value = campo.value + separacao1;
		else if (campo.value.length == conjunto3)
		campo.value = campo.value + separacao2;
		else if (campo.value.length == conjunto4)
		campo.value = campo.value + separacao3;
		else if (campo.value.length == conjunto5)
		campo.value = campo.value + separacao3;
	}
}

function apagarRegistro(msg, linkDel, extras){
	if (msg != '')
		txtMsg = msg;
	else
		txtMsg = 'Deseja realmente apagar esse registro?';
		
	if (confirm(txtMsg)){
		direciona(linkDel + extras);
	}
}


