// JavaScript Document
function loadPage(what,pageURL,delay,afterF) 
{
 var xmlHttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
 xmlHttp.open("GET",pageURL,delay);
 if (!xmlHttp)
 {
  window.alert("Server didn't respond in given time - try again later");
  return;
 }
 
 if (what)
 {
  if (delay==true)
  {
   xmlHttp.onreadystatechange=function() 
   {
	try
	{
     if(xmlHttp && xmlHttp.readyState == 4 && (xmlHttp.status == 200 || xmlHttp.status == 0))
     {		 
      what.innerHTML=xmlHttp.responseText;
	  if (afterF)
	   afterF();
	 }
	 else if (xmlHttp.readyState==4 && xmlHttp.status == 404)
     {
      window.alert("Couln't find \""+pageURL+"\" file.");
	 }
	}
	catch(e)
	{
	}
   }
   xmlHttp.send('');
  }
  else
  {
   xmlHttp.send('');
   if(xmlHttp.readyState==4 && xmlHttp.status == 200)
   {
    what.innerHTML=xmlHttp.responseText;
	if (afterF)
	 afterF();
   }
   else if (xmlHttp.status == 404)
    window.alert("Couln't find \""+pageURL+"\" file.");
  }
 }
 else
 {
  window.alert("Couldn't find target object"); 
 }
}

function justLoadPage(pageURL,delay)
{
 var buffer = document.createElement('div');
 loadPage(buffer,pageURL,delay);
}