 	function removerOptionSelect(pIdCombo, pValue)
	{
	  var objCombo = document.getElementById(pIdCombo);
	  var i;
	  for (i = 0; i< objCombo.length; i++)
	  {
		if (objCombo.options[i].value == pValue)
		{ objCombo.remove(i); }
	  }
	}
	
	function adicionarOptionSelect(pIdSelect, pTextOption, pValeuOption)
	{
		objCombo = document.getElementById(pIdSelect);
		objOption = document.createElement('option');
		objOption.text = pTextOption;
		objOption.value = pValeuOption;
		
		try
		{ objCombo.add(objOption, null); }
		catch (ex)
		{
			try
			{ objCombo.add(objOption); }
			catch (ex)
			{
			 alert('não foi possivel adicionar o option');
			 return false;
			}
		}
	}
	
	function validaArquivo(ele)
	{
		ext = getExtensao(ele.value);
		if (!verificaExtensao(ele.value))
		{
			alert('A extensão ' + ext + ' não é válida!');
			ele.value = '';
			return false;
		}
	}

	function getExtensao(nome_arquivo)
	{
		if (nome_arquivo.length > 0)
		{
			var array_nome = nome_arquivo.split('.');
			if (array_nome.length > 1 )
			{
				var ext = array_nome[array_nome.length - 1];
				return ext;
			}
			else
			{ return ""; }			
		}
		else
		{ return ""; }
	}

	function mudar_class(objHTML, strNovaClasse)
	{
		try
		{
			try
			{ objHTML.className = strNovaClasse; }
			catch (ex)
			{
				try
				{ objHTML.setAttribute('class', strNovaClasse); }
				catch (ex)
				{ alert('Erro: \n' + ex.message); }
			}
		}
		catch (ex)
		{ alert('Erro: \n' + ex.message); }
	}

// Remover Acentos
	String.prototype.accnt = function () {
		var cnt = 0;
		var acnt = this;
		acnt = acnt.split('');
		acntlen = acnt.length;
		var sec = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
		var rep = ['A', 'A', 'A', 'A', 'A', 'A', 'a', 'a', 'a', 'a', 'a', 'a', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'o', 'o', 'o', 'o', 'o', 'o', 'E', 'E', 'E', 'E', 'e', 'e', 'e', 'e', 'e', 'C', 'c', 'D', 'I', 'I', 'I', 'I', 'i', 'i', 'i', 'i', 'U', 'U', 'U', 'U', 'u', 'u', 'u', 'u', 'N', 'n', 'S', 's', 'Y', 'y', 'y', 'Z', 'z'];
		for (var y = 0; y < acntlen; y++) {
			if (sec.indexOf(acnt[y]) != -1) cnt++;
		}
		return cnt;
	}
	String.prototype.renlacc = function () {
		var torem = this;
		torem = torem.split('');
		toremout = new Array();
		toremlen = torem.length;
		var sec = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
		var rep = ['A', 'A', 'A', 'A', 'A', 'A', 'a', 'a', 'a', 'a', 'a', 'a', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'o', 'o', 'o', 'o', 'o', 'o', 'E', 'E', 'E', 'E', 'e', 'e', 'e', 'e', 'e', 'C', 'c', 'D', 'I', 'I', 'I', 'I', 'i', 'i', 'i', 'i', 'U', 'U', 'U', 'U', 'u', 'u', 'u', 'u', 'N', 'n', 'S', 's', 'Y', 'y', 'y', 'Z', 'z'];
		for (var y = 0; y < toremlen; y++) {
			if (sec.indexOf(torem[y]) != -1) {
				toremout[y] = rep[sec.indexOf(torem[y])];
			} else toremout[y] = torem[y];
		}
		toascout = toremout.join('');
		return toascout;
	}
	
	String.prototype.removeAcentos = function () {
		pText = this;
		var countarr = new Array();
		var c = '';
		var text = pText;
		var textout = new Array();
		text = text.replace(/\r/g, '');
		text = text.split('\n');
		var linecnt = text.length;
		for (var x = 0; x < linecnt; x++) {
			countarr[x] = Math.abs(text[x].accnt());
			textout[x] = text[x].renlacc();
		}
		textout = textout.join('\n');
		return textout;
	}
	
