<!-- Begin

function horizontal() {

var navItems = document.getElementById("barra").getElementsByTagName("ul");

for (var i=0; i< navItems.length; i++) {
if((navItems[i].className == "menuvertical") || (navItems[i].className == "submenu"))
{
if(navItems[i].getElementsByTagName('ul')[0] != null)
{
navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "#66cc00";this.style.fontColor = "#FF0000";}
navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "#e7e7e7";}
}
}
}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}

function confirmaorcamento(idservico){

    if(document.formprinc.contato.value==""){
      alert("Você deve informar o seu nome!");
      document.formprinc.contato.focus();
      return false;
    }    
    
    if(document.formprinc.empresa.value==""){
      alert("Você deve informar a Empresa!");
      document.formprinc.empresa.focus();
      return false;
    }
    
    
    if(document.formprinc.fone.value==""){
      alert("Você deve informar o seu Fone!");
      document.formprinc.fone.focus();
      return false;
    }
    
    if(document.formprinc.email.value==""){

      alert("Você deve informar seu email para contato!");
      document.formprinc.email.focus();
      return false;

    }else{

      if(document.formprinc.email.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.formprinc.email.value)){
           alert("Seu e-mail para contato é inválido!");
           document.formprinc.email.focus();
           return false;
        }
      }
    }
    
    if(document.formprinc.iduf.value=="0"){
      alert("Você deve informar o Estado!");
      document.formprinc.iduf.focus();
      return false;
    }
    
    if(document.formprinc.idcidade.value==""){
      alert("Você deve informar a Cidade!");
      document.formprinc.idcidade.focus();
      return false;
    }
    if (idservico == 2) {
	    if(document.formprinc.produto.value==""){
	      alert("Você deve informar o Produto!");
	      document.formprinc.produto.focus();
	      return false;
	    }
	    
	    if(document.formprinc.quantidade.value==""){
	      alert("Você deve informar a Quantidade!");
	      document.formprinc.quantidade.focus();
	      return false;
	    }
    }
    if(!document.formprinc.termos.checked){
      alert("É necessário concordar com os termos de uso!");
      document.formprinc.termos.focus();
      return false;
    }
    
    
}

function confirmasolicitacao(){
	if(document.formprinc.email.value==""){
      alert("Você deve informar seu email.");
      document.formprinc.email.focus();
      return false;
    }else{
      if(document.formprinc.email.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.formprinc.email.value)){
           alert("Seu e-mail é inválido");
           document.formprinc.email.focus();
           return false;
        }
      }
    }
    
	if(!document.formprinc.termos.checked){
      alert("É necessário concordar com os termos de uso!");
      document.formprinc.termos.focus();
      return false;
    }
    
    
}
 
