			function GM_Upload(campo,valor)
			{
					document.getElementById(campo).value = valor;
			}
			function GM_Limpa_Upload(campo1,campo2)
			{
					document.getElementById(campo1).value = "";
					document.getElementById(campo2).value = "";
			}
			function GM_Altera_foto(formulario,campo)
			{
						var erro = "";
						
						vErro_img = 0;
						if (document.getElementById(formulario)[campo].value != "") 
						{ 
							arquivo = (document.getElementById(formulario)[campo].value); 
							tipo = arquivo.substring(arquivo.length-4,arquivo.length); 
							tipo = tipo.toLowerCase() 
							
							if ((tipo != ".jpg" && tipo != ".jpeg"))
							{ 
								vErro_img = 1; 
							} 
						}
		
						if (vErro_img == 1) 
						{ 
							erro = erro + "Só é permitido o envio de imagens com extensão '.jpg' ou '.jpeg'!\n";
						}
						if (document.getElementById(formulario)[campo].value == '')
						{
								erro = erro + "Escolha uma imagem!";
						}
						
						if (erro != '')
						{
								alert(erro);
						}
						else
						{
								MM_showHideLayers('pop01','','hide');
								document.getElementById(formulario).submit();
						}
			}
			function GM_Remover_foto(formulario)
			{
					if ( confirm("Deseja remover sua foto?") )
					{
						document.getElementById(formulario).controle.value = 2;    
						setTimeout("document.getElementById('"+formulario+"').submit()",0);    
					}
			}
			function GM_Centraliza_IMG(objeto,imagem)
			{
					if(objeto != '' && imagem != '')
					{
							if(document.getElementById(objeto) && document.getElementById(imagem))
							{
							
									var vAltura_Obj = parseInt(document.getElementById(objeto).style.height);
									var vAltura_IMG = parseInt(document.getElementById(imagem).height)
									
									var vLargura_Obj = parseInt(document.getElementById(objeto).style.width);
									var vLargura_IMG = parseInt(document.getElementById(imagem).width)
									
									//alert(vAltura_Obj);
									//alert(vLargura_IMG);
									
									var vDiferenca_Altura = (vAltura_Obj - vAltura_IMG)/2;
									var vDiferenca_Largura = (vLargura_Obj - vLargura_IMG)/2;
									
									document.getElementById(imagem).style.paddingTop = vDiferenca_Altura + 'px';
									document.getElementById(imagem).style.paddingLeft = vDiferenca_Largura + 'px';
							}
					}
					
			}
			function GM_Menu_Trabalho(titulo_menu,subtitulo_menu,nome_area)
			{
					if(document.getElementById(subtitulo_menu).style.display == 'none')
					{
							document.getElementById(titulo_menu).setAttribute('className','tituloOn');
							document.getElementById(titulo_menu).setAttribute('class','tituloOn');
							document.getElementById(subtitulo_menu).style.display = 'block';
					}
					else
					{
							document.getElementById(titulo_menu).setAttribute('className','titulo');
							document.getElementById(titulo_menu).setAttribute('class','titulo');
							document.getElementById(subtitulo_menu).style.display = 'none';
					}
					if (nome_area != '')
					{
							GM_Centraliza_IMG_Trabalho(nome_area);
					}
					return false;
			}
			function GM_Centraliza_IMG_Trabalho(nome_area)
			{
					if(nome_area != '')
					{
								for (x=1;x<=3;x++)
								{
										if(document.getElementById('li_' + nome_area + '_' + x) && document.getElementById('imagem_' + nome_area + '_' + x))
										{
										
												var vAltura_LI = parseInt(document.getElementById('li_' + nome_area + '_' + x).style.height);
												var vAltura_IMG = parseInt(document.getElementById('imagem_' + nome_area + '_' + x).height)
												
												var vDiferenca = (vAltura_LI - vAltura_IMG)/2;
												
												document.getElementById('imagem_' + nome_area + '_' + x).style.paddingTop = (vDiferenca-2) + 'px';
										}
								}
					}
					
			}
			
			//=======================================================================
			//função referentes a escolha do 3º nível
			//move de um campo para outro os itens escolhidos
			//=======================================================================
			function moveDualList( srcList, destList, moveAll ) {
		
			 if ((srcList.selectedIndex == -1 ) && (moveAll == false)) {
				 return;
			 }
		
			 newDestList = new Array( destList.options.length );
			 var len = 0;
		
			 for( len = 0; len < destList.options.length; len++ ) {
				 if ( destList.options[ len ] != null ) {
					 newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[ len ].defaultSelected, destList.options[len].selected);
				 }
			 }
		
			 for( var i = 0; i < srcList.options.length; i++ ) { 
				 if (srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll))
				 {
		
						newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
						len++;
				 }
			 }
		
			 newDestList.sort();
			 
			 
			 for ( var j = 0; j < newDestList.length; j++ ) {
				 if ( newDestList[ j ] != null ) {
					 destList.options[ j ] = newDestList[ j ];
				 }
			 }
		
			 for( var i = srcList.options.length - 1; i >= 0; i-- ) { 
				 if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
						srcList.options[i] = null;
				 }
			 }
		}
		function GM_AplicaMascara_Moeda(vElement)
		{  
				var vAplicaMascara = vElement.value;
				vAplicaMascara = vAplicaMascara.replace(/\D/g,"")  //permite digitar apenas números
				vAplicaMascara = vAplicaMascara.replace(/[0-9]{13}/,"inválido")   //limita pra máximo 999.999.999,99
				vAplicaMascara = vAplicaMascara.replace(/(\d{1})(\d{7})$/,"$1.$2")  //coloca ponto antes dos últimos 8 digitos
				vAplicaMascara = vAplicaMascara.replace(/(\d{1})(\d{5})$/,"$1.$2")  //coloca ponto antes dos últimos 5 digitos
				vAplicaMascara = vAplicaMascara.replace(/(\d{1})(\d{1,2})$/,"$1,$2")    //coloca virgula antes dos últimos 2 digitos
				vElement.value = vAplicaMascara;
		}
		function soma(campo,campo_exibe,limite) 
		{ 
			var mais_um = eval(campo.value.length-1); 
			mais_um ++;
			if (campo.value.length>limite) 
			{
				campo.value = '';		
				campo.value = valor_limite;				
				alert("Limite de " + limite + " caracteres");
			}
			else
			{
				campo_exibe.value = '';	
				campo_exibe.value = eval(mais_um);	
				valor_limite = campo.value;		
			}	
			campo.focus();
		} 
		function GM_Aleatorio(minimo,maximo){
			
			numPosibilidades = maximo - minimo
			aleat = Math.random() * numPosibilidades
			return Math.round(parseInt(minimo) + aleat)
		}
		//funcao que abre popup
		function MM_openBrWindow(theURL,winName,features) { //v2.0
			popup = window.open(theURL,winName,features);
			popup.focus();
		}
		//funcao que insere evento na adm
		function GM_Insere_Evento(ID,Titulo,Status,Bloco)
		{
			
			if(Status == 1)
			{
					Status_nome = '<font color="#009900;">Liberado</font>';	
			}
			else if(Status == 2)
			{
					Status_nome = '<font color="#FF6600;">Expirado</font>';	
			}
			else
			{
					Status_nome = '<font color="#FF6600;">Não Lib.</font>';	
			}
			
			var posicao_tabela = parseInt(document.getElementsByName("ID_Lista_Evento[]").length)+1;
			
			var linha = document.getElementById('tabela_evento').insertRow(posicao_tabela)
			linha.id = "ID_Evento_" + ID;
			linha.className = 'tab-linha1';
		
			var celula1 = linha.insertCell(0)
			celula1.style.padding = '2px';
			celula1.style.width = '51%'
			//celula2.className = 'Arial_11_azul';
			
			var celula2 = linha.insertCell(1)
			celula2.style.padding = '2px';
			celula2.style.width = '27%'
			//celula1.className = 'Arial_11_azul';
			var conteudo_celula2 = "<center><input name='Ordem_" + ID + "' type='text' class='input-campos' id='Ordem_" + ID + "' onKeyPress=criaMascara(this,'###'); onKeyUp=criaMascara(this,'###'); value='' size='3' maxlength='3'></center>";
			
			var celula3 = linha.insertCell(2)
			celula3.style.padding = '2px';
			celula3.style.width = '14%'
			//celula1.className = 'Arial_11_azul';
			var conteudo_celula3 = Status_nome;
			
			var celula4 = linha.insertCell(3)
			celula4.style.padding = '2px';
			celula4.style.width = '8%'
			//celula1.className = 'Arial_11_azul';
			var conteudo_celula4 = "<center><input name='Conta_evento' id='Conta_evento' type='hidden' value='" +  ID + "'>";
			conteudo_celula4 = conteudo_celula4 + "<input name='ID_Lista_Evento[]' id='ID_Lista_Evento_" +  ID + "' type='hidden' value='" + ID + "'>";
			conteudo_celula4 = conteudo_celula4 + "<input type='button' class='input-botao' value='x' onclick=GM_Remove_Evento('ID_Evento_" + ID + "','1','" + ID + "','" + Bloco + "')></center>";
		
			celula1.innerHTML = Titulo;
			celula2.innerHTML = conteudo_celula2;
			celula3.innerHTML = conteudo_celula3;
			celula4.innerHTML = conteudo_celula4;
		
			document.getElementById('Total_eventos').value = parseInt(document.getElementById('Total_eventos').value) + 1;
			
			//alert(document.getElementById('Total_eventos').value);
			if(document.getElementById('tabela_nenhum_evento'))
			{
					if(parseInt(document.getElementById('Total_eventos').value) == 0)
					{
								document.getElementById('tabela_nenhum_evento').style.display = 'block';
								//document.getElementById('bt_salvar').style.display = 'none';
					}
					else
					{
								document.getElementById('tabela_nenhum_evento').style.display = 'none';
								document.getElementById('bt_salvar').style.display = 'block';
					}
			}
		
		}
		//funcao que remove evento na adm
		function GM_Remove_Evento(campo,pergunta,ID,Bloco)
		{
					if(pergunta == 1)
					{
					
								if ( confirm("Deseja remover o evento?") )
								{
										if (document.getElementById(campo))
										{
											var tr_remove = document.getElementById(campo);
											tr_remove.parentNode.removeChild(tr_remove);
										}
								}
								
					}
					else
					{
								if (document.getElementById(campo))
								{
									var tr_remove = document.getElementById(campo);
									tr_remove.parentNode.removeChild(tr_remove);
								}
					}
					//chama função que vai dar update no banco para editar o evento
					GM_Desmarca_Evento(ID,Bloco);
					document.getElementById('Total_eventos').value = parseInt(document.getElementById('Total_eventos').value) - 1;
					
					if(parseInt(document.getElementById('Total_eventos').value) == 0)
					{
								document.getElementById('tabela_nenhum_evento').style.display = 'block';
								//document.getElementById('bt_salvar').style.display = 'none';
					}
					else
					{
								document.getElementById('tabela_nenhum_evento').style.display = 'none';
								document.getElementById('bt_salvar').style.display = 'block';
					}
		}
		//função protege http://
		function GM_ValidaURL(url){
				var RegExp = /^(((ht|f)tp(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/;
				if(RegExp.test(url)){
						return true;
				}else{
						return false;
				}
		} 
		
		//funcão que retorna o dia da data
		function Dia(Data_DDMMYYYY)
		{
			string_data = Data_DDMMYYYY.toString();
			posicao_barra = string_data.indexOf("/");
			if (posicao_barra!= -1)
			{
				dia = string_data.substring(0,posicao_barra);
				return dia;
			}
			else
			{
				return false;
			}
		}
		
		//função que retorna o mês da data
		function Mes(Data_DDMMYYYY)
		{
			string_data = Data_DDMMYYYY.toString();
			posicao_barra = string_data.indexOf("/");
			if (posicao_barra!= -1)
			{
				dia = string_data.substring(0,posicao_barra);
				string_mes = string_data.substring(posicao_barra+1,string_data.length);
				posicao_barra = string_mes.indexOf("/");
				if (posicao_barra!= -1)
				{
					mes = string_mes.substring(0,posicao_barra);
					mes = Math.floor(mes);
					return mes;
				}
				else
				{
					return false;
				}
				
			}
			else
			{
				return false;
			}
		}
		
		//função que retorna o ano da data
		function Ano(Data_DDMMYYYY)
		{
			string_data = Data_DDMMYYYY.toString();
			posicao_barra = string_data.indexOf("/");
			if (posicao_barra!= -1)
			{
				dia = string_data.substring(0,posicao_barra);
				string_mes = string_data.substring(posicao_barra+1,string_data.length);
				posicao_barra = string_mes.indexOf("/");
				if (posicao_barra!= -1)
				{
					mes = string_mes.substring(0,posicao_barra);
					mes = Math.floor(mes);
					ano = string_mes.substring(posicao_barra+1,string_mes.length);
					return ano;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		//verifica se a data inicial e menor que a final
		function GM_compara_data(dt_inicio,dt_fim)
		{
			Var_Dia1=Dia(dt_fim);
			Var_Mes1=Mes(dt_fim);
			Var_Mes1=Math.floor(Var_Mes1)-1;
			Var_Ano1=Ano(dt_fim);
			var data1 = new Date(Var_Ano1,Var_Mes1,Var_Dia1);
			
			Var_Dia2=Dia(dt_inicio);
			Var_Mes2=Mes(dt_inicio);
			Var_Mes2=Math.floor(Var_Mes2)-1;
			Var_Ano2=Ano(dt_inicio);
			var data2 = new Date(Var_Ano2,Var_Mes2,Var_Dia2);
			
			var diferenca = data1.getTime() - data2.getTime();
			var diferenca = Math.floor(diferenca / (1000 * 60 * 60 * 24));
			//alert('Diferença em dias entre '+dt_inicio+' e '+dt_fim+' = '+diferenca);
			return diferenca
		}
		
		
		function GM_LiberaTodos(){
			for(i=0; i<document.getElementById('formulario').elements.length; i++){
				if(document.getElementById('formulario').elements[i].type=="checkbox"){
					document.getElementById('formulario').elements[i].checked=true;
				}
			}
		}
		
		function GM_BloqueiaTodos(){
			for(i=0; i<document.getElementById('formulario').elements.length; i++){
				if(document.getElementById('formulario').elements[i].type=="checkbox"){
					document.getElementById('formulario').elements[i].checked=false;
				}
			}
		}