/* AJAX - Requer o Prototype */
	
	var GlobalErroAjaxLogin;
	
	function PostAjax(action, parametros, funcaoCarregando, funcaoRetorno, funcaoErro)
	{
		
		GlobalErroAjaxLogin = false;
		
		var metodo = 'post';
		var pars = parametros;
		var url = action;
		var myAjax = new Ajax.Request(
		url, 
		{
			method: 		metodo, 
			parameters: 	pars,
			onLoad: 		funcaoCarregando,
			onLoading: 		funcaoCarregando, 
			onInteractive:	funcaoCarregando,
			onFailure: 		funcaoErro,
			onComplete: 	funcaoRetorno
		});
	}
	
	function RequisicaoAjax(action, parametros, funcaoCarregando, funcaoRetorno, funcaoErro)
	{
		
		GlobalErroAjaxLogin = false;
		
		var metodo = 'get';
		var pars = parametros;
		var url = action;
		var myAjax = new Ajax.Request(
		url, 
		{
			method: 		metodo, 
			parameters: 	pars,
			onLoad: 		funcaoCarregando,
			onLoading: 		funcaoCarregando, 
			onInteractive:	funcaoCarregando,
			onFailure: 		funcaoErro,
			onComplete: 	funcaoRetorno
		});
	}
	
	function erroAjaxPadrao()
	{ GlobalErroAjaxLogin = true; }
	
	function EnviarFormAjax(event, form) {
		Event.stop(event);
		
		if (form.id == '') { form.setAttribute('id', form.name); }
		
		pars = form.serialize(true);
		metodo = form.method;
		destino = form.action;
		
		Lightview.show({
			href: destino,
			rel: 'ajax',
			title: '',
			caption: '',
			options: {
			overflow: 'hidden',
			autosize: true,
			topclose: false,
			ajax: {
				method: metodo,
				parameters: 	pars,
				evalScripts: true,
				onComplete: function(){  }
				}
			}
		});
	}
	
	/* AJAX - Requer o Prototype */

	var ns4 = document.layers;
	var ns6 = document.getElementById && !document.all;
	var ie4 = document.all;
	
	var toolTipSTYLE="";
	
	function valida_link(pLink)
	{
		
		fLink = pLink.trim();
		
		if (fLink == '')
		{ return false; }
		else
		{
			
			if ( fLink.indexOf('http://') == 0 )
			{
				if ( fLink.replace(/http:\/\//, '').trim() == '' )
				{ return false; }
				else
				{ return true; }
			}
			else
			{ return false; }
			
		}	
		
	}
	
	function setSelected(combo, value_desejado)
	{
		combo = document.getElementById(combo);
		for (i = 0; i<combo.options.length; i++)
		{
			if (combo.options[i].value == value_desejado)
			{ combo.options[i].selected = true; }
		}
	}
	
	String.prototype.limpa = function ()
	{
		msg = this;
		
		if (msg != '')
		{
			msg = msg.replace(/[\n]/g,'chr13');
			msg = msg.replace(/[?]/g,'chr63');
			msg = msg.replace(/[&]/g,'chr38');
		}
		
		return msg;
	}

	/*	Chamada: onkeypress="javascript: return campo_email(event);" */	
	function campo_email(e)
	{
		var key = window.event ? e.keyCode : e.which;
		
		if (key < 32)
		{
			return true;
		}
		else
		{
			if ( (key == 45) || (key == 46) || (key == 64) || (key == 95) || (key == 127) ) {
				return true;
			}
			else
			{
				if ( ((key>47) && (key<58)) || ((key>96) && (key < 123)) )
				{
					return true;
				}
				else
				{
					return false;
				}
			} 
		}
	}
	
	/*	Chamada: onkeypress="javascript: return campo_alfanumerico(event);" */
	function campo_alfanumerico(e) {
		var key = window.event ? e.keyCode : e.which;
	
		if (key < 32) {
			return true;
		}
		else {
			if (key == 127) {
				return true;
			}
			else {
				if ( ((key > 47) && (key < 58)) || ((key > 64) && (key < 91)) || ((key > 96) && (key < 123)) ) {
					return true;
				}
				else {
					return false;
				}
			}
		}
	}
	
	/*	Chamada: onkeypress="return campo_numero(event);" */
	function campo_numero(e)
	{
		var key = window.event ? e.keyCode : e.which;
		
		if (key < 32)
		{
			return true;
		}
		else
		{
			if (key == 127) {
				return true;
			}
			else
			{
				if ( (key>47) && (key<58) )
				{
					return true;
				}
				else
				{
					return false;
				}
			} 
		}
	}

	/* Chamada: onkeypress="return campo_letra(event);" */	
	function campo_letra(e)
	{
		var key = window.event ? e.keyCode : e.which;
		
		if (key < 32)
		{
			return true;
		}
		else
		{
			if (key == 127) {
				return true;
			}
			else
			{
				if ( ((key>64) && (key<91)) || ((key>96) && (key < 123)) )
				{
					return true;
				}
				else
				{
					return false;
				}
			} 
		}
	}
	
	/* Trim */
	String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }	
	String.prototype.ltrim = function() { return this.replace(/^\s+/, ''); }	
	String.prototype.rtrim = function() { return this.replace(/\s+$/, ''); }

	function VoltarInicio(id_name_obj)
	{
		if (typeof id_name_obj != "undefined")
		{
			try
			{ document.getElementById(id_name_obj).focus();  }
			catch (ex)
			{
				try 
				{ document.getElementsByName(id_name_obj)[0].focus(); }
				catch (ex) { }
			}
		}
		
		pagina_pai().Lightview.hide();
	}
	
	function pagina_pai()
	{
		try
		{ w = window.parent; }
		catch(ex)
		{ w = top.window; }
		return w;
	}
	
	function formatPrice2(campo,tammax,teclapres,unmon)
	{
		if(apenas_numero(teclapres))
		{
			var key = window.event ? teclapres.keyCode : teclapres.which;
			if (key == 44 || key == 46 || key < 48 || key > 57) key = 0;
			var tecla = key;
			vr = document.getElementById(campo).value;
			vr = vr.replace( '/', '' );
			vr = vr.replace( '/', '' );
			vr = vr.replace( ',', '' );
			vr = vr.replace( '.', '' );
			vr = vr.replace( '.', '' );
			vr = vr.replace( '.', '' );
			vr = vr.replace( '.', '' );
			tam = vr.length;
			if ( tam < tammax && tecla != 8 ) {
				tam = vr.length + 1 ;
			}
			if ( tecla == 8 ) {
				tam = tam - 1 ;
			}
			if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
				if ( tam <= 2 ) {
					document.getElementById(campo).value = unmon + vr;
				}
				if ( (tam > 2) && (tam <= 8) ) {
					document.getElementById(campo).value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam );
				}
				if ( (tam >= 9) && (tam <= 11) ) {
					document.getElementById(campo).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
				}
				if ( (tam >= 12) && (tam <= 14) ) {
					document.getElementById(campo).value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
				}
				if ( (tam >= 15) && (tam <= 17) ) {
					document.getElementById(campo).value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
				}
				if ( (tam >= 18) && (tam <= 20) ) {
					document.getElementById(campo).value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); 
				}
			}
		}
		else
		{
			return false;
		}
	}

	function limita_caracteres(e, obj, pLen)
	{
		key = window.event ? e.keyCode : e.which;
		keychar = String.fromCharCode(key);
		
		if ((key == 0) || (key == 8)) 
		{ return true; }
		else
		{
			if (obj.value.length < pLen) 
			{ return true; }
			else
			{ return false; }
		}
	}
	
	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	
	function setCheckedValue(radioObj, novoValue) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].value == novoValue)
			{ radioObj[i].checked = true; }
			else { radioObj[i].checked = false; }
		}
		return "";
	}
	
	
	function suja_se_vazio(obj, msg) {
		if(obj.value=='') {
			obj.value=msg;
		}
	}
	
	function validaForm(nome_form, array_excecoes) {
		var excecoes = array_excecoes;
		var nm_form = nome_form;
		var return_ = true;
		
		if (nm_form=="")
		{
			alert("Form em branco!")
			return_ = false;
		}
		else
		{
			for (i=0; i<document.forms[nm_form].elements.length; i++)
			{
				if (
					(document.forms[nm_form].elements[i].type=="text") && 
					(document.forms[nm_form].elements[i].disabled!=true))
				{
					if (document.forms[nm_form].elements[i].value=="")
					{
						uma_excecao = false;
						if (array_excecoes!=null)
						{
							if (array_excecoes.length > 0)
							{
								for (c=0; c<excecoes.length; c++)
								{				
									if (document.forms[nm_form].elements[i].id==excecoes[c])
									{
										uma_excecao = true;
										break;
									}
								}
							}
						}
						if (!uma_excecao)
						{
							alert("O campo " + document.forms[nm_form].elements[i].title + " precisa ser preenchido");
							document.forms[nm_form].elements[i].focus();
							return_ = false;
							break;
						}
					}
				}
				
				if (!return_)
				{
					break;
				}
			}		
		}
		return return_;
	}

	function countChars(theElement, maxCount, textCounter, offChar) {
		var realCount, visibleCount, i;
		visibleCount = 0;
		realCount = 0;
		if (offChar != 0) {
			for (i=0; i < theElement.value.length; i++) {
				if (visibleCount < maxCount) {
					realCount++;
				}
				if (theElement.value.charCodeAt(i) != offChar) {
					visibleCount++;
				}
			}
		}
		textCounter.innerHTML = maxCount - visibleCount;
		if (maxCount - visibleCount < 0) {	
			theElement.value = theElement.value.substring(0, realCount);
			textCounter.innerHTML = 0;
		}
	}
	
	function redimensiona(width, height) {
		var width_tela   = self.screen.width;
		var height_tela  = self.screen.height;
		var pos_esquerda  = (width_tela - width)/2;
		var pos_direita  = (height_tela - height)/2;
		
		self.moveTo(pos_esquerda,pos_direita); //centraliza
		self.resizeTo(width, height); //redimensiona
	}
	
	function formata_horario(obj) {
		if ((event.keyCode<48)||(event.keyCode>57)){
			event.returnValue = false;
			}
		else{
			if(obj.value.length==2){
				obj.value = obj.value + ":";
			}
		}
	}
	
	function formata_data(obj) {
		if ((event.keyCode<48)||(event.keyCode>57)){
			event.returnValue = false;
			}
		else{
			if(obj.value.length==2||obj.value.length==5){
				obj.value = obj.value + "/";
			}
		}
	}
	
	function abrir(url) {
		window.open(url, 'S','resizable=yes,scrollbars=no');
	}
	
	function MM_openBrWindow(theURL,winName,features) { //v2.0
	  window.open(theURL,winName,features);
	}
	
	function apaga_valor_campo(destino) {
		destino.value = '';
	}
	
	function apenasNumero(input) {
		if ((event.keyCode<46)||(event.keyCode>57)||(event.keyCode==47)) {
			event.returnValue = false;
		}
	}
	
	function carrega() {
		document.getElementById("carrega_mensagem").style.display = 'none';
		document.getElementById("corpo").style.display = 'inline';
	}
	
	function carrega_define_posicao() {
	  var x,y;
	  if (self.innerHeight)
	  {// all except Explorer
		x = self.innerWidth;
		y = self.innerHeight;
	  }
	  else 
	  if (document.documentElement && document.documentElement.clientHeight)
	  {// Explorer 6 Strict Mode
	   x = document.documentElement.clientWidth;
	   y = document.documentElement.clientHeight;
	  }
	  else
	  if (document.body)
	  {// other Explorers
	   x = document.body.clientWidth;
	   y = document.body.clientHeight;
	  }
		var el=document.getElementById('carrega_mensagem');
		if(null!=el)
		{
			var top = (y/2) - 50;
			var left = (x/2) - 200;
			if( left<=0 ) left = 10;
	
			el.style.left = left + "px"
			el.style.top = top + "px";
			el.style.zIndex = 2;
		}
	}
	
	function centraliza_janela(width, height) {
		var width_janela	= eval(width);
		var height_janela	= eval(height);
		var width_tela 		= self.screen.width;
		var height_tela 	= self.screen.height;
		var pos_esquerda 	= (width_tela - width_janela)/2;
		var pos_direita 	= (height_tela - height_janela)/2;
	
		self.moveTo(pos_esquerda,pos_direita); //centraliza
		self.resizeTo(width_janela, height_janela); //redimensiona
	}
	
	function checou(campo) {
		if(campo) {
			if(campo.length) {
				for (var i=0; i<campo.length; i++) {
					if( campo[i].checked ) return true;
				}
				return false;
			}
			else {
				if(campo.checked) return true;
				return false;
			}
		}
		else {
			return false;
		}
	}
	
	function conta_checado(campo) {
		var acum = 0;
		if(campo) {
			if(campo.length) {
				for (var i=0; i<campo.length; i++) {
					if( campo[i].checked ) acum++;
				}
			}
			else {
				if(campo.checked) acum++;
			}
		}
		return acum;
	}
	
	function isDate(data) {
	
		if(!data) return false;
		
		var data_separada = data.split('/'); //separa as datas
		if(data_separada.length < 3) return false; //deve possuir a estrutura dd:mm:aaaa
		
		var dia = data_separada[0];
		var mes = data_separada[1];
		var ano = data_separada[2];
		
		//verificando se o dia, o mês e o ano são numéricos
		if( isNaN(dia) ) return false;
		if( isNaN(mes) ) return false;
		if( isNaN(ano) ) return false;
		
		//verificando se a faixa do mês está correta
		if( (mes<0)||(mes>12) ) return false;
	
		//verificando se o ano possui 4 dígitos
		if( ano.length!=4 ) return false;
	
		var dia_max;
		
		switch (mes)
		{
			case '1':
			case '01':
			case '3':
			case '03':
			case '5':
			case '05':
			case '7':
			case '07':
			case '8':
			case '08':
			case '10':
			case '12':
			{
				dia_max=31;
				break;
			}
			case '4':
			case '04':
			case '6':
			case '06':
			case '9':
			case '09':
			case '11':
			{
				dia_max=30;
				break;
			}
			case '2':
			case '02':
			{
	
				if (ano%4==0) {
				//Ano bissexto
					dia_max=29;
				}
				else {
				//Ano não bissexto
					dia_max=28;
				}
				break;
			}
		}
		if( parseInt(dia) > parseInt(dia_max) ) return false;
		
		return true;
	}
	
	function excluir(form, campo) {
		var campo= eval('document.'+form+'.'+campo);
		var form = eval('document.'+form);
		
		if(checou(campo)) {
			if(confirm("Deseja realmente excluir?")) {
				form.submit();
			}
		}
		else {
			alert('Selecione primeiro o que deseja excluir');
		}
	}
	function excluir_2(form, campo, msg) {
		var campo= eval('document.'+form+'.'+campo);
		var form = eval('document.'+form);
		
		if(checou(campo)) {
			if(confirm(msg)) {
				form.submit();
			}
		}
		else {
			alert('Selecione primeiro o que deseja excluir');
		}
	}
	
	function apenas_numero(e)
	{
		var key = window.event ? e.keyCode : e.which;
		var keychar = String.fromCharCode(key);
		if ((key == 0) || (key == 8)) {
			return true
		}
		else {
			reg = /\d/;
			return reg.test(keychar);
		}  
	}
	
	function ajustar_data(Campo, teclapres)
	{
		var retorno = apenas_numero(teclapres);
	
		if (retorno) {
			if(window.event) {
				var tecla = teclapres.keyCode;
			}
			else {
				var tecla = teclapres.which;
			}
		
			var vr = new String(Campo.value);
			vr = vr.replace("/", "");
			vr = vr.replace("/", "");
			
			tam = vr.length + 1;
			
			if (tecla != 9 && tecla != 8) {
				if (tam > 2 && tam < 5) {
					Campo.value = vr.substr(0, 2) + '/' + vr.substr(2, tam);
				}
				if (tam >= 5 && tam <= 10) {
					Campo.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,tam-4);
				}
			}
		}
		
		return retorno;
	}
	
	function formata_telefone(obj){
	   if (obj.value.length==4){
		   obj.value = obj.value + "-";
	   }
	}
	
	function formata_cpf(obj) {
		if ((event.keyCode<48)||(event.keyCode>57)){
			event.returnValue = false;
			}
		else{
			if((obj.value.length==3)||(obj.value.length==7)){
				obj.value = obj.value + ".";
			}
			else{
				if(obj.value.length==11){
					obj.value = obj.value + "-";
				}
			}
		}
	}
	
	function limpa_se_igual(obj, msg) {
		if(obj.value==msg) {
			obj.value='';
		}
	}
	
	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 move(index,to) {
		var list = document.form_ordenar.list;
		var total = list.options.length-1;
		if (index == -1) return false;
		if (to == +1 && index == total) return false;
		if (to == -1 && index == 0) return false;
		var items = new Array;
		var values = new Array;
		for (i = total; i >= 0; i--) {
			items[i] = list.options[i].text;
			values[i] = list.options[i].value;
		}
		for (i = total; i >= 0; i--) {
			if (index == i) {
				list.options[i + to] = new Option(items[i],values[i + to], 0, 1);
				list.options[i] = new Option(items[i + to], values[i]);
				i--;
			}
			else {
				list.options[i] = new Option(items[i], values[i]);
			}
		}
		list.focus();
	}
	
	function initToolTips()
	{
	  if(ns4||ns6||ie4)
	  {
		if(ns4) toolTipSTYLE = document.toolTipLayer;
		else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
		else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
		if(ns4) document.captureEvents(Event.MOUSEMOVE);
		else
		{
		  toolTipSTYLE.visibility = "visible";
		  toolTipSTYLE.display = "none";
		}
		document.onmousemove = moveToMouseLoc;
	  }
	}
	
	function toolTip(msg, fg, bg)
	{
	  if(toolTip.arguments.length < 1) // hide
	  {
		if(ns4) toolTipSTYLE.visibility = "hidden";
		else toolTipSTYLE.display = "none";
	  }
	  else // show
	  {
		if(!fg) fg = "#204373";
		if(!bg) bg = "#D7DBE7";
		var content =
		'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
		'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
		'"><td align="center" style="font-family:Verdana; font-size:9px;"><font color="' + fg +
		'">&nbsp\;' + msg +
		'&nbsp\;</font></td></table></td></table>';
		if(ns4)
		{
		  toolTipSTYLE.document.write(content);
		  toolTipSTYLE.document.close();
		  toolTipSTYLE.visibility = "visible";
		}
		if(ns6)
		{
		  document.getElementById("toolTipLayer").innerHTML = content;
		  toolTipSTYLE.display='block'
		}
		if(ie4)
		{
		  document.all("toolTipLayer").innerHTML=content;
		  toolTipSTYLE.display='block'
		}
	  }
	}
	function moveToMouseLoc(e)
	{
	  if(ns4||ns6)
	  {
		x = e.pageX;
		y = e.pageY;
	  }
	  else
	  {
		x = event.x + document.body.scrollLeft;
		y = event.y + document.body.scrollTop;
	  }
	  toolTipSTYLE.left = x + offsetX;
	  toolTipSTYLE.top = y + offsetY;
	  return true;
	}
	
	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);
	};
	
	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;
	};
	
	
	function ValidaEmail(email)
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		return reg.test(email);
	}
	
	function valida_cnpj(campo) {
		//Declaração as variáveis
		var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais, cnpj;
		cnpj = campo.value;
		//Verificando se o campo é nulo
		if (cnpj.length == 0) {
			return false;
		}
	
		//Filtrar o campo para verificar se está com máscara
		var filtro = /\d{2,3}.\d{3}.\d{3}\/\d{4}-\d{2}/;
		if (!filtro.test(cnpj)) {
			//window.alert("CNPJ inválido. Tente novamente.");
			return false;
		}
		//Ultilização expressão regular para retirar o que não for número
		cnpj = cnpj.replace(/\D+/g, '');
		digitos_iguais = 1;
	
		for (i = 0; i < cnpj.length - 1; i++)
		if (cnpj.charAt(i) != cnpj.charAt(i + 1)) {
			digitos_iguais = 0;
			break;
		}
		if (!digitos_iguais) {
			tamanho = cnpj.length - 2
			numeros = cnpj.substring(0, tamanho);
			digitos = cnpj.substring(tamanho);
			soma = 0;
			pos = tamanho - 7;
			for (i = tamanho; i >= 1; i--) {
				soma += numeros.charAt(tamanho - i) * pos--;
				if (pos < 2) pos = 9;
			}
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(0)) {
				//alert('CNPJ inválido');
				return false;
			}
			tamanho = tamanho + 1;
			numeros = cnpj.substring(0, tamanho);
			soma = 0;
			pos = tamanho - 7;
			for (i = tamanho; i >= 1; i--) {
				soma += numeros.charAt(tamanho - i) * pos--;
				if (pos < 2) pos = 9;
			}
	
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(1)) {
				//alert('CNPJ inválido');
				return false;
			}
			return true;
		}
		else {
			//alert('CNPJ inválido');
			return false;
		}
	}
	
	function Valida_CPF(st){	
		st = st.replace(".","");
		st = st.replace(".","");
		st = st.replace("-","");
		if (st == ""){
			return (false);
		}
		l = st.length;
	
		//aleterado para se usuário não digitar os zeros na frente do CPF, completar sozinho
		if ((l == 9) || (l == 8)){
			for (i = l ; i < 10; i++){
				st = '0' + st;
			}
		}
		l = st.length;
		st2 = "";
		for (i = 0; i < l; i++) {
			caracter = st.substring(i,i+1);
			if ((caracter >= '0') && (caracter <= '9'));
			st2 = st2 + caracter;
		}
		if ((st2.length > 11) || (st2.length < 10)){
			return false;
		}
		if (st2.length==10)
			st2 = '0' + st2;
		digito1 = st2.substring(9,10);
		digito2 = st2.substring(10,11);
		digito1 = parseInt(digito1,10);
		digito2 = parseInt(digito2,10);
		sum = 0; mul = 10;
		for (i = 0; i < 9 ; i++) {
			digit = st2.substring(i,i+1);
			tproduct = parseInt(digit ,10) * mul;
			sum += tproduct;
			mul--;
		}
		dig1 = ( sum % 11 );
		if ( dig1==0 || dig1==1 )
			dig1=0;
		else
			dig1 = 11 - dig1;
		if (dig1!=digito1){
			return false;
		}
		sum = 0;
		mul = 11;
		for (i = 0; i < 10 ; i++) {
			digit = st2.substring(i,i+1);
			tproduct = parseInt(digit ,10)*mul;
			sum += tproduct;
			mul--;
		}
		dig2 = (sum % 11);
		if ( dig2==0 || dig2==1 )
			dig2=0;
		else
			dig2 = 11 - dig2;
		if (dig2 != digito2){
			return false;
		}
		return true;
	}
	function createXMLHTTP()
 {
  var ajax;
  try
  {
   ajax = new ActiveXObject("Microsoft.XMLHTTP");
  }
  catch(e)
  {
   try
   {
    ajax = new ActiveXObject("Msxml2.XMLHTTP");
    alert(ajax);
   }
   catch(ex)
   {
    try
    {
     ajax = new XMLHttpRequest();
    }
    catch(exc)
    {
      alert("Esse browser não tem recursos para uso do Ajax");
      ajax = null;
    }
   }
   return ajax;
  }
 
 
     var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0",
           "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
           "Microsoft.XMLHTTP"];
     for (var i=0; i < arrSignatures.length; i++)
     {
    try
    {
     var oRequest = new ActiveXObject(arrSignatures[i]);
     return oRequest;
    }
    catch (oError)
    {
       }
     }
 
      throw new Error("MSXML is not installed on your system.");
 }// JavaScript Document
 
 function insere(campo, vl)
 {
	
	var obj = document.getElementById(campo);
	
	if (obj.value == "")
	{
		alert("Nome inválido!")
	}
	if (vl == 'Gravar')
	{
		obj = document.getElementById(campo);
      //alert(obj.value);
	    grava('form', 'temas-faq-formulario.asp', obj.value);
		obj.value = "";
		obj.focus();
	}
	else
	{
		obj = document.getElementById(campo);
		grava2('form', 'temas-faq-formulario-atualiza.asp',obj.value,document.forms["frm_faq"].elements['cd_enviado'].value);
		document.forms["frm_faq"].elements['btn_tema'].value = 'Gravar';
		obj.value = "";
		obj.focus();
	}
	
 }
 
 function Checa_checkbox(nome, maximoCheckbox, vl)
 {
 	var obj = document.getElementsByName(nome);
	var cont = 0;
	var it = 0;
	for(x=0;x<obj.length;x++)
	{
		if (obj.item(x).value == vl)
		{it = x}
		if (obj.item(x).checked)
		{cont = cont + 1}
	}
	
	if (cont <= maximoCheckbox)
	{
		grava("teste-inutil","veiculos-atualizar-ajax.asp",obj.item(it).value);
//	 	var oHTTPRequest = createXMLHTTP();
//	     oHTTPRequest.open("get","veiculos-atualizar-ajax.asp" + "?tema=" + encodeURIComponent(obj.item(it).value), true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
	}
	else
	{
		obj.item(it).checked = false;
		alert("Só podem ser escolhidos "  + maximoCheckbox + " itens!");
	}
 }
 
	function grava( nm_obj , pagina , value ) {
		var _type	= 'GET';
		var _url 	= pagina;
		var _pars	= 'tema=' + value;
		
		var requisicaoAjax = jQuery.ajax( {
			dataType: 'html',
			type: _type,
			data: _pars,
			url: _url,
			success: function( _retornoAjax ) {
				if (nm_obj == "teste-inutil" ) {
					alert("Destaque alterado com sucesso!");
				}
			}
		} );
	}
 
 