function confirmafacaparte(){
    
    
    if(document.formprinc.nomecontato.value==""){
      alert("Você deve informar o seu nome");
      document.formprinc.nomecontato.focus();
      return false;
    }
    
    if(document.formprinc.nome.value==""){
      alert("Você deve informar o Nome da Empresa.");
      document.formprinc.nome.focus();
      return false;
    }
    
    if(document.formprinc.fone.value==""){
      alert("Você deve informar o fone.");
      document.formprinc.fone.focus();
      return false;
    }
    
    if(document.formprinc.endereco.value==""){
      alert("Você deve informar o Endereço.");
      document.formprinc.endereco.focus();
      return false;
    }
    
    if(document.formprinc.iduf.value=="0"){
      alert("Você deve informar o Estado");
      document.formprinc.iduf.focus();
      return false;
    }
    
    if(document.formprinc.cnpj.value==""){
      alert("Você deve informar o CNPJ/CPF.");
      document.formprinc.cnpj.focus();
      return false;
    }
    
    var val = formprinc.cnpj.value;
	var base = val.substring(0, val.length-2);
	if (val.length != 11) {
	    //formprinc.cnpj.value = formatCpfCnpj(val, true, true);
		if (!isCnpj(val)) {
		  alert("CNPJ/CPF Não Informado/Inválido! \nDigite sem Pontuação ou nenhum outro caracter especial!");
          document.formprinc.cnpj.focus();
          return false;
		}
    } else {
        if (!isCpf(val)) {
		  alert("CPF/CPF Não Informado/Inválido! \nDigite sem Pontuação ou nenhum outro caracter especial!");
          document.formprinc.cnpj.focus();
          return false;
		}
	}
    
    if(document.formprinc.idcidade.value==""){
      alert("Você deve informar a Cidade");
      document.formprinc.idcidade.focus();
      return false;
    }

    if(document.formprinc.email.value==""){

      alert("Você deve informar seu email para contato.");
      document.formprinc.email.focus();
      return false;

    }else{

      if(document.formprinc.email.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.formprinc.email.value)){
           alert("Seu e-mail para contato é inválido");
           document.formprinc.email.focus();
           return false;
        }
      }
    }
    
    if(document.formprinc.emailorcamento.value==""){

      alert("Você deve informar seu email para orçamento.");
      document.formprinc.emailorcamento.focus();
      return false;

    }else{

      if(document.formprinc.emailorcamento.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.formprinc.emailorcamento.value)){
           alert("Seu e-mail para orçamento é inválido");
           document.formprinc.emailorcamento.focus();
           return false;
        }
      }
    }
    
    
    
    if(document.formprinc.idservico.value=="0"){
      alert("Você deve informar a Área de Serviço da Empresa");
      document.formprinc.idservico.focus();
      return false;
    }
    
    if(document.formprinc.idtiposervico.value==""){
      alert("Você deve informar o Tipo de Serviço da Empresa.");
      document.formprinc.idtiposervico.focus();
      return false;
    }

    
    if(!document.formprinc.termos.checked){
      alert("É necessário concordar com os termos de uso!");
      document.formprinc.termos.focus();
      return false;
    }


 }

function confirmaclassificado(idtipo){
    

    if(document.formprinc.nome.value==""){
      alert("Você deve informar o seu nome");
      document.formprinc.nome.focus();
      return false;
    }
    
    if (idtipo == "1") {
        if(document.formprinc.nempresa.value==""){
	      alert("Você deve informar o nome da Empresa");
	      document.formprinc.nempresa.focus();
	      return false;
	    }
    }
    
    if(document.formprinc.fone.value==""){
      alert("Você deve informar o fone.");
      document.formprinc.fone.focus();
      return false;
    }

    

    if(document.formprinc.iduf.value=="0"){
      alert("Você deve informar o Estado");
      document.formprinc.iduf.focus();
      return false;
    }
    
    if(document.formprinc.email.value==""){

      alert("Você deve informar seu email.");
      document.formprinc.email.focus();
      return false;

    }else{

      if(document.formprinc.email.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.formprinc.email.value)){
           alert("Seu e-mail é inválido");
           document.formprinc.email.focus();
           return false;
        }
      }
    }
    
    if(document.formprinc.idcidade.value==""){
      alert("Você deve informar a Cidade");
      document.formprinc.idcidade.focus();
      return false;
    }
    
    if(document.formprinc.cnpj.value!=""){    
	    var val = formprinc.cnpj.value;
		var base = val.substring(0, val.length-2);
		if (val.length != 11) {
		    //formprinc.cnpj.value = formatCpfCnpj(val, true, true);
			if (!isCnpj(val)) {
			  alert("CNPJ Não Informado/Inválido!");
	          document.formprinc.cnpj.focus();
	          return false;
			}
	    } else {
	        if (!isCpf(val)) {
			  alert("CPF Não Informado/Inválido!");
	          document.formprinc.cnpj.focus();
	          return false;
			}
		}
	
	}
    
    if (idtipo == "1") {
	    if(document.formprinc.idfuncao.value==""){
	      alert("Você deve informar o Equipamento");
	      document.formprinc.idfuncao.focus();
	      return false;
	    }
	    if(document.formprinc.marca.value==""){
	      alert("Você deve informar a Marca");
	      document.formprinc.marca.focus();
	      return false;
	    }
	    
	    if(document.formprinc.ano.value==""){
	      alert("Você deve informar o Ano");
	      document.formprinc.ano.focus();
	      return false;
	    }
    } else {
        if(document.formprinc.idprofissao.value==""){
	      alert("Você deve informar a Profissão");
	      document.formprinc.idprofissao.focus();
	      return false;
	    }
    }
    

    
    if(document.formprinc.descricao.value==""){
      alert("Você deve informar a Descrição.");
      document.formprinc.descricao.focus();
      return false;
    }
    
    
    if(!document.formprinc.termos.checked){
      alert("É necessário concordar com os termos de uso!");
      document.formprinc.descricao.focus();
      return false;
    }


 }


