try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function extraiScript(texto){
    var ini, pos_src, fim, codigo;
    var objScript = null;
    ini = texto.indexOf('<script', 0)
    while (ini!=-1){
        var objScript = document.createElement("script");
        pos_src = texto.indexOf(' src', ini)
        ini = texto.indexOf('>', ini) + 1;

        if (pos_src < ini && pos_src >=0){
            ini = pos_src + 4;
            fim = texto.indexOf('.', ini)+4;
            codigo = texto.substring(ini,fim);
            codigo = codigo.replace("=","").replace(" ","").replace("\"","").replace("\"","").replace("\'","").replace("\'","").replace(">","");
            objScript.src = codigo;
        }else{
            fim = texto.indexOf('</script>', ini);
            codigo = texto.substring(ini,fim);
            objScript.text = codigo;
        }
        document.body.appendChild(objScript);
        ini = texto.indexOf('<script', fim);
        objScript = null;
    }
}



function ajax(url)
{
    req = null;
    // Procura por um objeto nativo (Mozilla/Safari)
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET",url,true);
        req.send(null);
    // Procura por uma versão ActiveX (IE)
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET",url,true);
            req.send();
        }
    }
}

function processReqChange()
{
    // apenas quando o estado for "completado"
    if (req.readyState == 4) {
        // apenas se o servidor retornar "OK"
        if (req.status ==200) {
            document.getElementById("conteudo").innerHTML = req.responseText;
        } else {
            alert("Houve um problema ao obter os dados:" + req.statusText);
        }
    }
        if(req.readyState == 4){extraiScript(req.responseText);}

        if (req.readyState == 4) {
            if(navigator.appVersion.indexOf("MSIE")!= -1){
              var temp = navigator.appVersion.split("MSIE");
              var versao = parseFloat(temp[1]);
              if((versao == 7) || (versao == 8))
              {
                    var conteudo = document.getElementById('conteudo');

                    if(document.getElementById('conteudo').scrollHeight >= document.getElementById('conteudo').clientHeight)
                    {
                      conteudo.style.backgroundImage = "url('imgs/fundo_conteudo_ie7.jpg')";
                      conteudo.style.backgroundRepeat = 'repeat';
                      conteudo.style.backgroundAttachment = 'fixed';
                    } else
                    {
                      var conteudo = document.getElementById('conteudo');
                      conteudo.style.backgroundImage = "url('imgs/fundo_conteudo.jpg')";
                      conteudo.style.backgroundRepeat = 'no-repeat';
                      conteudo.style.backgroundAttachment = 'scroll';
                    }
              }
            }
        }
}

function load(url)
{
    document.getElementById("conteudo").innerHTML = "<center><p style='padding-top: 150px;'><img src='./images/loader.gif' alt='loader' /></p></center>";
    ajax(url);

      $('a.classe1').mouseover(function() {
		$(this).css('color','#FFd400');
	  });
      $('a.classe1').mouseout(function() {
		$(this).css('color','#6b6c71');
	  });


      $('#ajudarr').mouseover(function() {
		$(this).css('color','#FFd400');
	  });
      $('#ajudarr').mouseout(function() {
		$(this).css('color','#6b6c71');
	  });
      $("#ajudarr").css("color","#6b6c71");


      $('#ajudarrr').mouseover(function() {
		$(this).css('color','#FFd400');
	  });
      $('#ajudarrr').mouseout(function() {
		$(this).css('color','#6b6c71');
	  });

      $("#ajudarrr").css("color","#6b6c71");


    if(url.indexOf('agua') != -1)
    {
        teste_agua(url);
    }
    if(url.indexOf('refrigerante') != -1)
    {
        teste_refrigerante(url);
    }
    if(url.indexOf('cerveja') != -1)
    {
        teste_ceva(url);
    }
    if(url.indexOf('outras') != -1)
    {
        teste_outras(url);
    }
    if((url.indexOf('institucional') != -1) || (url == 'historia.php'))
    {
        teste_inst(url);
    }



 /*   if (url != "cerveja/setor.php?utf=1&fonte=2")
    {
    document.getElementById("conteudo").style.width = "553px";
    document.getElementById("alter_img").src = "imgs/conteudofim.jpg";
    document.getElementById("alter_img").width = "43";
    } else {
    document.getElementById("conteudo").style.width = "600px";
    document.getElementById("alter_img").src = "imgs/conteudofim3.jpg";
    document.getElementById("alter_img").width = "8";
    } */
}

