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].listCidades.options.length = 1;
		idOpcao = document.getElementById("opcoes");
		
		ajax.open("POST", "ajax/cidades.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 cidade--";
			   }
            }
         }

		 // Passa o código do estado escolhido
	     var params = "estado="+valor;
         ajax.send(params);
	}

}// Close function
   
   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 descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
			
	        idOpcao.innerHTML = "--Selecione um bairro mais proximo de voc&ecirc;--";
			
			//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.forms[0].listCidades.options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "--Primeiro selecione a cidade--";
	  }	  
   }

function GoURL(url)
{
	/*var x = document.getElementById("listEstados");	
	alert(x.selectedIndex);
	location.href='/ajax/cliente.php?codigo='+url+'&cidade='+x.options[x.selectedIndex].value;*/

}


function MM_jumpMenu(selObj)
{ //v3.0
	eval("parent.location='?pagina=produto&codigo="+selObj.options[selObj.selectedIndex].value+"'");
}


// JavaScript Document
startList = function() {
if (document.all&&document.getElementById)
{
	navRoot = document.getElementById("menu");
	for(i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
	node.onmouseover=function() {
	this.className+=" over";
	}
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

function _dSectionExpand(n)
{
	// Ocuta todos os outros itens
	for(var i=1; i<=5; i++)
	{
		_dSectionCollapse(i);
	}

	document.getElementById("xSec"+n).style.display = "block";
	document.getElementById("cSec"+n).style.display = "none";
}

function _dSectionCollapse(n)
{
	document.getElementById("xSec"+n).style.display = "none";
	document.getElementById("cSec"+n).style.display = "block";
}

function DivFichaTecnica(IdDiv)
{
	var ficha = document.getElementById(IdDiv).style.display;
	//var link_ficha  = document.getElementById('link-ficha').style.color;

	if ( ficha == 'none')
	{
		document.getElementById(IdDiv).style.display = 'block';
		document.getElementById('link-ficha').style.color = 'red';
	}
	else
	{
		document.getElementById(IdDiv).style.display = 'none';
		document.getElementById('link-ficha').style.color = '#669999';			
	}		
}