function confirmacontato(){


    if(document.form.nome.value==""){
      alert("Você deve informar o seu nome");
      document.form.nome.focus();
      return false;
    }

    if(document.form.telefone.value=="" && document.form.email.value==""){

      alert("Você deve informar seu email ou telefone");
      document.form.email.focus();
      return false;

    }else{

      if(document.form.email.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.form.email.value)){
           alert("Seu e-mail é inválido");
           document.form.email.focus();
           return false;
        }
      }
    }

    if(document.form.assunto.value==""){
      alert("Você deve informar o assunto");
      document.form.assunto.focus();
      return false;
    }

    if(document.form.mensagem.value==""){
      alert("Você deve escrever sua mensagem");
      document.form.mensagem.focus();
      return false;
    }


 }


 	function maxLength(textAreaField, limit) {
 		var ta = document.getElementById(textAreaField);
 		
 		if (ta.value.length >= limit) {
 			ta.value = ta.value.substring(0, limit-1);
 		}
 		document.getElementById("divcntcaracteres").innerHTML = "<span class=verdananormal>" + (limit - ta.value.length - 1) + " Caracteres Restantes.</span>";
 	}

var janela;

function pagina(pg)
	{
		location.href = pg ;
	}

var janela;
function popup(theURL,winName,params)
	{	if(janela != null)
			{	janela.close();
			}
		janela = window.open(theURL,winName,params);
		janela.focus();
	}
function po(o){o.className=='p1'?o.className='p2': o.className=o.className; }
function px(o){o.className=='p2'?o.className='p1': o.className=o.className; }
function pc(o){o.className='p3'; }

