   function Dados(valor) {
     if(valor == ""){
		document.getElementById("opcoes").innerHTML = "--Primeiro selecione o Produto--";
		document.getElementById("linha").disabled = true;
	 }
	 else {
	  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.getElementById("linha").options.length = 1;   
		 idOpcao  = document.getElementById("opcoes");
		 
	     ajax.open("POST", "linhas.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...";
			   document.getElementById("linha").disabled = true;
	        }
			//após ser processado - chama função processXML que vai varrer os dados
            if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
			      processXML(ajax.responseXML);
				  document.getElementById("linha").disabled = false;
			   }
			   else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "--Primeiro selecione o Produto--";
				   document.getElementById("linha").disabled = true;
			   }
            }
         }
		 //passa o código do estado escolhido
	     var params = "produto="+valor;
         ajax.send(params);
      }
	  
   }
  
   }
   function processXML(obj){
      //pega a tag cidade
      var dataArray   = obj.getElementsByTagName("linha");
      
	  //total de elementos contidos na tag cidade
	  if(dataArray.length > 0) {
	     //percorre o arquivo XML paara extrair os dados
         var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = "";
				//atribui um texto
			    novo.text  = " ";
				//finalmente adiciona o novo elemento
				document.getElementById("linha").options.add(novo);
				
         var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = "";
				//atribui um texto
			    novo.text  = " ";
				//finalmente adiciona o novo elemento
				document.getElementById("linha").options.add(novo);
				
	     var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = "0";
				//atribui um texto
			    novo.text  = "Todas as Linhas";
				//finalmente adiciona o novo elemento
				document.getElementById("linha").options.add(novo);
				
	     var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes");
				//atribui um valor
			    novo.value = "";
				//atribui um texto
			    novo.text  = "---";
				//finalmente adiciona o novo elemento
				document.getElementById("linha").options.add(novo);
		 
		 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 descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
			
	        idOpcao.innerHTML = "--Selecione--";
			
			//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  = descricao;
				//finalmente adiciona o novo elemento
				document.getElementById("linha").options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "-- Selecione --";
	  }	  
   }
   function vai(){
	var prod = document.getElementById("produto").value;
	var lin = document.getElementById("linha").value;
	if(lin != "" && prod != ""){
		
		
			document.location.href = "produtos.php?prod="+prod+"&lin="+lin;	

   
	}
   }
   function busca_uni (){
	var valor = document.getElementById("n_uni").value;
	var valor2 = valor.replace(/\s+/g,"%20");
	if(valor != ""){
	document.location.href = "produtos.php?cond=1&busca="+valor2;
	}
   }
   function busca_ori (){
	var valor = document.getElementById("n_ori").value;
	var valor2 = valor.replace(/\s+/g,"%20");
	if(valor != ""){
	document.location.href = "produtos.php?cond=2&busca="+valor2;
   		}
   }
   function busca_alt (){
	var valor = document.getElementById("n_alt").value;
	var valor2 = valor.replace(/\s+/g,"%20");
		if(valor != ""){
	document.location.href = "produtos.php?cond=3&busca="+valor2;
   		}
   }
   function envia_contato(){
	   if(document.getElementById("nome").value == ""){
		   alert("Informe o Nome");
		   document.getElementById("nome").focus();
		   return false;
	   }
	   else if(document.getElementById("email").value == "" && document.getElementById("fone").value == ""){
		   alert("Informe o E-mail ou o Telefone!");
		   document.getElementById("email").focus();
		   return false;
	   }
	   else if(document.getElementById("fone").value != "" && document.getElementById("foneddd").value == ""){
		   alert("Informe o DDD!");
		   document.getElementById("foneddd").focus();
		   return false;
	   }
	   else if(document.getElementById("mensagem").value == ""){
		   alert("Informe a Mensagem!");
		   document.getElementById("mensagem").focus();
		   return false;
	   }
	   
   }
   