function teste_inst(url)
{
      document.getElementById('link1').style.color = "#6b6c71";
      document.getElementById('link2').style.color = "#6b6c71";
      document.getElementById('link3').style.color = "#6b6c71";
      document.getElementById('link4').style.color = "#6b6c71";
      document.getElementById('link5').style.color = "#6b6c71";
      document.getElementById('link6').style.color = "#6b6c71";
      //document.getElementById('link7').style.color = "#6b6c71";
      document.getElementById('link8').style.color = "#6b6c71";
     //document.getElementById('link9').style.color = "#6b6c71";
      document.getElementById('link10').style.color = "#6b6c71";
     //document.getElementById('link11').style.color = "#6b6c71";
      document.getElementById('link12').style.color = "#6b6c71";
      document.getElementById('link13').style.color = "#6b6c71";
      document.getElementById('link14').style.color = "#6b6c71";
      document.getElementById('link15').style.color = "#6b6c71";
      document.getElementById('link16').style.color = "#6b6c71";
      document.getElementById('link17').style.color = "#6b6c71";
      document.getElementById('link18').style.color = "#6b6c71";
      document.getElementById('link19').style.color = "#6b6c71";
      document.getElementById('link20').style.color = "#6b6c71";
      document.getElementById('link21').style.color = "#6b6c71";
      document.getElementById('link22').style.color = "#6b6c71";
      document.getElementById('link23').style.color = "#6b6c71";
     // document.getElementById('decisao1').style.color = "#6b6c71";
     // document.getElementById('decisao2').style.color = "#6b6c71";
    //  document.getElementById('decisao3').style.color = "#6b6c71";

  if (url == "historia.php") {
      document.getElementById('link1').style.color = "#ffd400";
      $("#link1").unbind();
  }

  if(url == "institucional/exibe.php?o=1&t=2")
  {
      document.getElementById('link2').style.color = "#ffd400";
      $("#link2").unbind();
  }

  if(url == "institucional/exibe.php?o=2&t=1")
  {
      document.getElementById('link3').style.color = "#ffd400";
      $('#link3').unbind();
  }
  if(url == "institucional/exibe.php?o=3&t=3")
  {
      document.getElementById('link4').style.color = "#ffd400";
      $('#link4').unbind();
  }
  if(url == "institucional/exibe.php?o=4&t=4&orgaos=1")
  {
      document.getElementById('link5').style.color = "#ffd400";
      $('#link5').unbind();
  }
  if(url == "institucional/exibe.php?o=6")
  {
      document.getElementById('link6').style.color = "#ffd400";
      $('#link6').unbind();
  }
  if(url == "institucional/exibe.php?o=4&t=4")
  {
      document.getElementById('decisao1').style.color = "#ffd400";
      $('#decisao1').unbind();
  }
  if(url == "institucional/exibe.php?o=4&t=5")
  {
      document.getElementById('decisao2').style.color = "#ffd400";
      $('#decisao2').unbind();
  }
  if(url == "institucional/exibe.php?o=4&t=8")
  {
      document.getElementById('decisao3').style.color = "#ffd400";
      $('#decisao3').unbind();
  }
  if(url == "institucional/exibe.php?o=8&id_tipo2=1&id_tipo3=1")
  {
      document.getElementById('link7').style.color = "#ffd400";
      $('#link7').unbind();
  }
  if(url == "institucional/exibe.php?o=8&id_tipo2=1&id_tipo3=2")
  {
      document.getElementById('link8').style.color = "#ffd400";
      $('#link8').unbind();
  }
  if(url == "institucional/exibe.php?o=8&id_tipo2=2&id_tipo3=1")
  {
      document.getElementById('link9').style.color = "#ffd400";
      $('#link9').unbind();
  }
  if(url == "institucional/exibe.php?o=8&id_tipo2=2&id_tipo3=2")
  {
      document.getElementById('link10').style.color = "#ffd400";
      $('#link10').unbind();
  }
  if(url == "institucional/exibe.php?o=8&id_tipo2=3&id_tipo3=1")
  {
      document.getElementById('link11').style.color = "#ffd400";
      $('#link11').unbind();
  }
  if(url == "institucional/exibe.php?o=8&id_tipo2=3&id_tipo3=2")
  {
      document.getElementById('link12').style.color = "#ffd400";
      $('#link12').unbind();
  }

  if(url == "institucional/exibe.php?o=8")
  {
      document.getElementById('link13').style.color = "#ffd400";
      $('#link13').unbind();
  }

  if(url == "institucional/exibe.php?o=8&mapa=1")
  {
      document.getElementById('link14').style.color = "#ffd400";
      $('#link14').unbind();
  }

  if(url == "institucional/exibe.php?o=8&mapa=2")
  {
      document.getElementById('link15').style.color = "#ffd400";
      $('#link15').unbind();
  }

  if(url == "institucional/exibe.php?o=9&c=1")
  {
      document.getElementById('link16').style.color = "#ffd400";
      $('#link16').unbind();
  }

  if(url == "institucional/exibe.php?o=9&c=2")
  {
      document.getElementById('link17').style.color = "#ffd400";
      $('#link17').unbind();
  }

  if(url == "institucional/exibe.php?o=9&c=3")
  {
      document.getElementById('link18').style.color = "#ffd400";
      $('#link18').unbind();
  }

  if(url == "institucional/exibe.php?o=9&c=5")
  {
      document.getElementById('link19').style.color = "#ffd400";
      $('#link19').unbind();
  }

  if(url == "institucional/exibe.php?o=9&c=6")
  {
      document.getElementById('link20').style.color = "#ffd400";
      $('#link20').unbind();
  }
  if(url == "institucional/exibe.php?o=9&c=7")
  {
      document.getElementById('link21').style.color = "#ffd400";
      $('#link21').unbind();
  }
  if(url == "institucional/exibe.php?o=9&c=4")
  {
      document.getElementById('link22').style.color = "#ffd400";
      $('#link22').unbind();
  }
  if(url == "institucional/exibe.php?o=9&c=1021")
  {
      document.getElementById('link23').style.color = "#ffd400";
      $('#link23').unbind();
  }

}

