// here we define global variable
var ajaxdestination="";
var previoushtml="";
var pleasewaitplace="";

function GetDataAnywhere(what,where,pleasewaitplace, pleasewait) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

previoushtml = document.getElementById(pleasewaitplace).innerHTML ;
document.getElementById(pleasewaitplace).innerHTML = pleasewait;

// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = TriggeredAnywhere; // when request finished, call the function to put result to destination DIV

xmlhttp.open("GET", what);
xmlhttp.send(null);
return false;
}


function TriggeredAnywhere() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 
//document.getElementById(ajaxdestination ).innerHTML = "";
document.getElementById(ajaxdestination).innerHTML = xmlhttp.responseText;
document.getElementById(pleasewaitplace).innerHTML = previoushtml;
}