function verificaObrigClassificado (form)
{
	if (form.datvenc.value!="")
	{
		if (!(verificaData (form, form.datvenc.name, false)))
  		{
    			form.datvenc.focus();
    			return false;
  		}
	}
	
	if(document.form.nome.value==""){
      alert("Você deve informar o seu nome");
      document.form.nome.focus();
      return false;
    }

    if(document.form.fone.value=="" && document.form.email.value==""){

      alert("Você deve informar seu email ou telefone");
      document.form.email.focus();
      return false;

    }else{

      if(document.form.email.value != ""){
        var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
        var regex = new RegExp(emailReg);
        if(!regex.test(document.form.email.value)){
           alert("Seu e-mail é inválido");
           document.form.email.focus();
           return false;
        }
      }
    }
    return true;

}
      function Dados(valor,idcidade) {
	  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;
            }
         }
      }
	  if(ajax) {
		 document.formprinc.idcidade.options.length = 1;

		 idOpcao  = document.getElementById("opcoes");

	     ajax.open("POST", "./xmlcidades.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 ajax.onreadystatechange = function() {
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "<img src=./imagens/loading.gif>";
	        }
            if(ajax.readyState == 4) {
			   if(ajax.responseXML) {
			      processXML(ajax.responseXML,idcidade);
			   }
			   else {
				   idOpcao.innerHTML = "Selecione a Cidade";
			   }
            }
         }
	     var params = "iduf="+valor;
         ajax.send(params);
      }
   }

   function processXML(obj,idcidade){
      //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 = "-----------";

			//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;
			    if (novo.value == idcidade) { novo.selected = true; }
				//finalmente adiciona o novo elemento
				document.formprinc.idcidade.options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "-------";
	  }
   }
   
   function DadosCarrinho(valor,checked) {
      if (checked) {
        document.getElementById(valor).style.background = "url(./imagens/categoria_item2.gif) #FFFFCC";
      } else {
        document.getElementById(valor).style.background = "url(./imagens/categoria_item2.gif) #FFFFFF";
      }
	  try {
         ajax8 = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {
         try {
            ajax8 = new ActiveXObject("Msxml2.XMLHTTP");
         }
	     catch(ex) {
            try {
               ajax8 = new XMLHttpRequest();
            }
	        catch(exc) {
               alert("Esse browser não tem recursos para uso do Ajax");
               ajax8 = null;
            }
         }
      }
	  if(ajax8) {
		// document.formprinc.idsetor.options.length = 1;

		 //idOpcao  = document.getElementById("opcoes");

	     ajax8.open("POST", "./xmlcarrinho.php", true);
		 ajax8.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 ajax8.onreadystatechange = function() {
			if(ajax8.readyState == 1) {
			  // idOpcao.innerHTML = "<img src=./imagens/loading.gif>";
	        }
            if(ajax8.readyState == 4) {
			   if(ajax8.responseXML) {
			      processXMLCarrinho(ajax8.responseXML);
			   }
            }
         }
	     var params = "idfoto="+valor;
	     var params = params + "&checked="+checked;
         ajax8.send(params);
        // ajax8.send(params2);
      }
   }

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

	  //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 = "Setor";

			//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;
			    if (novo.value == idsetor) { novo.selected = true; }
				//finalmente adiciona o novo elemento
				document.formprinc.idsetor.options.add(novo); */
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
	//	idOpcao.innerHTML = "Setor";
	  }
   }
   
   function DadosSetores(valor,idsetor) {
	  try {
         ajax8 = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e) {
         try {
            ajax8 = new ActiveXObject("Msxml2.XMLHTTP");
         }
	     catch(ex) {
            try {
               ajax8 = new XMLHttpRequest();
            }
	        catch(exc) {
               alert("Esse browser não tem recursos para uso do Ajax");
               ajax8 = null;
            }
         }
      }
	  if(ajax8) {
		 document.formprinc.idsetor.options.length = 1;

		 idOpcao  = document.getElementById("opcoes");

	     ajax8.open("POST", "./xmlbimgsetor.php", true);
		 ajax8.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 ajax8.onreadystatechange = function() {
			if(ajax8.readyState == 1) {
			   idOpcao.innerHTML = "<img src=./imagens/loading.gif>";
	        }
            if(ajax8.readyState == 4) {
			   if(ajax8.responseXML) {
			      processXMLSetores(ajax8.responseXML,idsetor);
			   }
			   else {
				   idOpcao.innerHTML = "Todos";
			   }
            }
         }
	     var params = "idcategoria="+valor;
         ajax8.send(params);
      }
   }

   function processXMLSetores(obj,idsetor){
      //pega a tag cidade
      var dataArray   = obj.getElementsByTagName("categoria");

	  //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 = "Todos";

			//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;
			    if (novo.value == idsetor) { novo.selected = true; }
				//finalmente adiciona o novo elemento
				document.formprinc.idsetor.options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "Todos";
	  }
   }
   
   
   function AJXCategorias(valor,idcategoria,idtiposervico) {
	  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;
            }
         }
      }
	  if(ajax) {
		 document.formprinc.idcategoria.options.length = 1;

		 idOpcao  = document.getElementById("opcoes");

	     ajax.open("POST", "./xmlcategorias.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 ajax.onreadystatechange = function() {
			if(ajax.readyState == 1) {
		//	   idOpcao.innerHTML = "<img src=./imagens/loading.gif>";
	        }
            if(ajax.readyState == 4) {
			   if(ajax.responseXML) {
			      processXMLCategorias(ajax.responseXML,idcategoria);
			   }
			   else {
				   idOpcao.innerHTML = "Selecione o Serviço";
			   }
            }
         }
	     var params = "idservico="+valor;
         ajax.send(params);
      }
   }
   
   function processXMLCategorias(obj,idcategoria){
      //pega a tag cidade
      var dataArray   = obj.getElementsByTagName("categoria");

	  //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 = "-----------";

			//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;
			    if (novo.value == idcategoria) { novo.selected = true; }
				//finalmente adiciona o novo elemento
				document.formprinc.idcategoria.options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "-------";
	  }
   }
   
   
   function AJXTipoServico(idservico,idcategoria,idtiposervico) {
	  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;
            }
         }
      }
	  if(ajax) {
		 document.formprinc.idtiposervico.options.length = 1;

		 idOpcao  = document.getElementById("opcoes2");

	     ajax.open("POST", "./xmltiposervico.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 ajax.onreadystatechange = function() {
			if(ajax.readyState == 1) {
			//   idOpcao.innerHTML = "Carregando...!";
	        }
            if(ajax.readyState == 4) {
			   if(ajax.responseXML) {
			      processXMLTipoServico(ajax.responseXML,idtiposervico);
			   }
			   else {
				   idOpcao.innerHTML = "Selecione a Categoria";
			   }
            }
         }
	     var params = "idservico="+idservico+"&idcategoria="+idcategoria;
         ajax.send(params);
      }
   }
   
   function processXMLTipoServico(obj,idtiposervico){
      //pega a tag cidade
      var dataArray   = obj.getElementsByTagName("tiposervico");

	  //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 = "-----------";

			//cria um novo option dinamicamente
			var novo = document.createElement("option");
			    //atribui um ID a esse elemento
			    novo.setAttribute("id", "opcoes2");
				//atribui um valor
			    novo.value = codigo;
				//atribui um texto
			    novo.text  = descricao;
			    if (novo.value == idtiposervico) { novo.selected = true; }
				//finalmente adiciona o novo elemento
					document.formprinc.idtiposervico.options.add(novo);
		 }
	  }
	  else {
	    //caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "-------";
	  }
   }
  
   

