	////////////////////////////////////////////////
	// Funcoes para as mascaras do formulario 
	////////////////////////////////////////////////
	
	/*
	MaskInput(f.fone, "(99)9999-9999");
	MaskInput(f.data, "99/99/9999");
	MaskInput(f.etc, "Cc99-*C"); // máscara = letra + letra sem acento + 2 números + tracinho + qualquer digito + letra "Cc99-*C"
	MaskInput(f.except, "E^abc"); // permite qualquer coisa menos a, b ou c "E^abc"
	MaskInput(f.only, "O^abc"); // permite somente a, b ou c "O^abc"
	MaskInput(f.letra, "C^"); // somente letras "C^"
	MaskInput(f.letra2, "C^ "); // somente letras e, tb espaço em branco "C^ "
	MaskInput(f.numero, "9^abc"); // somente números e, as letras a, b e c "9^abc"
	*/
	
	addEvent = function(o, e, f, s){
		var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
		r[r.length] = [f, s || o], o[e] = function(e){
			try{
				(e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
				e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
				e.target || (e.target = e.srcElement || null);
				e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
			}catch(f){}
			for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
			return e = null, !!d;
		}
	};
	
	removeEvent = function(o, e, f, s){
		for(var i = (e = o["_on" + e] || []).length; i;)
			if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
				return delete e[i];
		return false;
	};

	maskInput = function(f, m){
		function mask(e){
			var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[\xC0-\xFF]/i, "8": /./ },
				rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
			function accept(c, rule){
				for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
					if(r & i && patterns[i].test(c))
						break;
					return i <= r || c == rule;
			}
			var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
			(!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
				r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
				: (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
				r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
		}
		for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
			addEvent(f, i, mask);
	};

	function maskSaltaCampo(campo,keypress,form,prox,tammax)
	{
		var tecla = keypress.keyCode;
		vr = campo.value;
		tam = vr.length;
		
		if (tecla != 8 && tecla != 46 && tecla != 110 && tecla != 37 && tecla != 39 )
		{
			if (tam == tammax)
			{
				document.forms[form].elements[prox].focus();
			}
		}
	}

	///////////////////////////////////////////////////////
	// Funcoes para manipular valores de objetos do form 
	///////////////////////////////////////////////////////
	
	// Funcao para definir o valor do btn_act	
	function setBtn(form,act,func)
	{	
		d = document.forms[form];
		d.btn_act.value = act;
		
		if(func!="")
		{	
			if(func())
			{
				d.submit();		
			}
		}
		else
		{
			d.submit();
		}	
	}

	// seta o valor em um check box
	function setCheckBox( obj, str )
	{
		var tam=obj.length;
	
		if( tam == undefined )
		{
			if( obj.value == str )
				obj.checked = true;
		}
		else
		{
			for( i=0; i < tam; i++ )
			{
				if( obj[i].value == str )
				{
					obj[i].checked = true;
					return;
				}
			}
		}
	}
	
	// remove o select de um check box
	function unsetCheckBox( obj, str )
	{
		var tam=obj.length;
	
		if( tam == undefined )
		{
			if( obj.value == str )
				obj.checked = false;
		}
		else
		{
			for( i=0; i < tam; i++ )
			{
				if( obj[i].value == str )
				{
					obj[i].checked = false;
					return;
				}
			}
		}
	}
	
	// seleciona o valor em um combo
	function setSelect( sel, strOpt )
	{
		if( strOpt == "" ) return;
	
		for( var i=0; i < sel.length; i++ ) {
			if( sel.options[i].value == strOpt ) {
				sel.options[i].selected = true;
				return;
			}
		}
	}
	
	// retorna o valor selecionado de um combo
	function getSelect( o ) 
	{
		return o.options[o.options.selectedIndex].value;
	}
	
	// seta o valor em um radio box
	function setRadio( o, strOpt )
	{
		if( strOpt == "" ) return;
		
		var tam=o.length;
		
		if( tam > 1 ) {
			for( var i=0; i < tam; i++ )
				if( o[i].value == strOpt ) {
					o[i].click();
					return;
				}
		} else
			if( o.value == strOpt )
				o.click();
	}
	
	// retorna o valor selecionado de um radio box
	function getRadio( o )
	{
		var tam=o.length;
		
		if( tam > 1 ) {
			for (var i=0;i<tam;i++)
				if(o[i].checked=="1")
					return o[i].value;
		} else
			if(o.checked=="1")
				return o.value;
	
		return "";
	}
	
	///////////////////////////////////////////////////////
	// Funcoes para o limitador de caracteres
	///////////////////////////////////////////////////////
	
	// verifica se o limite de caracteres ja foi alcancado
	function taLimit(taObj,eventObj,maxLimit) 
	{
		if(eventObj.keyCode == 8)
		{
			return true;
		}
		else
		{
			if(taObj.value.length == maxLimit) return false;
			return true;
		}
	}
	
	// conta os caracteres digitados e da o replace
	function taCount(taObj,Cnt,maxLimit) { 
		objCnt = document.getElementById(Cnt)
		if(taObj.value.length > maxLimit) taObj.value = taObj.value.substring(0,maxLimit);
		if(objCnt) objCnt.value = maxLimit - taObj.value.length;
		return true;
	}
	
	///////////////////////////////////////
	// Funcoes para formatacao de campos
	///////////////////////////////////////

	// define a posicao do cursor no campo
	function setCursorPosition(oInput,oStart,oEnd)
	{
		if( oInput.setSelectionRange ) 
		{        
			oInput.setSelectionRange(oStart,oEnd);    
		} 
		else if( oInput.createTextRange )
		{	 
			var range = oInput.createTextRange();
			range.collapse(true);
			range.moveEnd('character',oEnd);
			range.moveStart('character',oStart);
			range.select();
		}	
	}
	
	// formata a moeda em reais
	function formataMoeda(obj,objEvent)
	{ 
		var keyCode = objEvent.keyCode ? objEvent.keyCode : objEvent.which ? objEvent.which : objEvent.charCode;
		var d = ",";
		var t = ".";
		var n = obj.value;	
		n = n.replace(/\D/g,"");
		setCursorPosition(obj,obj.length,obj.length);
		
		if((keyCode >= 48 &&  keyCode <= 57) || (keyCode >= 96 &&  keyCode <= 105))
		{	
			var c = 1;	
			n = n.replace(/[0-9]{11}/,"")
			n = n.replace(/(\d{1})(\d{1,1})$/,"$1.$2");
			i = parseInt(n = (+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
			obj.value = (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");	
		}
		else if(keyCode == 8)
		{
			var c = 3;

			if(n.length <= 3)
			{
				obj.value = "0"+d+n;
			}
			else
			{
				n = n.replace(/(\d{1})(\d{1,3})$/,"$1.$2");
				i = parseInt(n = (+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
				obj.value = (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
			}
		}
		else if(keyCode == 46){ obj.value = ""; }
		else if(keyCode == 9){ return true; }else{ return false; }	
	}
	
	///////////////////////////////////////
	// Funcoes para a barra de progresso
	///////////////////////////////////////
	
	function progressBar(id,valor,text,animate)
	{
		new JS_BRAMUS.jsProgressBar($(id),valor,
		{		
			showText	: text,
			animate		: animate,	
			barImage : Array('adm_images/progress_bar/percentImage_back1.gif','adm_images/progress_bar/percentImage_back2.gif',
							 'adm_images/progress_bar/percentImage_back3.gif','adm_images/progress_bar/percentImage_back4.gif')
		});	
	}

	///////////////////////////////////////
	// Funcoes validacao dos campos
	///////////////////////////////////////

	/*
	 * Adiciona método lpad() a classe String.
	 * Preenche a String a esquerda com o caractere fornecido,
	 * até que ela atinja o tamanho especificado.
	 */
	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);
	}

	/**
	 * Adiciona método trim() a classe String.
	 * Elimina brancos no início e fim da String.
	 */
	String.prototype.trim = function()
	{
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}

	/**
	 * Elimina caracteres de formataçao e zeros a esquerda da string
	 * de número fornecida.
	 * @param String pNum
	 * 	String de número fornecida para ser desformatada.
	 * @return String de número desformatada.
	 */
	function unformatNumber(pNum)
	{
		return String(pNum).replace(/\D/g, "").replace(/^0+/, "");
	}
	
	/**
	 * Formata a string fornecida como CNPJ ou CPF, adicionando zeros
	 * a esquerda se necessário e caracteres separadores, conforme solicitado.
	 * @param String pCpfCnpj
	 * 	String fornecida para ser formatada.
	 * @param boolean pUseSepar
	 * 	Indica se devem ser usados caracteres separadores (. - /).
	 * @param boolean pIsCnpj
	 * 	Indica se a string fornecida é um CNPJ.
	 * 	Caso contrário, é CPF. Default = false (CPF).
	 * @return String de CPF ou CNPJ devidamente formatada.
	 */
	function formatCpfCnpj(pCpfCnpj, pUseSepar, pIsCnpj)
	{
		if (pIsCnpj==null) pIsCnpj = false;
		if (pUseSepar==null) pUseSepar = true;
		var maxDigitos = pIsCnpj? 14: 11;
		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;
	}
	
	/**
	 * Calcula os 2 dígitos verificadores para o número-efetivo pEfetivo de
	 * CNPJ (12 dígitos) ou CPF (9 dígitos) fornecido. pIsCnpj é booleano e
	 * informa se o número-efetivo fornecido é CNPJ (default = false).
	 * @param String pEfetivo
	 * 	String do número-efetivo (SEM dígitos verificadores) de CNPJ ou CPF.
	 * @param boolean pIsCnpj
	 * 	Indica se a string fornecida é de um CNPJ.
	 * 	Caso contrário, é CPF. Default = false (CPF).
	 * @return String com os dois dígitos verificadores.
	 */
	function dvCpfCnpj(pEfetivo, pIsCnpj)
	{
		if (pIsCnpj==null) pIsCnpj = false;
		var i, j, k, soma, dv;
		var cicloPeso = pIsCnpj? 8: 11;
		var maxDigitos = pIsCnpj? 14: 11;
		var calculado = formatCpfCnpj(pEfetivo, 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;
	}
	
	
	/**
	 * Testa se a String pCpf fornecida é um CPF válido.
	 * Qualquer formataçao que nao seja algarismos é desconsiderada.
	 * @param String pCpf
	 * 	String fornecida para ser testada.
	 * @return <code>true</code> se a String fornecida for um CPF válido.
	 */
	function validaCpf(pCpf)
	{
		if(typeof(pCpf) == "object"){ pCpf = pCpf.value; }
		var numero = formatCpfCnpj(pCpf, false, false);
		var base = numero.substring(0, numero.length - 2);
		var digitos = dvCpfCnpj(base, false);
		var algUnico, i;
	
		// Valida dígitos verificadores
		if (numero != base + digitos) return false;
	
		/* Nao serao considerados válidos os seguintes CPF:
		 * 000.000.000-00, 111.111.111-11, 222.222.222-22, 333.333.333-33, 444.444.444-44,
		 * 555.555.555-55, 666.666.666-66, 777.777.777-77, 888.888.888-88, 999.999.999-99.
		 */
		algUnico = true;
		for (i=1; algUnico && i<11; i++)
		{
			algUnico = (numero.charAt(i-1) == numero.charAt(i));
		}
		return (!algUnico);
	}

	/**
	 * Testa se a String pCnpj fornecida é um CNPJ válido.
	 * Qualquer formataçao que nao seja algarismos é desconsiderada.
	 * @param String pCnpj
	 * 	String fornecida para ser testada.
	 * @return <code>true</code> se a String fornecida for um CNPJ válido.
	 */
	function validaCnpj(pCnpj)
	{
		if(typeof(pCnpj) == "object"){ pCnpj = pCnpj.value; }
		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;
	
		// Valida dígitos verificadores
		if (numero != base + ordem + digitos) return false;
	
		/* Nao serao considerados válidos os CNPJ com os seguintes números BÁSICOS:
		 * 11.111.111, 22.222.222, 33.333.333, 44.444.444, 55.555.555,
		 * 66.666.666, 77.777.777, 88.888.888, 99.999.999.
		 */
		algUnico = numero.charAt(0) != '0';
		for (i=1; algUnico && i<8; i++)
		{
			algUnico = (numero.charAt(i-1) == numero.charAt(i));
		}
		if (algUnico) return false;
	
		/* Nao será considerado válido CNPJ com número de ORDEM igual a 0000.
		 * Nao será considerado válido CNPJ com número de ORDEM maior do que 0300
		 * e com as tres primeiras posiçoes do número BÁSICO com 000 (zeros).
		 * Esta crítica nao será feita quando o no BÁSICO do CNPJ for igual a 00.000.000.
		 */
		if (ordem == "0000") return false;
		return (base == "00000000"
			|| parseInt(ordem, 10) <= 300 || base.substring(0, 3) != "000");
	}
	
	/**
	 * Testa se a String pCpfCnpj fornecida é um CPF ou CNPJ válido.
	 * Se a String tiver uma quantidade de dígitos igual ou inferior
	 * a 11, valida como CPF. Se for maior que 11, valida como CNPJ.
	 * Qualquer formataçao que nao seja algarismos é desconsiderada.
	 * @param String pCpfCnpj
	 * 	String fornecida para ser testada.
	 * @return <code>true</code> se a String fornecida for um CPF ou CNPJ válido.
	 */
	function validaCpfCnpj(pCpfCnpj)
	{
		if(typeof(pCpfCnpj) == "object"){ pCpfCnpj = pCpfCnpj.value; }
		var numero = pCpfCnpj.replace(/\D/g, "");
		if (numero.length > 11)
			return isCnpj(pCpfCnpj)
		else
			return isCpf(pCpfCnpj);
	}
	
	/**
	 * Testa se a String obj fornecida é um email válido.
	 * @return <code>true</code> se a String fornecida for um email válido.
	 */
	function validaEmail(obj)
	{
		var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
		if(typeof(obj) == "string"){
			if(er.test(obj)){ return true; }
		}else if(typeof(obj) == "object"){
			if(er.test(obj.value)){ return true; }
		}else{ return false; }
	}
	
	/**
	 * Testa se a String obj fornecida é uma data válida no formato dd/mm/aaaa.
	 * @return <code>true</code> se a String fornecida for uma data válida.
	 */
	function validaData(obj)
	{
		var er = new RegExp(/^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/);
		if(typeof(obj) == "string"){
			if(er.test(obj)){ return true; }
		}else if(typeof(obj) == "object"){
			if(er.test(obj.value)){ return true; }
		}else{ return false; }
	}

	/**
	 * Testa se a String obj fornecida é uma hora válida no formato hh:mm 24h.
	 * @return <code>true</code> se a String fornecida for uma hora válida.
	 */
	function validaHora(obj)
	{
		var er = new RegExp(/^([0-1]\d|2[0-3]):[0-5]\d$/);
		if(typeof(obj) == "string"){
			if(er.test(obj)){ return true; }
		}else if(typeof(obj) == "object"){
			if(er.test(obj.value)){ return true; }
		}else{ return false; }
	}	
		
	/**
	 * Testa se a String obj fornecida é um telefone válido no formato (xx) xxxx-xxxx.
	 * @return <code>true</code> se a String fornecida for um telefone válido.
	 */
	function validaTelefone(obj)
	{
		var er = new RegExp(/\(?\d{2}\)? ?\d{4}-\d{4}/);
		if(typeof(obj) == "string"){
			if(er.test(obj)){ return true; }
		}else if(typeof(obj) == "object"){
			if(er.test(obj.value)){ return true; }
		}else{ return false; }
	}
	
	function abreJanela(szJanela, szUrl, intWidth, intHeight )
	{
		var posx = (screen.width-intWidth)/2;
		var posy = (screen.height-intHeight)/2;
	
		win = window.open(szUrl,szJanela,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width='+intWidth+',height='+intHeight+',screenX='+posx+',screenY='+posy);
		win.moveTo(posx,posy);
		win.focus();
	}
	
	function abreJanela2(szJanela, szUrl, intWidth, intHeight )
	{
		var posx = (screen.width-intWidth)/2;
		var posy = (screen.height-intHeight)/2;
	
		win = window.open(szUrl,szJanela,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width='+intWidth+',height='+intHeight+',screenX='+posx+',screenY='+posy);
		win.moveTo(posx,posy);
		win.focus();
	}	
	
	function carregaSwf(nome,largura,altura,parametros)
	{	
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', largura,
			'height', altura,
			'src', nome,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'window',
			'devicefont', 'false',
			'id', nome,
			'bgcolor', '#ffffff',
			'name', nome,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', nome+'?'+parametros,
			'salign', ''
			);
	}	
	
	function objetoSwf(nome,largura,altura,parametros)
	{	
		AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',
			'width', largura,
			'height', altura,
			'src', nome,
			'quality', 'high',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'align', 'middle',
			'play', 'true',
			'loop', 'true',
			'scale', 'showall',
			'wmode', 'opaque',
			'devicefont', 'false',
			'id', nome,
			'bgcolor', '#ffffff',
			'name', nome,
			'menu', 'true',
			'allowFullScreen', 'false',
			'allowScriptAccess','sameDomain',
			'movie', nome+'?'+parametros,
			'salign', ''
			);
	}