function teste_outras(url)
{
      document.getElementById('link1').style.color = "#6b6c71";
      document.getElementById('link2').style.color = "#6b6c71";
      document.getElementById('link3').style.color = "#6b6c71";
     // document.getElementById('link4').style.color = "#6b6c71";

  if(url == "outras/setor.php?utf=1")
  {
      document.getElementById('link1').style.color = "#ffd400";
      $("#link1").unbind();
  }

  if(url == "outras/exibe.php?o=2&t=18")
  {
      document.getElementById('link2').style.color = "#ffd400";
      $('#link2').unbind();
  }

  if(url == "outras/exibe.php?o=2&t=19")
  {
      document.getElementById('link3').style.color = "#ffd400";
      $('#link3').unbind();
  }
  if(url == "outras/exibe.php?o=1")
  {
      document.getElementById('link4').style.color = "#ffd400";
      $('#link4').unbind();
  }

}

function teste_ceva(url)
{

      document.getElementById('link1').style.color = "#6b6c71";
      document.getElementById('link2').style.color = "#6b6c71";
      document.getElementById('1').style.color = "#6b6c71";
      document.getElementById('4').style.color = "#6b6c71";
      //document.getElementById('6').style.color = "#6b6c71";
      document.getElementById('link3').style.color = "#6b6c71";
      document.getElementById('link4').style.color = "#6b6c71";
      document.getElementById('link5').style.color = "#6b6c71";
      document.getElementById('link6').style.color = "#6b6c71";
      document.getElementById('link7').style.color = "#6b6c71";
      document.getElementById('link8').style.color = "#6b6c71";
      document.getElementById('link9').style.color = "#6b6c71";
      document.getElementById('link10').style.color = "#6b6c71";
      document.getElementById('decisao1').style.color = "#6b6c71";
      document.getElementById('decisao2').style.color = "#6b6c71";
      document.getElementById('decisao3').style.color = "#6b6c71";
  //    document.getElementById('link7').style.color = "#6b6c71";
 //     document.getElementById('sde1').style.color = "#6b6c71";

 if(url == "cerveja/a_setor.php?utf=1")
  {
      document.getElementById('link1').style.color = "#ffd400";

      $("#link1").unbind();
  }
  if(url == "cerveja/setor.php?utf=1")
  {
      document.getElementById('link2').style.color = "#ffd400";

      $("#link2").unbind();
  }
  if(url == "cerveja/exibe.php?o=6&t=24")
  {
      document.getElementById('1').style.color = "#ffd400";

      $("#1").unbind('mouseover');
      $("#1").unbind('mouseout');

      $('#ajudarrr').mouseover(function() {
		$(this).css('color','#FFd400');
	  });
      $('#ajudarrr').mouseout(function() {
		$(this).css('color','#FFd400');
	  });


      $("#ajudarrr").css("color","#ffd400");
  }

  if(url == "cerveja/exibe.php?o=6&t=25")
  {
      document.getElementById('link3').style.color = "#ffd400";

      $("#link3").unbind();
  }


  if(url =="cerveja/exibe.php?o=7&t=26")
  {
      document.getElementById('4').style.color = "#ffd400";

      $("#4").unbind('mouseover');
      $("#4").unbind('mouseout');

      $('#ajudarr').mouseover(function() {
		$(this).css('color','#FFd400');
	  });
      $('#ajudarr').mouseout(function() {
		$(this).css('color','#FFd400');
	  });


      $("#ajudarr").css("color","#ffd400");

  }


  if(url == "cerveja/exibe.php?o=2&t=18")
  {
      document.getElementById('link4').style.color = "#ffd400";

      $("#link4").unbind();
  }
  if(url == "cerveja/exibe.php?o=2&t=19")
  {
      document.getElementById('link5').style.color = "#ffd400";

      $("#link5").unbind();
  }
  if(url == "cerveja/exibe.php?o=1")
  {
      document.getElementById('link6').style.color = "#ffd400";

      $("#link6").unbind();
  }
  if(url == "cerveja/exibe.php?o=4&t=4")
  {
      document.getElementById('decisao1').style.color = "#ffd400";

      $("#decisao1").unbind();
  }
  if(url == "cerveja/exibe.php?o=4&t=5")
  {
      document.getElementById('decisao2').style.color = "#ffd400";

      $("#decisao2").unbind();
  }
  if(url == "cerveja/exibe.php?o=4&t=8")
  {
      document.getElementById('decisao3').style.color = "#ffd400";

      $("#decisao3").unbind();
  }

  if(url == "cerveja/exibe.php?o=8&t=8")
  {
      document.getElementById('link7').style.color = "#ffd400";


      $("#link7").unbind();
  }
  if(url == "cerveja/exibe.php?o=6&t=27")
  {
      document.getElementById('link6').style.color = "#ffd400";


      $("#link6").unbind();
  }
  if(url == "cerveja/exibe.php?o=9&t=29")
  {
      document.getElementById('link7').style.color = "#ffd400";


      $("#link7").unbind();
  }
  if(url == "cerveja/exibe.php?o=10&t=28")
  {
      document.getElementById('link8').style.color = "#ffd400";


      $("#link8").unbind();
  }
  if(url == "cerveja/exibe.php?o=1771")
  {
      document.getElementById('link9').style.color = "#ffd400";


      $("#link9").unbind();
  }
  if(url == "cerveja/exibe.php?o=4810")
  {
      document.getElementById('link10').style.color = "#ffd400";


      $("#link10").unbind();
  }
  /*
  if(url == "cerveja/exibe.php?o=8&t=3")
  {
      document.getElementById('sde2').style.color = "#ffd400";
      document.getElementById('link2').style.color = "#6b6c71";
      document.getElementById('1').style.color = "#6b6c71";
      document.getElementById('4').style.color = "#6b6c71";
      document.getElementById('link3').style.color = "#6b6c71";
      document.getElementById('link4').style.color = "#6b6c71";
      document.getElementById('link5').style.color = "#6b6c71";
      document.getElementById('link6').style.color = "#6b6c71";
 //     document.getElementById('link7').style.color = "#6b6c71";
      document.getElementById('cade1').style.color = "#6b6c71";
      document.getElementById('cade2').style.color = "#6b6c71";
      document.getElementById('sde1').style.color = "#6b6c71";
      document.getElementById('link1').style.color = "#6b6c71";
      document.getElementById('cade3').style.color = "#6b6c71";

      $("#sde2").unbind();
  }
 */

}