imgout=new Image(9,9);
imgin=new Image(9,9);

function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

function selecionaServico(idservico) {
  ajaxGet("./ajxcategorias.php?idservico=" + idservico,document.getElementById("div1"),true);
  ajaxGet("./ajxservico.php?idservico=" + idservico,document.getElementById("div2"),true);
}

function hiddeall(prefix) {
  for (var i=0;i<300;i++) {
    id = prefix + i;
    td1 = "td1" + i;
	td2 = "td2" + i;
	td3 = "td3" + i;
	td4 = "td4" + i;
	td5 = "td5" + i;
	td6 = "td6" + i;
    if (document.getElementById(id)) {
      document.getElementById(id).style.display = 'none';
      document.getElementById(td1).style.background = "url(./imagens/categoria_item.gif)";
	  document.getElementById(td2).style.background = "url(./imagens/categoria_item_line.jpg)";
	  document.getElementById(td3).style.background = "url(./imagens/categoria_item_end.jpg) no-repeat";
	  document.getElementById(td4).src = "./imagens/tree_main.gif";
	  document.getElementById(td5).style.color = "#00923F";
	  document.getElementById(td6).style.color = "#666666";
    }
  }
}

function show(id,prefix) { 
	hiddeall(prefix);
	td1 = "td1" + id;
	td2 = "td2" + id;
	td3 = "td3" + id;
	td4 = "td4" + id;
	td5 = "td5" + id;
	td6 = "td6" + id;
	id = prefix + id;
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
		//	filter(("img"+id),'imgin');			
		} else {
		//	filter(("img"+id),'imgout');
			document.getElementById(id).style.display = 'none';			
		}
		document.getElementById(td1).style.background = "url(./imagens/categoria_item_on.gif)";
		document.getElementById(td2).style.background = "url(./imagens/categoria_item_line_on.jpg)";
		document.getElementById(td3).style.background = "url(./imagens/categoria_item_end_on.jpg) no-repeat";
		document.getElementById(td4).src = "./imagens/tree_hover3.gif";
		document.getElementById(td5).style.color = "#FFCC00";
		document.getElementById(td6).style.color = "#FFFFFF";
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
			//	filter(("img"+id),'imgin');
			} else {
			//	filter(("img"+id),'imgout');	
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
			//	filter(("img"+id),'imgout');
				document.all.id.style.display = 'none';
			}
		}
	}
}



