   function Dados(valor) {
      //verifica se o browser tem suporte a ajax
	  try {
         ajax = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {
         try {
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
         }
	     catch(ex) {
            try {
               ajax = new XMLHttpRequest();
            }
	        catch(exc) {
               alert("Esse browser nï¿½o tem recursos para uso do Ajax");
               ajax = null;
            }
         }
      }
	  //se tiver suporte ajax
	  if(ajax) {
	     //deixa apenas o elemento 1 no option, os outros sï¿½o excluï¿½dos
		 document.forms[0].txtCdFunc_destino.options.length = 1;

		 idOpcao  = document.getElementById("opcoes");

	     ajax.open("POST", "../func_ajax.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

		 ajax.onreadystatechange = function() {
            //enquanto estiver processando...emite a msg de carregando
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";
	        }
			//apï¿½s ser processado - chama funï¿½ï¿½o processXML que vai varrer os dados
            if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
			      processXML(ajax.responseXML);
			   }
			   else {
			       //caso nï¿½o seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "-- Primeiro selecione a Unidade/Setor --";
			   }
            }
         }
		 //passa o cï¿½digo do estado escolhido
	     var params = "destino="+valor;
         ajax.send(params);
      }
   }

   function processXML(obj){
      //pega a tag cidade
      var dataArray   = obj.getElementsByTagName("cidade");

	  //total de elementos contidos na tag cidade
	  if(dataArray.length > 0) {
	     //percorre o arquivo XML paara extrair os dados
         for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
			//contï¿½udo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
			var nome =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
			var sobrenome =  item.getElementsByTagName("sobrenome")[0].firstChild.nodeValue;

	        idOpcao.innerHTML = "-- Funcionários --";

			//cria um novo option dinamicamente
			var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = codigo;
				//atribui um texto
			    novo.text  = nome+" "+sobrenome;
				//novo.text  = sobrenome;
				//finalmente adiciona o novo elemento
				document.forms[0].txtCdFunc_destino.options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "--Primeiro selecione a Unidade/Setor--";
	  }
   }


// Funï¿½ï¿½es para admColaborador
	var div;

	function showHide(tr, imgExp, pg, div) {
		row = document.getElementById(tr);
		img = document.getElementById(imgExp);
		pag = document.getElementById(div);
		this.div = div;

		if (row.style.display == '') {
			row.style.display = 'none';
			img.src = '../imagens/mais.gif';
			pag.innerHTML = "";
		}
		else {
			row.style.display = '';
			img.src = '../imagens/menos.gif';
			preencheDiv(pg,div);
		}
	}
	
	function showHide2(valor) {
	switch (valor) {
		case "1":
			document.getElementById('div1').style.display = 'block';
			document.getElementById('div2').style.display = 'none';
			document.getElementById('div3').style.display = 'none';
			document.getElementById('div4').style.display = 'none';
			document.getElementById('div5').style.display = 'none';
			document.getElementById('div6').style.display = 'none';
			
		break;
		case "2":
			document.getElementById('div1').style.display = 'none';
			document.getElementById('div2').style.display = 'block';
			document.getElementById('div3').style.display = 'none';
			document.getElementById('div4').style.display = 'none';
			document.getElementById('div5').style.display = 'none';
			document.getElementById('div6').style.display = 'none';
		break;
		case "3":
			document.getElementById('div1').style.display = 'none';
			document.getElementById('div2').style.display = 'none';
			document.getElementById('div3').style.display = 'block';
			document.getElementById('div4').style.display = 'none';
			document.getElementById('div5').style.display = 'none';
			document.getElementById('div6').style.display = 'none';
		break;
		case "4":
			document.getElementById('div1').style.display = 'none';
			document.getElementById('div2').style.display = 'none';
			document.getElementById('div3').style.display = 'none';
			document.getElementById('div4').style.display = 'block';
			document.getElementById('div5').style.display = 'none';
			document.getElementById('div6').style.display = 'none';
		break;
		case "5":
			document.getElementById('div1').style.display = 'none';
			document.getElementById('div2').style.display = 'none';
			document.getElementById('div3').style.display = 'none';
			document.getElementById('div4').style.display = 'none';
			document.getElementById('div5').style.display = 'block';
			document.getElementById('div6').style.display = 'none';
		break;
		case "6":
			document.getElementById('div1').style.display = 'none';
			document.getElementById('div2').style.display = 'none';
			document.getElementById('div3').style.display = 'none';
			document.getElementById('div4').style.display = 'none';
			document.getElementById('div5').style.display = 'none';
			document.getElementById('div6').style.display = 'block';
		break;
				
	}
}

	var xmlHttp

	function preencheDiv(pg) {
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null) {
	  		alert ("Your browser does not support AJAX!");
			return;
		}

		var url=pg;
		xmlHttp.onreadystatechange=function () {
			if (xmlHttp.readyState==4) {
				document.getElementById(div).innerHTML=xmlHttp.responseText;
			}
		};

		xmlHttp.open("GET",url,true);
		xmlHttp.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
		xmlHttp.send(null);
	}

	function GetXmlHttpObject()	{
		var xmlHttp=null;
		try {
	  		// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
	  	}
		catch (e) {
		  // Internet Explorer
	  		try {
			    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		    }
			catch (e) {
			    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		    }
		}
		return xmlHttp;
	}