function teste_agua(url)
{
   //links água
      document.getElementById('link1').style.color = "#6b6c71";
      document.getElementById('link2').style.color = "#6b6c71";
      document.getElementById('link3').style.color = "#6b6c71";
      document.getElementById('link4').style.color = "#6b6c71";
      document.getElementById('link5').style.color = "#6b6c71";
    //  document.getElementById('link6').style.color = "#6b6c71";
      document.getElementById('1').style.color = "#6b6c71";


    if (url == "agua/a_setor.php?utf=1")
    {
      document.getElementById('link1').style.color = "#ffd400";
      $("#link1").unbind();
    }
    if(url == "agua/setor.php?utf=1") {
      document.getElementById('link2').style.color = "#ffd400";
      $("#link2").unbind();
    }
    if(url == "agua/exibe.php?o=5&t=23") {
      document.getElementById('1').style.color = "#ffd400";
    }
    if (url == "agua/exibe.php?o=5&t=24"){
      document.getElementById('link3').style.color = "#ffd400";
    }
    if (url == "agua/exibe.php?o=2&t=18"){
      document.getElementById('link4').style.color = "#ffd400";
    }
    if (url == "agua/exibe.php?o=2&t=19"){
      document.getElementById('link5').style.color = "#ffd400";
    }
    if (url == "agua/exibe.php?o=1"){
      document.getElementById('link6').style.color = "#ffd400";
    }
}