function expand(sec,comple)
{
     thisSec = eval('e' + comple + sec);
     if (thisSec != null){
          if (thisSec.length){
               if (thisSec[0].style.display != 'none'){
                    for (var i=0;i<thisSec.length;i++) {thisSec[i].style.display = 'none'}
               }
               else{
                    for (var i=0;i<thisSec.length;i++) {thisSec[i].style.display = 'inline'}
               }
          }
          else{
                         if (thisSec.style.display != 'none')     {thisSec.style.display = 'none'}
               else{thisSec.style.display = 'inline'}
          }
     }

}

function ajaxGet(url,elemento_retorno,exibe_carregando){
/******
* ajaxGet - Coloca o retorno de uma url em um elemento qualquer
* Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email.
* Versão: 1.0 - 06/04/2006
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* Parametros:
* url: string; elemento_retorno: object||string; exibe_carregando:boolean
*  - Se elemento_retorno for um elemento html (inclusive inputs e selects),
*    exibe o retorno no innerHTML / value / options do elemento
*  - Se elemento_retorno for o nome de uma variavel
*    (o nome da variável deve ser declarado por string, pois será feito um eval)
*    a função irá atribuir o retorno à variável ao receber a url.
*******/
    var ajax1 = pegaAjax();
    if(ajax1){
        ajax1.onreadystatechange = ajaxOnReady
        ajax1.open("GET", url ,true);
        if(exibe_carregando){ put("<img src=./imagens/loading.gif>")    }
        ajax1.send(null)
        return true;
    } else {
        return false;
    }
    function ajaxOnReady(){
        if (ajax1.readyState==4){
            if(ajax1.status == 200){
                var texto=ajax1.responseText;
                if(texto.indexOf(" ")<0) texto=texto.replace(/\+/g," ");
                texto=unescape(texto); //descomente esta linha se tiver usado o urlencode no php ou asp
                put(texto);
            }else{
                if(exibe_carregando){put("Falha no carregamento");}
            }
            ajax1 = null
        } else if(exibe_carregando){//para mudar o status de cada carregando
                put("<img src=./imagens/loading.gif>" )
        }
    }
    function put(valor){ //coloca o valor na variavel/elemento de retorno
        if((typeof(elemento_retorno)).toLowerCase()=="string"){ //se for o nome da string
            if(valor!="Falha no carregamento"){
                eval(elemento_retorno + '= unescape("' + escape(valor) + '")')
            }
        }else if(elemento_retorno.tagName.toLowerCase()=="input"){
            valor = escape(valor).replace(/\%0D\%0A/g,"")
            elemento_retorno.value = unescape(valor);
        }else if(elemento_retorno.tagName.toLowerCase()=="select"){        
            select_innerHTML(elemento_retorno,valor)
        }else if(elemento_retorno.tagName){
            elemento_retorno.innerHTML = valor;
            //alert(elemento_retorno.innerHTML)
        }    
    }
    function pegaAjax(){ //instancia um novo xmlhttprequest
        //baseado na getXMLHttpObj que possui muitas cópias na net e eu nao sei quem é o autor original
        if(typeof(XMLHttpRequest)!='undefined'){return new XMLHttpRequest();}
        var axO=['Microsoft.XMLHTTP','Msxml2.XMLHTTP','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0'];
        for(var i=0;i<axO.length;i++){ try{ return new ActiveXObject(axO[i]);}catch(e){} }
        return null;
    }
}
function select_innerHTML(objeto,innerHTML){
/******
* select_innerHTML - altera o innerHTML de um select independente se é FF ou IE
* Corrige o problema de não ser possível usar o innerHTML no IE corretamente
* Veja o problema em: http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
* Use a vontade mas coloque meu nome nos créditos. Dúvidas, me mande um email.
* Versão: 1.0 - 06/04/2006
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* Parametros:
* objeto(tipo object): o select a ser alterado
* innerHTML(tipo string): o novo valor do innerHTML
*******/
    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
    for(var i=0;i<selTemp.childNodes.length;i++){
        if(selTemp.childNodes[i].tagName){
            opt = document.createElement("OPTION")
            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
            }
            opt.value = selTemp.childNodes[i].getAttribute("value")
            opt.text = selTemp.childNodes[i].innerHTML
            if(document.all){ //IEca
                objeto.add(opt)
            }else{
                objeto.appendChild(opt)
            }                    
        }    
    }
    document.body.removeChild(selTemp)
    selTemp = null
}

