function getHTTPObject()
{
  var xmlhttp;

    try
    {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
          try
          {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (e)
          {
                try
                {
                    xmlhttp = new XMLHttpRequest();
                }
                catch (e)
                {
                    xmlhttp = false;
                }
          }
    }
  return xmlhttp;
}
var http = getHTTPObject();

function handleHttpResponseSelect()
{
  //obj= document.getElementById("carrega");
  //obj.style.visibility= "visible";
  //obj.innerHTML= "Carregando...";
  campo_select = document.getElementById("plano");
  if (http.readyState == 4) {
    campo_select.options.length = 0;
    results = http.responseText.split("!");
    for( i = 0; i < results.length; i++ )
    {
          string = results[i].split( "|" );
          var novo= document.createElement("OPTION");
          novo.setAttribute("value", string[1]);
          novo.innerHTML= string[0];
          campo_select.appendChild(novo);
    }
    //obj.style.visibility= "hidden";
  }
}


// coloca o conteúdo da resposta dentro do div "ver"
function handleHttpResponseDiv()
{
  var obj= document.getElementById("carrega");
  obj.style.visibility= "visible";
  obj.innerHTML= "Carregando...";
  var elem = document.getElementById("dados");
  //var elem2= document.getElementById("vermod");
  elem.style.display= "block";
  if (http.readyState == 4)
  {
      resposta= http.responseText;
      elem.innerHTML= resposta;
      obj.style.visibility= "hidden";
      //elem2.style.display= "none";
  }
}
/*
function handleHttpResponseDiv2()
{
  var obj= document.getElementById("carrega");
  obj.style.visibility= "visible";
  obj.innerHTML= "Carregando...";
  var elem = document.getElementById("vermod");
  elem.style.display= "block";
  if (http.readyState == 4)
  {
      resposta= http.responseText;
      var tabela= document.createElement("TABLE");
      tabela.className="geral";
      tabela.setAttribute("width", "90%");
      tabela.setAttribute("border", "0");
      tabela.setAttribute("align", "center");
      tabela.setAttribute("cellspacing", "2");
      tabela.setAttribute("cellpadding", "2");
      
      var tbody= document.createElement("TBODY");
      
      var linha= document.createElement("TR");
      var coluna= document.createElement("TD");
      coluna.className= "menuheader";
      coluna.innerHTML= "Descrição";
      
      var linha1= document.createElement("TR");
      var coluna1= document.createElement("TD");
      coluna1.className= "itens";
      coluna1.innerHTML= resposta;
      
      linha.appendChild(coluna);
      linha1.appendChild(coluna1);
      tbody.appendChild(linha);
      tbody.appendChild(linha1);
      tabela.appendChild(tbody);
      var filhos= elem.childNodes;
      for (var i = 0; i < filhos.length; i++)
      {
         elem.removeChild(filhos[i]);
      }
      elem.appendChild(tabela);
      obj.style.visibility= "hidden";
  }
}

// coloca o conteúdo da resposta dentro do div "ver"
function handleHttpResponseDivTicket()
{
  var obj= document.getElementById("carrega");
  obj.style.visibility= "visible";
  obj.innerHTML= "Carregando...";
  var elem = document.getElementById("tickets");
  elem.style.display= "block";
  if (http.readyState == 4)
  {
      resposta= http.responseText;
      elem.innerHTML= resposta;
      obj.style.visibility= "hidden";
  }
}

*/
// preenche um div com conteúdo html
function fillDiv(url)
{
    http.open("GET", url, true);
    http.onreadystatechange = handleHttpResponseDiv;
    http.send(null);
}
/*
function filldiv2(url)
{
    http.open("GET", url, true);
    http.onreadystatechange = handleHttpResponseDiv2;
    http.send(null);
}
function filldivTicket(url)
{
    http.open("GET", url, true);
    http.onreadystatechange = handleHttpResponseDivTicket;
    http.send(null);
}

function Ver(id)
{
    filldiv("ver.php?id="+id);
}

function VerMod(id)
{
    filldiv2("vermod.php?id="+id);
}

function VerCurso(id)
{
    filldiv("ver.php?id="+id);
}

function exibeModulos(sel)
{
    var id= sel.options[sel.selectedIndex].value;
    filldiv("vermod.php?curso="+id);
}
*/
// preenche um select
function fillSelect(url)
{
  var sel_tipo= document.getElementById("tipoplano");
  var indice= sel_tipo.selectedIndex;
  var tipoplano= sel_tipo.options[indice].value;
  if (tipoplano == "")
  {
        alert('Selecione primeiro um "Tipo de Plano"');
  }
  else
  {
      http.open("GET", url+"?tipo="+tipoplano, true);
      http.onreadystatechange = handleHttpResponseSelect;
      http.send(null);
  }
}

function ordemUp(id,ordem,idcurso)
{
    filldiv("ordemmod.php?id="+id+"&curso="+idcurso+"&ordem="+ordem+"&acao=up");
}

function ordemDown(id,ordem,idcurso)
{
    filldiv("ordemmod.php?id="+id+"&curso="+idcurso+"&ordem="+ordem+"&acao=down");
}




