// set focus on a field of a form
function setFocus(idField)
{
   document.getElementById(idField).focus();
}

// AJAX routines

// create a variable that will be used for all AJAX processes
function startAjax()
{
   // check if the browser is IE or others
   if (window.ActiveXObject)
      ajax = new ActiveXObject("Microsoft.XMLHTTP"); // initialize the ActiveX object, is the IE browser
   else
      ajax = new XMLHttpRequest(); // other browsers: FireFox, etc

   return ajax;
}

function selectContents(url)
{
   document.getElementById('page_panel').innerHTML = ""; // clear the contents of the page
   ajax = startAjax(); // start the AJAX object
	
   // check if the object was created
   if (ajax)
   {
      // wait until the state of the server changes
      ajax.onreadystatechange = changeContents;
      ajax.open("GET", url); // open server connection
      ajax.send(null); // send the request
   }
}

function changeContents()
{
   // check the request status
   if (ajax.readyState == 4)
   {
      // verify the status number, if different than 200 there are errors
      if (ajax.status == 200)
         document.getElementById('page_panel').innerHTML = ajax.responseText; // update div with new page
      else
         selectContents("general.php?msgtitle=ERROR!&message="+ajax.statusText);
   }
}
// end of AJAX routines