function teste_refrigerante(url)
{
        // links refrigerante
         document.getElementById('1').style.color = "#6b6c71";
         document.getElementById('link2').style.color = "#6b6c71";
      //   document.getElementById('link1').style.color = "#6b6c71";
      //   document.getElementById('link3').style.color = "#6b6c71";
      //   document.getElementById('link4').style.color = "#6b6c71";
         document.getElementById('link5').style.color = "#6b6c71";
         document.getElementById('link6').style.color = "#6b6c71";
         document.getElementById('link7').style.color = "#6b6c71";
         document.getElementById('link8').style.color = "#6b6c71";
         document.getElementById('link9').style.color = "#6b6c71";
         document.getElementById('link10').style.color = "#6b6c71";
         document.getElementById('link11').style.color = "#6b6c71";
     //    document.getElementById('link12').style.color = "#6b6c71";
     //    document.getElementById('link13').style.color = "#6b6c71";
         document.getElementById('link14').style.color = "#6b6c71";
         document.getElementById('link15').style.color = "#6b6c71";
         document.getElementById('link16').style.color = "#6b6c71";
     //    document.getElementById('link17').style.color = "#6b6c71";
         document.getElementById('link18').style.color = "#6b6c71";
         document.getElementById('link19').style.color = "#6b6c71";
         document.getElementById('link20').style.color = "#6b6c71";
         document.getElementById('link21').style.color = "#6b6c71";
         document.getElementById('link22').style.color = "#6b6c71";

    if (url == "refrigerante/exibe.php?o=31&t=215") {
     document.getElementById('1').style.color = "#ffd400";
      $("#1").unbind('mouseover');
      $("#1").unbind('mouseout');

      $('#ajudarrr').mouseover(function() {
		$(this).css('color','#FFd400');
	  });
      $('#ajudarrr').mouseout(function() {
		$(this).css('color','#FFd400');
	  });


      $("#ajudarrr").css("color","#ffd400");



    }

    if (url == "historia.php") {
     document.getElementById('link1').style.color = "#ffd400";
      $("#link1").unbind();
    }
    if (url == "refrigerante/setor.php?utf=1") {
     document.getElementById('link2').style.color = "#ffd400";
      $("#link2").unbind();
    }
    if (url == "refrigerante/exibe.php?o=2&t=6") {
     document.getElementById('link3').style.color = "#ffd400";
      $("#link3").unbind();
    }
    if (url == "refrigerante/exibe.php?o=2&t=7") {
     document.getElementById('link4').style.color = "#ffd400";
      $("#link4").unbind();
    }
    if (url == "refrigerante/exibe.php?o=3&t=8") {
     document.getElementById('link7').style.color = "#ffd400";
     $("#link7").unbind();
    }
    if (url == "refrigerante/exibe.php?o=3&t=9") {
     document.getElementById('link8').style.color = "#ffd400";
      $("#link8").unbind();
    }
    if (url == "refrigerante/exibe.php?o=3&t=10") {
     document.getElementById('link6').style.color = "#ffd400";
      $("#link6").unbind();
    }
    if (url == "refrigerante/exibe.php?o=3&t=12") {
     document.getElementById('link5').style.color = "#ffd400";
      $("#link5").unbind();
    }
    if (url == "refrigerante/exibe.php?o=3&t=13") {
     document.getElementById('link9').style.color = "#ffd400";
      $("#link9").unbind();
    }
    if (url == "refrigerante/exibe.php?o=4&t=15") {
     document.getElementById('link10').style.color = "#ffd400";
      $("#link10").unbind();
    }
    if (url == "refrigerante/exibe.php?o=4&t=16") {
     document.getElementById('link11').style.color = "#ffd400";
      $("#link11").unbind();
    }
    if (url == "refrigerante/exibe.php?o=16&t=28") {
     document.getElementById('link12').style.color = "#ffd400";
      $("#link12").unbind();
    }
    if (url == "refrigerante/exibe.php?o=17&t=29") {
     document.getElementById('link13').style.color = "#ffd400";
      $("#link13").unbind();
    }
    if (url == "refrigerante/exibe.php?o=6&t=18") {
     document.getElementById('link14').style.color = "#ffd400";
      $("#link14").unbind();
    }
    if (url == "refrigerante/exibe.php?o=6&t=19") {
     document.getElementById('link15').style.color = "#ffd400";
      $("#link15").unbind();
    }
    if (url == "refrigerante/exibe.php?o=6&t=20") {
     document.getElementById('link16').style.color = "#ffd400";
      $("#link16").unbind();
    }
    if (url == "refrigerante/exibe.php?o=13") {
     document.getElementById('link17').style.color = "#ffd400";
      $("#link17").unbind();
    }
    if (url == "refrigerante/exibe.php?o=31&t=216") {
     document.getElementById('link18').style.color = "#ffd400";
      $("#link18").unbind();
    }
    if (url == "refrigerante/exibe.php?o=31&t=217") {
     document.getElementById('link19').style.color = "#ffd400";
      $("#link19").unbind();
    }
    if (url == "refrigerante/exibe.php?o=5&t=17&a=1") {
     document.getElementById('link20').style.color = "#ffd400";
      $("#link20").unbind();
    }
    if (url == "refrigerante/exibe.php?o=5&t=17&a=2") {
     document.getElementById('link21').style.color = "#ffd400";
      $("#link21").unbind();
    }
    if (url == "refrigerante/exibe.php?o=1771") {
     document.getElementById('link22').style.color = "#ffd400";
      $("#link22").unbind();
    }
    if (url == "refrigerante/exibe.php?o=4810") {
     document.getElementById('link23').style.color = "#ffd400";
      $("#link23").unbind();
    }
}

