function GM_Mostra_SubCategoria(vID_Pai){
  
  if (document.getElementById("imagem_servico_" + vID_Pai).src.indexOf("images/mais.gif") > -1)
  {
    ometodo = getMetodo();
	  xmlhttp = getHTTPObject();

    url_asp = "includes/inc_lista_subcategoria.asp?id_pai="+vID_Pai;
    xmlhttp.open(ometodo,url_asp,true);
    xmlhttp.onreadystatechange=function(){
	        if(xmlhttp.readyState == 4) {
             var vRetorno = xmlhttp.responseText;

                document.getElementById("dv_servico_" + vID_Pai).innerHTML=vRetorno;
		            document.getElementById("imagem_servico_" + vID_Pai).src = "images/menos.gif";
         }
    }
    
    xmlhttp.send(null);
    //return false;
  } else {
    document.getElementById("dv_servico_" + vID_Pai).innerHTML="";
    document.getElementById("imagem_servico_" + vID_Pai).src = "images/mais.gif"
  }


}

  function GM_Random(){
	  today = new Date();
	  num= Math.abs(Math.sin(today.getTime()));
	  return num;  
  }
  
  function GM_AJAX_CarregaCidades(_estado){
    vUF = _estado.value;
    if (vUF!=""){
      var selectBox = document.getElementById('cidadesTemp');
      ometodo = getMetodo();
	    xmlhttp = getHTTPObject();
      url_asp = "ajax_consultas.asp?controle=1&uf=" + vUF + "&" + GM_Random() + "=" + GM_Random();
      xmlhttp.open(ometodo,url_asp,true);
      xmlhttp.onreadystatechange=function(){
        selectBox.length=0;
        var option = document.createElement('option');
        option.text = "-- carregando aguarde --";
        option.value = "";
        selectBox.options[0]=option;
	      if(xmlhttp.readyState == 4) {
          var vRetorno = xmlhttp.responseText.toString();
          var vMT_Opcoes = vRetorno.split("#");
          selectBox.length=0;
          var vLinha = new String;
          for (x=0; x<vMT_Opcoes.length; x++){
            vLinha = vMT_Opcoes[x].toString();
            var vMT_Linha = vLinha.split("|");
            var option = document.createElement('option');
            option.value=vMT_Linha[0];
            option.text=vMT_Linha[1];
            selectBox.options[x]=option;
          }
        }
      }
      xmlhttp.send(null);
    }
  }
  
  function GM_AJAX_CarregaCidades_Tipo(_estado,_tipo){
    document.body.style.cursor = "wait";
    var vUF = _estado.value;
    var vTipo = _tipo.value;
    if (vUF!=""){
      var selectBox = document.getElementById('cidadesTemp');
      ometodo = getMetodo();
	    xmlhttp = getHTTPObject();
      url_asp = "ajax_consultas.asp?controle=4&uf=" + vUF + "&tipo=" + vTipo + "&" + GM_Random() + "=" + GM_Random();
      xmlhttp.open(ometodo,url_asp,true);
      xmlhttp.onreadystatechange=function(){
        selectBox.length=0;
        var option = document.createElement('option');
        option.text = "-- carregando aguarde --";
        option.value = "";
        selectBox.options[0]=option;
	      if(xmlhttp.readyState == 4) {
          var vRetorno = xmlhttp.responseText.toString();
          var vMT_Opcoes = vRetorno.split("#");
          selectBox.length=0;
          var vLinha = new String;

          for (x=0; x<vMT_Opcoes.length; x++){
            vLinha = vMT_Opcoes[x].toString();
            var vMT_Linha = vLinha.split("|");
            var option = document.createElement('option');
            option.value=vMT_Linha[0];
            option.text=vMT_Linha[1];
            selectBox.options[x]=option;
          }
          
        }
        document.body.style.cursor = "default";
      }
      xmlhttp.send(null);
    }
  }
  
  function GM_AJAX_UFCidade(_cidade){
    vCidade = _cidade.value;
    var vRetorno = new String;
    if (vCidade!=""){
      ometodo = getMetodo();
	    xmlhttp = getHTTPObject();
      url_asp = "ajax_consultas.asp?controle=3&cidade=" + vCidade + "&" + GM_Random() + "=" + GM_Random();
      xmlhttp.open(ometodo,url_asp,true);
      xmlhttp.onreadystatechange=function(){
	      if(xmlhttp.readyState == 4) {
          vRetorno = xmlhttp.responseText;
          xmlhttp.send(null);
          return vRetorno;
        }
      }
    }
  }
  
  function GM_AJAX_RelacionaCidade(_cidade,_op){
    vCidade = _cidade.value;
    if (vCidade!=""){
      ometodo = getMetodo();
	    xmlhttp = getHTTPObject();
      url_asp = "ajax_consultas.asp?controle=2&op=" + _op + "&cidade=" + vCidade + "&" + GM_Random() + "=" + GM_Random();
      xmlhttp.open(ometodo,url_asp,true);
      xmlhttp.onreadystatechange=function(){
	      if(xmlhttp.readyState == 4) {
          var vRetorno = xmlhttp.responseText.toString();
        }
      }
      xmlhttp.send(null);
    }
  }
  
  function GM_Select(objFrom,objTo){
    var objTo = document.getElementById(objTo);
    var objFrom = document.getElementById(objFrom);
    var ncount = objTo.length;
    if (typeof(objFrom.options[objFrom.selectedIndex])=="object" && typeof(objTo)=="object"){
      if (typeof(objFrom.selectedIndex)=="number" && typeof(ncount)=="number"){
        var value = objFrom.options[objFrom.selectedIndex].value;
        var find = false;
        for (x=0; x<ncount; x++){
          if (objTo.options[x].value==value){
            find = true;
          }
        }
        var option = document.createElement('option');
        option.text=objFrom.options[objFrom.selectedIndex].text;
        option.value=objFrom.options[objFrom.selectedIndex].value;
        //GM_AJAX_RelacionaCidade(option,'r');
        if (find==false){
          objTo.options[ncount]=option;
          objFrom.options[objFrom.selectedIndex]=null;
        }
      }
    }
  }
  
  function GM_PreencheCombo(fonte1,destino1){
    document.body.style.cursor = "wait";
    //Pegando os Drops que estão na página
    var fonte = document.getElementById(fonte1);
    var destino = document.getElementById(destino1);
    var i=0;
    //Fazendo o laço FOR para recuperar todos os options selecionados
    //no drop FONTE e mandar para o drop DESTINO
    for(i=fonte.options.length-1; i >= 0; i--) {
      //Verificando se o option atual está selecionado
      if(fonte.options[i].selected==true){
        //se estiver, então adiciona no novo drop
        var vId = fonte.options[i].value;
        var vNome = fonte.options[i].text;
        opcoes = document.createElement("option");
        opcoes.value = vId;
        opcoes.text = vNome;
        destino.options.add(opcoes,destino.selectedIndex);
        fonte.remove(i);
      }
    }
    document.body.style.cursor = "default";
  }
  
  function GM_PreencheComboSemSelecionar(fonte1,destino1){
    document.body.style.cursor = "wait";
    //Pegando os Drops que estão na página
    var fonte = document.getElementById(fonte1);
    var destino = document.getElementById(destino1);
    var i=0;
    //Fazendo o laço FOR para recuperar todos os options selecionados
    //no drop FONTE e mandar para o drop DESTINO
    for(i=fonte.options.length-1; i >= 0; i--) {
      var vId = fonte.options[i].value;
      var vNome = fonte.options[i].text;
      opcoes = document.createElement("option");
      opcoes.value = vId;
      opcoes.text = vNome;
      destino.options.add(opcoes,destino.selectedIndex);
      fonte.remove(i);
    }
    document.body.style.cursor = "default";
  }
  
  function GM_DeSelect(objFrom,objTo){
    var objTo = document.getElementById(objTo);
    var objFrom = document.getElementById(objFrom);
    var ncount = objTo.length;
    if (typeof(objFrom.options[objFrom.selectedIndex])=="object" && typeof(objTo)=="object"){
      if (typeof(objFrom.selectedIndex)=="number" && typeof(ncount)=="number"){
        vCidade = objFrom.options[objFrom.selectedIndex].value;
        ometodo = getMetodo();
	      xmlhttp = getHTTPObject();
        url_asp = "ajax_consultas.asp?controle=3&cidade=" + vCidade + "&" + GM_Random() + "=" + GM_Random();
        xmlhttp.open(ometodo,url_asp,true);
        xmlhttp.onreadystatechange=function(){
	        if(xmlhttp.readyState == 4) {
            var vEstadoCidade = xmlhttp.responseText;
            var vEstadoSelecionado = document.getElementById('estado');
            var vEstadoSelecionado = vEstadoSelecionado.options[vEstadoSelecionado.selectedIndex].value;
            var value = objFrom.options[objFrom.selectedIndex].value;
            var find = false;
            for (x=0; x<ncount; x++){
              if (objTo.options[x].value==value){
                find = true;
              }
            }
            var option = document.createElement('option');
            option.text=objFrom.options[objFrom.selectedIndex].text;
            option.value=objFrom.options[objFrom.selectedIndex].value;
            GM_AJAX_RelacionaCidade(option,'d');
            if (find==false && vEstadoSelecionado==vEstadoCidade){
              objTo.options[ncount]=option;
            }
            objFrom.options[objFrom.selectedIndex]=null;
          }
        }
        xmlhttp.send(null);
      }
    }
  }
  
  function GM_AJAX_DetalhesBoletim(_data){
    document.getElementById('detalhes').innerHTML="carregando informações para a nova data....";
    if (_data.value.length==10){
      ometodo = getMetodo();
	    xmlhttp = getHTTPObject();
      url_asp = "ajax_consultas.asp?controle=3&data=" + _data.value + "&" + GM_Random() + "=" + GM_Random();
      xmlhttp.open(ometodo,url_asp,true);
      xmlhttp.onreadystatechange=function(){
        document.getElementById('detalhes').innerHTML="carregando dados do banco...";
	      if(xmlhttp.readyState == 3){
	        document.getElementById('detalhes').innerHTML="processando dados...";
	      }
	      if(xmlhttp.readyState == 4){
          document.getElementById('detalhes').innerHTML = xmlhttp.responseText.toString();
        }
      }
      xmlhttp.send(null);
    } else {
      document.getElementById('detalhes').innerHTML="data incorreta....";
    }
  }
	
	//*************verifica se o navegador tem suporte ao AJAX****************
	function GM_Verifica_ajax()
	{ 
		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;
	}
	//função que retorna para o combo desejado os valores retornados do link da var url
	function GM_Combo(url,Campo,Selecionado)
	{
			//alert(url);
			var ajax = GM_Verifica_ajax();
			if(ajax)
			{
					var Rnd = GM_Random();
					if(url.indexOf("?")>=0)
					{
						// já tem parametros vindos na url
						url = url + "&" + Rnd;
					}
					else
					{ 
						url = url + "?" + Rnd;
					}
					ajax.onreadystatechange = GM_Status_ajax
					ajax.open("GET", url ,true);
					ajax.setRequestHeader("Cache-Control", "no-cache");
					ajax.setRequestHeader("Pragma", "no-cache");
					ajax.send(null);
					return true;
		 }
			else
			{
					alert("Este navegador não tem suporte ao AJAX!");
					return false;
			}
			function GM_Status_ajax()
			{
					if (ajax.readyState==4)
					{
							if(ajax.status == 200)
							{
								//alert(document.getElementById(Campo).value);
								document.getElementById(Campo).options.length = 1;
								var vRetorno = ajax.responseText;
								var vId_Nome = vRetorno.split('*');
								//insere os novos valores
								 for(var i=0; i < vId_Nome.length-1; i++) 
								 {
									 var Lista = vId_Nome[i].split('|'); //separa ID do Nome pela Barra(|)
									 var vId = Lista[0];
									 var vNome = Lista[1];
									 opcoes = document.createElement("option");
									 opcoes.value = vId;
									 opcoes.text = vNome;
									 if (Selecionado == vId)
									 {
											opcoes.setAttribute("selected", "true");
									 }
									 document.getElementById(Campo).options.add(opcoes);
								 }
							}
							else
							{
									alert("Carregamento falhou!");
							}
							ajax = null
					}
			}
	}
	