// ============= FUNï¿½ï¿½O PARA SUBMETER OS DADOS DA TELA ADM ===================
	function submitForm(form,url,confirmar){
		form.action = url;
		vetItens = form.rdOpcao;
		bolChecked = false;
		for(i=0; i<vetItens.length; i++){
			if(vetItens[i].checked){
				bolChecked = true;
				break;
			}
		}

		if(bolChecked || (form.rdOpcao.checked)){
			if(confirmar){
				//if(confirm('Deseja realmente executar a operacao?'))
					form.submit();
			}else{
				form.submit();
			}
		}else{
			alert('Escolha um Item!');
		}
	}
	
	function submitForm2(form,url){
		form.action = url;
		//vetItens = form.rdOpcao;
		
				form.submit();
		
	}
// ============= FUNï¿½ï¿½O PARA ABRIR JANELAS ===================

function abrirJanela(url){
	window.open(url, 'janela', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no, width=750, height=300, left=20, top=20, screenX=20, screenY=20');
}

// ============= FUNï¿½ï¿½O PARA PASSAR VALORES PARA UMA Pï¿½GINA ===================

function passaValoresfrmAgendanavio(valor1, valor2){
	window.opener.document.frmAgendanavio.txtVeiculoTransporte.value 	= valor1;
	window.opener.document.frmAgendanavio.txtCodVeiculoTransporte.value	= valor2;
	window.opener.focus();
	close();
}



// ============= FUNï¿½ï¿½O PARA PASSAR VALORES PARA UMA Pï¿½GINA ===================

function passaValores(oForm,array1,array2){
	for(i=0;i<array1.length;i++){
       window.opener.document[oForm].elements[array1[i]].value	= array2[i];
    }
	window.opener.focus();
	close();
}

// ============= FUNï¿½ï¿½O PARA FECHAR JANELAS ===================

function fechaJanela(){
	window.close();
}

//=================== 
function Formata(campo,tammax,teclapres,decimal) {
	var tecla = teclapres.keyCode;
	vr = Limpar(campo.value,"0123456789");
	tam = vr.length;
	dec=decimal

	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 <= dec )
		{ campo.value = vr ; }

		if ( (tam > dec) && (tam <= 5) ){
			campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
			if ( (tam >= 6) && (tam <= 8) ){
				campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ;
			}
			if ( (tam >= 9) && (tam <= 11) ){
				campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
				if ( (tam >= 12) && (tam <= 14) ){
					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 - dec, tam ) ; }
					if ( (tam >= 15) && (tam <= 17) ){
						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 ) ;}
	}

}