//-----------------------------------------------
//create XmlHttp Object (browser-sensitive)
function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}

//------------------------------------------------------
// Shorter version to document object ID access
function getId(id) {
  return document.getElementById(id);
}

//------------------------------------------------
function isDefined( variable)
{
    return (typeof(variable) == "undefined")?  false: true;
}

//-----------------------------------------------
// send command and get response from server
// INPUTS:
//    url    : the url to get
//    method : the method to use (GET or POST)
//    idout  : the function to call with results or tag ID to put results into
function getpage(url,method,idout) {

  //default values for non-included inputs
  if (!isDefined(idout)) idout = function (response) {};

  if (url.length==0)
	  { 
    if (typeof(idout) == "function") {
      idout("");
    } else {
      getId(idout).innerHTML="<!>";
    }
    return;
  }

  var xmlHttp = GetXmlHttpObject()
  if (xmlHttp==null) return;

  xmlHttp.onreadystatechange = function () {
    if (xmlHttp.readyState==4) { 
        var status = 0;
        var response = '';

        //see if we can get a response, if not set status as error
        try {
          status = xmlHttp.status;
        }
        catch (err) {
          status = -1;
        }
        response = xmlHttp.responseText;

        //write response to lastin field and then call function or output to requested element
        if (typeof(idout) == "function") {
          idout(response);
        } else {
          getId(idout).innerHTML = response;
        }
        xmlHttp = null;
    }
  };
  
	xmlHttp.open(method,url,true);
	xmlHttp.send(null);

}

function opacity(element,level) {
  element.style.zoom = 1;
  element.style.opacity = level;
  element.style.MozOpacity = level;
  element.style.KhtmlOpacity = level;
  element.style.filter = "alpha(opacity=" + (level * 100) + ");";
}

//-------------------------------------------------------

var paused = false;
var newcontent = '';
var nextEgDelay = 30;
var pauseDelay = 5;

function getConsultingEg() {
  if (paused) {
    //user has mouse over box, don't do anything right now
    setTimeout("getConsultingEg();",pauseDelay*1000);
  } else {
    //getpage("http://127.0.0.1/oneconsultingeg.php?time='" + (new Date()).getTime() + "'","GET",updateEgcustom);
    getpage("http://software.eigenvector.com/oneconsultingeg.php?time='" + (new Date()).getTime() + "'","GET",updateEgcustom);
    newcontent = '';
  }
}
function updateEgcustom(response) {
  newcontent = response;
  for (j=0; j<=1; j+=.1) {
    setTimeout("opacity(getId('egcustom')," + (1-j) + ");",(j+1)*500);
  }
  setTimeout("getId('egcustom').innerHTML = newcontent;",(1+1)*500);
  for (j=0; j<=1; j+=.1) {
    setTimeout("opacity(getId('egcustom')," + j + ");",(j+2)*500);
  }
  setTimeout("getConsultingEg();",nextEgDelay*1000);
}

