<!-- =========================================================================================== --> 
<!-- SHEEP Project - Copyright Compomentis Pty Ltd                                               -->
<!-- =========================================================================================== --> 

<!-- =========================================================================================== --> 
<!-- This function loads responses of any URL into any html tag that has an id attribute           -->
<!-- =========================================================================================== --> 
<!-- getContent uses the XMLHttpRequest you always find in a web browser nowadays.               -->
<!-- parameters:                                                                                 -->
<!-- asynchronous: Set to true to perform an asynchronous call (ie your script continues while   -->
<!--               the request and downloads executes); this is particularly useful when you 	   -->						   
<!--               need to retrieve several things at once (from different websites for instance)-->
<!-- url         : Provide here an http(s) url of a web site or service to retrieve data from.   -->
<!-- targetId    : Provide here the id of an existing html element on your page.                 -->
<!--               Although the element can be defined in HTML, this is not a requirement, you   -->
<!--               can use dynamically created elements just as well.                            -->
<!-- noResponse   : Provide here a String (just as an error message) to display when there is no -->
<!--               response from the url.                                                        -->
<!-- destination : Provide here a String (just as an error message) to display when there is no  -->
<!--               response from the url.                                                        -->
<!-- =========================================================================================== --> 
function getContent(asynchronous, url, targetId, noResponse, destination)
{
  var xmlhttp=null;
  if (window.XMLHttpRequest)
  {
    xmlhttp=new XMLHttpRequest();
  }
  else if (window.ActiveXObject)
  {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

  if(xmlhttp.overrideMimeType) // for Firefox
  {
    xmlhttp.overrideMimeType('text/xml');
  }
  xmlhttp.onreadystatechange= function()
  { 
    if (xmlhttp.readyState==4)
    {
      var response;  
      if (xmlhttp.status==200)
      {
        response=xmlhttp.responseText;
      }
      else
      {
        response = noResponse;
      }
      if(destination=="innerText")
      { document.getElementById(targetId).innerText = response; }
      else if(destination=="outerHTML")
      { document.getElementById(targetId).outerHTML = response; }
      else if(destination=="innerHTML")
      { document.getElementById(targetId).innerHTML = response; }
      else
      { window.alert(response); }
    }
  }
  xmlhttp.open("GET",url,asynchronous);
  xmlhttp.send('');
}    