/**
 * @author Márcio d'Ávila
 * @version 1.01, 2004
 *
 * PROTÓTIPOS:
 * método String.lpad(int pSize, char pCharPad)
 * método String.trim()
 *
 * String unformatNumber(String pNum)
 * String formatCpfCnpj(String pCpfCnpj, boolean pUseSepar, boolean pIsCnpj)
 * String dvCpfCnpj(String pEfetivo, boolean pIsCnpj)
 * boolean isCpf(String pCpf)
 * boolean isCnpj(String pCnpj)
 * boolean isCpfCnpj(String pCpfCnpj)
 */


var NUM_DIGITOS_CPF  = 11;
var NUM_DIGITOS_CNPJ = 14;
var NUM_DGT_CNPJ_BASE = 8;


/**
 * Adiciona método lpad() à classe String.
 * Preenche a String à esquerda com o caractere fornecido,
 * até que ela atinja o tamanho especificado.
 */
String.prototype.lpad = function(pSize, pCharPad)
{
	var str = this;
	var dif = pSize - str.length;
	var ch = String(pCharPad).charAt(0);
	for (; dif>0; dif--) str = ch + str;
	return (str);
} //String.lpad


/**
 * Adiciona método trim() à classe String.
 * Elimina brancos no início e fim da String.
 */
String.prototype.trim = function()
{
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
} //String.trim


/**
 * Elimina caracteres de formatação e zeros à esquerda da string
 * de número fornecida.
 * @param String pNum
 *      String de número fornecida para ser desformatada.
 * @return String de número desformatada.
 */
function unformatNumber(pNum)
{
	return String(pNum).replace(/\D/g, "").replace(/^0+/, "");
} //unformatNumber


/**
 * Formata a string fornecida como CNPJ ou CPF, adicionando zeros
 * à esquerda se necessário e caracteres separadores, conforme solicitado.
 * @param String pCpfCnpj
 *      String fornecida para ser formatada.
 * @param boolean pUseSepar
 *      Indica se devem ser usados caracteres separadores (. - /).
 * @param boolean pIsCnpj
 *      Indica se a string fornecida é um CNPJ.
 *      Caso contrário, é CPF. Default = false (CPF).
 * @return String de CPF ou CNPJ devidamente formatada.
 */
