	// JavaScript Document
	var aux;
	var idOpcao;		
	var idOpcao1;	
	var idOpcao2;
	var idOpcao3;  
	var retorno;
	var text;
	var id_potencia;
	
	function SelecionaProdutoOleo() {		
      //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) {			
		    geraXMLPotencias();		  
	  } 
   }
   
   function geraXMLPotencias(){	
   		//deleteOption(document.forms[0].id_potencia_oleo);	
        idOpcao  = document.getElementById("potencias");		
	   	idOpcao1  = document.getElementById("idTipoOleo").value;	
	   	idOpcao2  = document.getElementById("idClasseOleo").value;	
		retorno   = document.getElementById("retorno").value;    
		 
	   ajax.open("POST", "seleciona_potencias.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 = "...";   
	   		}
	   		//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 = "...";
		   		}
       		}
       }
	    //passa o código 
	   var params = "t="+idOpcao1;	   
       ajax.send(params);   	   
   }
   
   function processXML(obj){	        
      var dataArray   = obj.getElementsByTagName("potencias_cat"); 
	  
	  //alert(document.getElementById("pot").value);

	  //total de elementos contidos na tag 
	  if(dataArray.length > 0) {  	  			 
	     if(retorno != 'produtos_oleo' && retorno != 'produtos'){
			text = '<label for="idPotencia">POTÊNCIA (kVA)</label> <br />'+
		 		   '<select name="id_potencia_oleo" id="idPotenciaOleo" onchange="javascript:geraXMLProdutoOleo();">';															
		 }else{
			text = '<label for="idPotencia">POTÊNCIA (kVA)</label> '+
		 		   '<select name="id_potencia_oleo" id="idPotenciaOleo" onchange="javascript:geraXMLProdutoOleo();">';																 
		 }
		 
		 //percorre o arquivo XML 
         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 seg    =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;
			
			if(retorno == 'produtos_oleo'){
				var pot = document.getElementById("pot").value;
				if(pot == codigo){					
					text += '<option value="'+codigo+'" id="potencias" selected="selected" >'+seg+'</option>';        		
				}else{					
					text += '<option value="'+codigo+'" id="potencias" >'+seg+'</option>';        		
				}
			}else{
				text += '<option value="'+codigo+'" id="potencias" >'+seg+'</option>';        			
			}			
		 }		 
		 text += '</select>';		 
		 document.getElementById('potencias_oleo').innerHTML = text ;
		 geraXMLProdutoOleo();
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		//idOpcao.innerHTML = "...";
	  }  
   }
   
   function geraXMLProdutoOleo(){	   
	   
	   idOpcao1  = document.getElementById("idTipoOleo").value;	
	   idOpcao2  = document.getElementById("idClasseOleo").value;	   
	   idOpcao3  = document.getElementById("idPotenciaOleo").value;	   
	   retorno   = document.getElementById("retorno").value;	  
	   
	   ajax.open("POST", "seleciona_produtos_oleo.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 = "...";   
	       }
		   //após ser processado - chama função processXML que vai varrer os dados
           if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {				   
			      processXMLProdutoOleo(ajax.responseXML);
			   }
			   else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   //idOpcao.innerHTML = "...";
			   }
           }
       }
	   //passa o código 
	   var params = "subcat="+idOpcao1+"&classe="+idOpcao2+"&potencia="+idOpcao3;	  
       ajax.send(params);        	   
   }
   
   function processXMLProdutoOleo(obj){	   	
      var dataArray   = obj.getElementsByTagName("infos_produto");
      
	  //total de elementos contidos na tag 
	  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 id_produto = item.getElementsByTagName("id_produto")[0].firstChild.nodeValue;
			var id_subCat = item.getElementsByTagName("id_subCat")[0].firstChild.nodeValue;
			var altura = item.getElementsByTagName("altura")[0].firstChild.nodeValue;
			var comprimento = item.getElementsByTagName("comprimento")[0].firstChild.nodeValue;
			var largura = item.getElementsByTagName("largura")[0].firstChild.nodeValue;
			var massa = item.getElementsByTagName("massa")[0].firstChild.nodeValue;
			var total = item.getElementsByTagName("total")[0].firstChild.nodeValue;				
			
			document.getElementById("altura_oleo").innerHTML  = altura;
			document.getElementById("comprimento_oleo").innerHTML  = comprimento;		 
			document.getElementById("largura_oleo").innerHTML  = largura;		 
			document.getElementById("massa_oleo").innerHTML  = massa;		 
			document.getElementById("total_oleo").innerHTML  = total;		
			
			
			if(document.getElementById("retorno").value != 'index'){					
				if(id_subCat == 2){
					document.getElementById("subCat").innerHTML	= 'Imersos em óleo mineral. De 3 kVA a 100 kVA - 15 kV, 24.2 kV, 36.2 kV.';
				}else if(id_subCat == 3){
					document.getElementById("subCat").innerHTML	= 'Imersos em óleo mineral. De 15 kVA a 500 kVA - 15 kV, 24.2 kV, 36.2 kV.';
				}	
			}
			
			if(document.getElementById("retorno").value != 'produtos_oleo'){					
				document.getElementById("botaoOleo").href  = 'produtos_oleo.php?transformador_a_oleo=0&id_produto='+id_produto+'&tipo='+idOpcao1+'&potencia='+idOpcao3+'&retorno='+retorno;
				
			}else{					
				var imagem_prod = item.getElementsByTagName("imagem_prod")[0].firstChild.nodeValue;
				var figura_prod = item.getElementsByTagName("figura_prod")[0].firstChild.nodeValue;				
				var video = item.getElementsByTagName("video")[0].firstChild.nodeValue;
				var arquivo = item.getElementsByTagName("arquivo")[0].firstChild.nodeValue;
				
				//alert(imagem_prod);
				if(imagem_prod != undefined){ 					
					document.getElementById("link_imagem_prod").href  = imagem_prod;
					document.getElementById("imagem_prod").src  = "thumb.php?src="+imagem_prod+"&x=100&y=139&f=0";
				}
			
				if(figura_prod != undefined){ 
					document.getElementById("link_figura_prod").href  = figura_prod;
					document.getElementById("figura_prod").src  = "thumb.php?src="+figura_prod+"&x=250&y=210&f=0";
				}
			
				if(video != "sem"){					
					document.getElementById("video").href  = "player.php?caminhoVideo="+video;
					document.getElementById("video").innerHTML = "Ver vídeo";
					document.getElementById("video").style.display = 'block';					
				}else{
					document.getElementById("video").style.display = 'none';	
				}
			
				if(arquivo != "sem"){
					document.getElementById("arquivo").href  = "../site/"+arquivo;						
					document.getElementById("arquivo").innerHTML  = "Arquivo"
										
					tipo = arquivo.substring(arquivo.length-4,arquivo.length);
					tipo = tipo.toLowerCase();				
					
					if (tipo == "jpeg"){
						document.getElementById("arquivo").className  = "jpg";	
					}else if (tipo == ".jpg"){
						document.getElementById("arquivo").className  = "jpg";
					}else if (tipo == ".pdf"){
						document.getElementById("arquivo").className  = "pdf";
					}else if (tipo == ".pps") {
						document.getElementById("arquivo").className  = "pps";
					}else if (tipo == ".doc") {
						document.getElementById("arquivo").className  = "doc";
					}else if (tipo == ".xls") {
						document.getElementById("arquivo").className  = "xls";
					}else if (tipo == ".zip") {
						document.getElementById("arquivo").className  = "zip";
					}else if (tipo == ".flv") {
						document.getElementById("arquivo").className  = "video";
					}else{
						
					}
					document.getElementById("arquivo").style.display = 'block';
					
				}else{
					document.getElementById("arquivo").style.display = 'none';
				}			
			}
			
			document.getElementById("cotacaoOleo").href = 'cotacao.php?transformador_a_oleo=0&id_produto='+id_produto+'&potencia='+idOpcao3+'&retorno='+retorno;
			
			if(aux == 1){
				geraXMLProdutoSeco();
			}		
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		//idOpcao.innerHTML = "...";
	  }  
   }
   
   function SelecionaProdutoSeco() {	   
      //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) {		  
		  geraXMLProdutoSeco();
	  } 
   }
   
   function geraXMLProdutoSeco(){	     	
       idOpcao1  = document.getElementById("idTipoSeco").value;	
	   idOpcao2  = document.getElementById("idClasseSeco").value;
	   idOpcao3  = document.getElementById("idPotenciaSeco").value;
	   retorno   = document.getElementById("retorno").value;	   
	   
	   ajax.open("POST", "seleciona_produtos_seco.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 = "...";   
	       }
		   //após ser processado - chama função processXML que vai varrer os dados
           if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {				   
			      processXMLProdutoSeco(ajax.responseXML);
			   }
			   else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   //idOpcao.innerHTML = "...";
			   }
           }
       }
	   //passa o código do estado escolhido
	   var params = "subcat="+idOpcao1+"&classe="+idOpcao2+"&potencia="+idOpcao3;		   
       ajax.send(params);        	   
   }
   
   function processXMLProdutoSeco(obj){	   
      //pega a tag 
      var dataArray   = obj.getElementsByTagName("infos_produto");
      
	  //total de elementos contidos na tag 
	  if(dataArray.length > 0) {	     
		 //percorre o arquivo XML para extrair os dados
         for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
			
			//contéudo dos campos no arquivo XML
			var id_produto = item.getElementsByTagName("id_produto")[0].firstChild.nodeValue;
			var altura = item.getElementsByTagName("altura")[0].firstChild.nodeValue;
			var comprimento = item.getElementsByTagName("comprimento")[0].firstChild.nodeValue;
			var largura = item.getElementsByTagName("largura")[0].firstChild.nodeValue;			
			var total = item.getElementsByTagName("total")[0].firstChild.nodeValue;			
			
			document.getElementById("altura_seco").innerHTML  = altura;
			document.getElementById("comprimento_seco").innerHTML  = comprimento;		 
			document.getElementById("largura_seco").innerHTML  = largura;		 			
			document.getElementById("total_seco").innerHTML  = total;			
			
			if(document.getElementById("retorno").value != 'produtos_seco'){				
				document.getElementById("botaoSeco").href  = 'produtos_seco.php?transformador_a_seco=0&id_produto='+id_produto+'&tipo='+idOpcao1+'&retorno='+retorno;
			}else{					
				var imagem_prod = item.getElementsByTagName("imagem_prod")[0].firstChild.nodeValue;
				var figura_prod = item.getElementsByTagName("figura_prod")[0].firstChild.nodeValue;				
				var video = item.getElementsByTagName("video")[0].firstChild.nodeValue;
				var arquivo = item.getElementsByTagName("arquivo")[0].firstChild.nodeValue;				
				
				if(imagem_prod != undefined){ 					
					document.getElementById("link_imagem_prod").href  = imagem_prod;
					document.getElementById("imagem_prod").src  = "thumb.php?src="+imagem_prod+"&x=100&y=139&f=0";
				}
			
				if(figura_prod != undefined){ 
					document.getElementById("link_figura_prod").href  = figura_prod;
					document.getElementById("figura_prod").src  = "thumb.php?src="+figura_prod+"&x=250&y=210&f=0";
				}
			
				if(video != "sem"){
					document.getElementById("video").href  = "player.php?caminhoVideo="+video;
					document.getElementById("video").innerHTML = "Ver vídeo";
					document.getElementById("video").style.display = 'block';
				}else{
					document.getElementById("video").style.display = 'none';	
				}
			
				if(arquivo != "sem"){
					document.getElementById("arquivo").href  = "../site/"+arquivo;	
					document.getElementById("arquivo").innerHTML  = "Arquivo"
										
					tipo = arquivo.substring(arquivo.length-4,arquivo.length);
					tipo = tipo.toLowerCase();				
					
					if (tipo == "jpeg"){
						document.getElementById("arquivo").className  = "jpg";	
					}else if (tipo == ".jpg"){
						document.getElementById("arquivo").className  = "jpg";
					}else if (tipo == ".pdf"){
						document.getElementById("arquivo").className  = "pdf";
					}else if (tipo == ".pps") {
						document.getElementById("arquivo").className  = "pps";
					}else if (tipo == ".doc") {
						document.getElementById("arquivo").className  = "doc";
					}else if (tipo == ".xls") {
						document.getElementById("arquivo").className  = "xls";
					}else if (tipo == ".zip") {
						document.getElementById("arquivo").className  = "zip";
					}else if (tipo == ".flv") {
						document.getElementById("arquivo").className  = "video";
					}else{
						
					}
					document.getElementById("arquivo").style.display = 'block';
					
				}else{
					document.getElementById("arquivo").style.display = 'none';
				}			
			}
			
			document.getElementById("cotacaoSeco").href = 'cotacao.php?transformador_a_seco=0&id_produto='+id_produto+'&potencia='+idOpcao3+'&retorno='+retorno;	
			
			if(aux == 1){
				geraXMLProdutoForca();
			}		
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		//idOpcao.innerHTML = "...";
	  }  
   }
   
   function SelecionaProdutoForca() {
      //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) {	   	  
		  geraXMLProdutoForca();
	  } 
   }
   
   function geraXMLProdutoForca(){	   
   	   idOpcao1  = document.getElementById("idClasseForca").value;
	   idOpcao2  = document.getElementById("idPotenciaForca").value;
	   retorno   = document.getElementById("retorno").value;
	   
	   ajax.open("POST", "seleciona_produtos_forca.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 = "...";   
	       }
		   //após ser processado - chama função processXML que vai varrer os dados
           if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
			      processXMLProdutoForca(ajax.responseXML);
			   }
			   else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   //idOpcao.innerHTML = "...";
			   }
           }
       }
	   //passa o código 
	   var params = "classe="+idOpcao1+"&potencia="+idOpcao2;	   
       ajax.send(params);        	   
   }
   
   function processXMLProdutoForca(obj){      
      var dataArray   = obj.getElementsByTagName("infos_produto");
      
	  //total de elementos contidos na tag 
	  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 id_produto = item.getElementsByTagName("id_produto")[0].firstChild.nodeValue;
			var altura = item.getElementsByTagName("altura")[0].firstChild.nodeValue;
			var comprimento = item.getElementsByTagName("comprimento")[0].firstChild.nodeValue;
			var largura = item.getElementsByTagName("largura")[0].firstChild.nodeValue;			
			var massa = item.getElementsByTagName("massa")[0].firstChild.nodeValue;			
			var total = item.getElementsByTagName("total")[0].firstChild.nodeValue;			
			
			document.getElementById("altura_forca").innerHTML  = altura;
			document.getElementById("comprimento_forca").innerHTML  = comprimento;		 
			document.getElementById("largura_forca").innerHTML  = largura;		 			
			document.getElementById("massa_forca").innerHTML  = massa;		 			
			document.getElementById("total_forca").innerHTML  = total;		
			
			if(document.getElementById("retorno").value != 'produtos_forca'){				
				document.getElementById("botaoForca").href  = 'produtos_forca.php?transformador_de_forca=0&id_produto='+id_produto+'&retorno='+retorno;
			}else{					
				var imagem_prod = item.getElementsByTagName("imagem_prod")[0].firstChild.nodeValue;
				var figura_prod = item.getElementsByTagName("figura_prod")[0].firstChild.nodeValue;				
				var video = item.getElementsByTagName("video")[0].firstChild.nodeValue;
				var arquivo = item.getElementsByTagName("arquivo")[0].firstChild.nodeValue;			
				
				if(imagem_prod != undefined){ 					
					document.getElementById("link_imagem_prod").href  = imagem_prod;
					document.getElementById("imagem_prod").src  = "thumb.php?src="+imagem_prod+"&x=100&y=139&f=0";
				}
			
				if(figura_prod != undefined){ 
					document.getElementById("link_figura_prod").href  = figura_prod;
					document.getElementById("figura_prod").src  = "thumb.php?src="+figura_prod+"&x=250&y=210&f=0";
				}
			
				if(video != "sem"){
					document.getElementById("video").href  = "player.php?caminhoVideo="+video;
					document.getElementById("video").innerHTML = "Ver vídeo";
					document.getElementById("video").style.display = 'block';
				}else{
					document.getElementById("video").style.display = 'none';	
				}
			
				if(arquivo != "sem"){
					document.getElementById("arquivo").href  = "../site/"+arquivo;	
					document.getElementById("arquivo").innerHTML  = "Arquivo"
										
					tipo = arquivo.substring(arquivo.length-4,arquivo.length);
					tipo = tipo.toLowerCase();				
					
					if (tipo == "jpeg"){
						document.getElementById("arquivo").className  = "jpg";	
					}else if (tipo == ".jpg"){
						document.getElementById("arquivo").className  = "jpg";
					}else if (tipo == ".pdf"){
						document.getElementById("arquivo").className  = "pdf";
					}else if (tipo == ".pps") {
						document.getElementById("arquivo").className  = "pps";
					}else if (tipo == ".doc") {
						document.getElementById("arquivo").className  = "doc";
					}else if (tipo == ".xls") {
						document.getElementById("arquivo").className  = "xls";
					}else if (tipo == ".zip") {
						document.getElementById("arquivo").className  = "zip";
					}else if (tipo == ".flv") {
						document.getElementById("arquivo").className  = "video";
					}else{
						
					}
					
					document.getElementById("arquivo").style.display = 'block';
					
				}else{
					document.getElementById("arquivo").style.display = 'none';
				}			
			}
			
			document.getElementById("cotacaoForca").href = 'cotacao.php?transformador_de_forca=0&id_produto='+id_produto+'&potencia='+idOpcao2+'&retorno='+retorno+'&forca=sim';
			
			if(aux == 1){
				aux = 0;
			}				
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		//idOpcao.innerHTML = "...";
	  }  
   }
   
   function SelecionaProdutos(){	 
	  //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) {		  
	      aux = 1;
		  geraXMLPotencias();
	  }
   }
   
   function SelecionaProdutoCotacao(){
		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) {	      
		  geraXMLPotenciasCotacao();
	  }
   }
   
   function geraXMLPotenciasCotacao(){	   	    
       idOpcao  = document.getElementById("potencias");		
	   idOpcao1  = document.getElementById("idTipo").value;	
	   idOpcao2  = document.getElementById("txtClasse").value;
	   idOpcao3  = document.getElementById("txtPotencia").value;  	    
	   document.forms[0].id_potencia.options.length = 1;	
		 
	   ajax.open("POST", "seleciona_potencias.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 = "...";   
	   		}
	   		//após ser processado - chama função processXML que vai varrer os dados
       		if(ajax.readyState == 4 ) {
		   		if(ajax.responseXML) {
			   		processXMLPotenciasCotacao(ajax.responseXML);
		   		} else {
			   		//caso não seja um arquivo XML emite a mensagem abaixo
			   		//idOpcao.innerHTML = "...";
		   		}
       		}
       }
	    //passa o código 			
	   var params = "t="+idOpcao1;		   
       ajax.send(params);   	   
   }
   
   function processXMLPotenciasCotacao(obj){     
      var dataArray   = obj.getElementsByTagName("potencias_cat");

	  //total de elementos contidos na tag 
	  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 seg    =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;		        	
			
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
			
			//atribui um ID a esse elemento
			novo.setAttribute("id", "desc");
			
			//atribui um valor
			novo.value = codigo;
			
			//atribui um texto
			novo.text  = seg;
			
			if(document.getElementById("retorno").value == 'cotacao'){
				id_potencia = document.getElementById("id_potencia").value;
				if(id_potencia == codigo){
					novo.selected = 'selected';	
				}
			}else if(i == 0){
				novo.selected = 'selected';	
			}
			
			//finalmente adiciona o novo elemento
			document.forms[0].id_potencia.options.add(novo);			
			DadosTensoes();
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		//idOpcao.innerHTML = "...";
	  }  
   }
   
   function DadosTensoes(){
		document.forms[0].tensao.options.length = 1;	     
		idOpcao  = document.getElementById("opcoes");			 
		idOpcao1  = document.getElementById("idTipo").value;
				 
	    ajax.open("POST", "seleciona_tensoes.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 = "...";   
	        }
			//após ser processado - chama função processXML que vai varrer os dados
            if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
			      processXMLTensoes(ajax.responseXML);
			   }
			   else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   //idOpcao.innerHTML = "...";
			   }
            }
         }
		 //passa o código do estado escolhido
	     params = "t="+idOpcao1;
         ajax.send(params);   
   }
   
   function processXMLTensoes(obj){      
      var dataArray   = obj.getElementsByTagName("tensoes_desc");
      
	  //total de elementos contidos na tag 
	  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 seg    =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;       		
			
			//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  = seg;
			
			if(i == 0){
				novo.selected = 'selected';	
			}
			//finalmente adiciona o novo elemento
			document.forms[0].tensao.options.add(novo);			
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "...";
	  }  
   }