// JavaScript Document
function runajax(objID, serverPage)
{
var xmlhttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlhttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  if(!xmlhttp && typeof XMLHttpRequest != 'undefined')
  {
	  xmlhttp = new XMLHttpRequest();
  }
  
  var obj = document.getElementById(objID);
  xmlhttp.open("GET",serverPage);
  xmlhttp.onreadystatechange = function ()
  {
	  if(xmlhttp.readyState == 4)
	  {
		  obj.innerHTML = xmlhttp.responseText;
	  }
  }
  xmlhttp.send(null);
}

var refreshrate = 1000;

function updateStatus(local)
{
	document.getElementById(local).innerHTML = "Carregando...";
}

function refreshView()
{
	setTimeout('runajax("middiv","includes/cursos_lista.php")',refreshrate);
}

function imageClick(campi,tipo,local)
{
	var obj = document.getElementById(local);
	if(obj.className == "contCursosHide") {
		obj.className = "contCursosShow";
		updateStatus(local);
		runajax(local,'includes/cursos_lista.php?tipo='+tipo+'&campi='+campi);
	} else {
		obj.className = "contCursosHide";
	}
}

function areaClick(area,tipo,local)
{
	var obj = document.getElementById(local);
	if(obj.className == "contCursosHide") {
		obj.className = "contCursosShow";
		updateStatus(local);
		runajax(local,'includes/cursos_lista_area.php?tipo='+tipo+'&area='+area);
	} else {
		obj.className = "contCursosHide";
	}
}