function formatCpfCnpj(pCpfCnpj, pUseSepar, pIsCnpj)
{
	if (pIsCnpj==null) pIsCnpj = false;
	if (pUseSepar==null) pUseSepar = true;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var numero = unformatNumber(pCpfCnpj);

	numero = numero.lpad(maxDigitos, '0');
	if (!pUseSepar) return numero;

	if (pIsCnpj)
	{
		reCnpj = /(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/;
		numero = numero.replace(reCnpj, "$1.$2.$3/$4-$5");
	}
	else
	{
		reCpf  = /(\d{3})(\d{3})(\d{3})(\d{2})$/;
		numero = numero.replace(reCpf, "$1.$2.$3-$4");
	}
	return numero;
} //formatCpfCnpj


/**
 * Calcula os 2 dígitos verificadores para o número-efetivo pEfetivo de
 * CNPJ (12 dígitos) ou CPF (9 dígitos) fornecido. pIsCnpj é booleano e
 * informa se o número-efetivo fornecido é CNPJ (default = false).
 * @param String pEfetivo
 *      String do número-efetivo (SEM dígitos verificadores) de CNPJ ou CPF.
 * @param boolean pIsCnpj
 *      Indica se a string fornecida é de um CNPJ.
 *      Caso contrário, é CPF. Default = false (CPF).
 * @return String com os dois dígitos verificadores.
 */
function dvCpfCnpj(pEfetivo, pIsCnpj)
{
	if (pIsCnpj==null) pIsCnpj = false;
	var i, j, k, soma, dv;
	var cicloPeso = pIsCnpj? NUM_DGT_CNPJ_BASE: NUM_DIGITOS_CPF;
	var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
	var calculado = formatCpfCnpj(pEfetivo, false, pIsCnpj);
	calculado = calculado.substring(2, maxDigitos);
	var result = "";

	for (j = 1; j <= 2; j++)
	{
		k = 2;
		soma = 0;
		for (i = calculado.length-1; i >= 0; i--)
		{
			soma += (calculado.charAt(i) - '0') * k;
			k = (k-1) % cicloPeso + 2;
		}
		dv = 11 - soma % 11;
		if (dv > 9) dv = 0;
		calculado += dv;
		result += dv
	}

	return result;
} //dvCpfCnpj


/**
 * Testa se a String pCpf fornecida é um CPF válido.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCpf
 *      String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CPF válido.
 */
function isCpf(pCpf)
{
	var numero = formatCpfCnpj(pCpf, false, false);
	var base = numero.substring(0, numero.length - 2);
	var digitos = dvCpfCnpj(base, false);
	var algUnico, i;

	// Valida dígitos verificadores
	if (numero != base + digitos) return false;

	/* Não serão considerados válidos os seguintes CPF:
	 * 000.000.000-00, 111.111.111-11, 222.222.222-22, 333.333.333-33, 444.444.444-44,
	 * 555.555.555-55, 666.666.666-66, 777.777.777-77, 888.888.888-88, 999.999.999-99.
	 */
	algUnico = true;
	for (i=1; i<NUM_DIGITOS_CPF; i++)
	{
		algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
	}
	return (!algUnico);
} //isCpf


/**
 * Testa se a String pCnpj fornecida é um CNPJ válido.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCnpj
 *      String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CNPJ válido.
 */
function isCnpj(pCnpj)
{
	var numero = formatCpfCnpj(pCnpj, false, true);
	var base = numero.substring(0, NUM_DGT_CNPJ_BASE);
	var ordem = numero.substring(NUM_DGT_CNPJ_BASE, 12);
	var digitos = dvCpfCnpj(base + ordem, true);
	var algUnico;

	// Valida dígitos verificadores
	if (numero != base + ordem + digitos) return false;

	/* Não serão considerados válidos os CNPJ com os seguintes números BÁSICOS:
	 * 11.111.111, 22.222.222, 33.333.333, 44.444.444, 55.555.555,
	 * 66.666.666, 77.777.777, 88.888.888, 99.999.999.
	 */
	algUnico = numero.charAt(0) != '0';
	for (i=1; i<NUM_DGT_CNPJ_BASE; i++)
	{
		algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
	}
	if (algUnico) return false;

	/* Não será considerado válido CNPJ com número de ORDEM igual a 0000.
	 * Não será considerado válido CNPJ com número de ORDEM maior do que 0300
	 * e com as três primeiras posições do número BÁSICO com 000 (zeros).
	 * Esta crítica não será feita quando o no BÁSICO do CNPJ for igual a 00.000.000.
	 */
	if (ordem == "0000") return false;
	return (base == "00000000"
		|| parseInt(ordem, 10) <= 300 || base.substring(0, 3) != "000");
} //isCnpj


/**
 * Testa se a String pCpfCnpj fornecida é um CPF ou CNPJ válido.
 * Se a String tiver uma quantidade de dígitos igual ou inferior
 * a 11, valida como CPF. Se for maior que 11, valida como CNPJ.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCpfCnpj
 *      String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CPF ou CNPJ válido.
 */
function isCpfCnpj(pCpfCnpj)
{
	var numero = pCpfCnpj.replace(/\D/g, "");
	if (numero.length > NUM_DIGITOS_CPF)
		return isCnpj(pCpfCnpj)
	else
		return isCpf(pCpfCnpj);
} //isCpfCnpj






//]]>