/* function grava(nm_obj, pagina, value)
 {

	 var oHTTPRequest = createXMLHTTP();
     oHTTPRequest.open("get", pagina + "?tema=" + encodeURIComponent(value), true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
     oHTTPRequest.onreadystatechange=function(){
     // o valor 4 significa que o objeto ja completou a solicitacao
     if (oHTTPRequest.readyState==4){// abaixo o texto gerado no arquivo executa.asp e colocado no div
     	document.getElementById(nm_obj).innerHTML = oHTTPRequest.responseText;}}
	    oHTTPRequest.send();
		
		if (nm_obj == "teste-inutil" )
		{
			alert("Destaque alterado com sucesso!")
		}
 }
*/
	function grava2(nm_obj, pagina, value,value2)
 {

	 var oHTTPRequest = createXMLHTTP();
     oHTTPRequest.open("get", pagina + "?tema=" + encodeURIComponent(value) + "&cd=" + encodeURIComponent(value2), true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
     oHTTPRequest.onreadystatechange=function(){
     // o valor 4 significa que o objeto ja completou a solicitacao
     if (oHTTPRequest.readyState==4){// abaixo o texto gerado no arquivo executa.asp e colocado no div
     	document.getElementById(nm_obj).innerHTML = oHTTPRequest.responseText;}}
	    oHTTPRequest.send();
		//alert(v2)
   	// alert(v1)
  /*---------------------------------------------------------------*/
 }
function envia_valor(valor, cd_valor)
{
	var obj = document.getElementById("nm_tema")
	obj.value = valor;
	obj.focus();
	document.forms["frm_faq"].elements['btn_tema'].value = 'Alterar';
	document.forms["frm_faq"].elements['cd_enviado'].value = cd_valor;
}
function atualiza(valor,cd_valor)
{
//	valor = document.forms["frm_faq"].elements['nm_tema'].value;
//	grava('form', 'temas-faq-formulario-atualiza.asp', valor, cd_valor);
//	document.forms["frm_faq"].elements['btn_tema'].value = 'Gravar';
//	document.forms["frm_faq"].elements['btn_tema'].onclick = insere('nm_tema');
}
 function atrib()
 {
//	 obj = document.getElementById("qt_arquivos")
//	 obj.value = 1;
	altera(0,'qt_arquivos')
 }
 function ChangeLanguage(pIdioma, pPagina, pQuery)
{ window.location = 'idioma-alterar.asp?idioma=' + pIdioma + '&pagina=' + pPagina + '&query=' +pQuery; }
 
 function retorna_dados(objATUAL, id, url) {
	 
	document.getElementById('d_cidade').innerHTML = "<center><img src='images/load.gif'></center>"
	var valor_objATUAL = objATUAL.value;
	


	 var oHTTPRequest = createXMLHTTP();
     oHTTPRequest.open("get", url + "?valor=" + encodeURIComponent(valor_objATUAL) + "&id=" + encodeURIComponent(id), true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
	// alert(valor_objATUAL);
     oHTTPRequest.onreadystatechange=function(){
     // o valor 4 significa que o objeto ja completou a solicitacao
     if (oHTTPRequest.readyState==4){// abaixo o texto gerado no arquivo executa.asp e colocado no div
     	document.getElementById('d_cidade').innerHTML = oHTTPRequest.responseText;}}
	    oHTTPRequest.send();

}

function retorna_trabalhos_2(url) {
	document.getElementById('galeria_imagens').innerHTML = '<center><img src="../images/load_grande.gif"></center>'
	
	 var oHTTPRequest = createXMLHTTP();
     oHTTPRequest.open("get", url , true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
	// alert(valor_objATUAL);
     oHTTPRequest.onreadystatechange=function(){
     // o valor 4 significa que o objeto ja completou a solicitacao
     if (oHTTPRequest.readyState==4){// abaixo o texto gerado no arquivo executa.asp e colocado no div
     	document.getElementById('galeria_imagens').innerHTML = oHTTPRequest.responseText;}}
	 
	 oHTTPRequest.send();			
}

function retorna_trabalhos(url) {
	document.getElementById('galeria_imagens').innerHTML = '<center><img src="images/load_grande.gif"></center>'
	
	 var oHTTPRequest = createXMLHTTP();
     oHTTPRequest.open("get", url , true); //enviamos para a página que faz o select do que foi digitado e traz a lista preenchida.
	// alert(valor_objATUAL);
     oHTTPRequest.onreadystatechange=function(){
     // o valor 4 significa que o objeto ja completou a solicitacao
     if (oHTTPRequest.readyState==4){// abaixo o texto gerado no arquivo executa.asp e colocado no div
     	document.getElementById('galeria_imagens').innerHTML = oHTTPRequest.responseText;}}
	 
	 oHTTPRequest.send();			
}


function preencheSelect(requisicaoOriginal) {

	var retorno = requisicaoOriginal.responseText;
	retorno = retorno.split("|");

	id = retorno[0]; // O retorno[0] é a parte da string que contém o id a ser atualizado.
	opcoes = retorno[1].split("^"); // O retorno[1] é a parte da string que vai atualizar o SELECT
	// limpo o select
	limpa_select(id);

	for (i = 0; i < opcoes.length; i++) {
		opcoes_separadas = opcoes[i].split('~');

		var novo_option = document.createElement('option');
		novo_option.text = opcoes_separadas[1];

		try {
			// adiciono os novos options
			document.getElementById(id).add(novo_option, null); // standards compliant
			document.getElementById(id).options[i].setAttribute('value', opcoes_separadas[0]);
		}
		catch(ex) {
			// adiciono os novos options
			document.getElementById(id).add(novo_option); // IE only
			document.getElementById(id).options[i].setAttribute('value', opcoes_separadas[0]);
		}
	}
}

function limpa_select(id) {
	var total_opcoes = document.getElementById(id).length;

	for (j = total_opcoes; j > -1; j--)
	document.getElementById(id).remove(j);
}


function atualiza_capa() {
	muda_action('form_excluir', 'noticias_alterar_capa.asp');
	document.form_excluir.submit();
}
function atualiza_capa_artigo() {
	muda_action('form_excluir', 'artigos_alterar_capa.asp');
	document.form_excluir.submit();
}
