  var xmlHttp;

  var READY_STATE_UNINITIALISED = 0;
  var READY_STATE_LOADING = 1;
  var READY_STATE_LOADED = 2;
  var READY_STATE_INTERACTIVE = 3;
  var READY_STATE_COMPLETE = 4;

  function getHttpRequestObject(){
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
  }

/* Use this to GET
	dataSource - page to retrieve data from
	id - target id for content
	(e.g.) 	getDataForId($basePath + "view/contact.php", "content");
*/
function getDataForId(dataSource, id){
	getHttpRequestObject();
	if (xmlHttp){
		var obj = document.getElementById(id);
	    xmlHttp.open("GET", dataSource, true);
	    xmlHttp.onreadystatechange=function(){
	      if(xmlHttp.readyState==4 && xmlHttp.status==200){
	        obj.innerHTML = xmlHttp.responseText;
	        var lastSlash = dataSource.lastIndexOf("/");
	        var pageId = dataSource.substring(lastSlash);
	        pageTracker._trackPageview(pageId);
	        }
	      }
	    xmlHttp.send(null);
	}
}

function ajaxSanity(text){
	alert(text);
}

/* Use this to post N.B. Check the path to the URL
	url - page to retrieve data from
	parameters - target id for content
	(e.g.) makePOSTRequest("<?=PATH_BASE?>view/order.php", "quantity=" + encodeURI(document.getElementById("quantity").value) + "&" + "origin=" + encodeURI("australia"))
*/
function makePOSTRequest(url, parameters) {
	xmlHttp = false;
	getHttpRequestObject();

	xmlHttp.onreadystatechange = alertContents;
	xmlHttp.open('POST', url, true);
//alert(parameters);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}

function alertContents() {
   if (xmlHttp.readyState == 4) {
      if (xmlHttp.status == 200) {
//         alert(xmlHttp.responseText);
         result = xmlHttp.responseText;
         document.getElementById('content').innerHTML = result;
      } else {
         alert('There was a problem with the request.');
      }
   }
}

function makePOSTRequestNoResponse(url, parameters) {
	xmlHttp = false;
	getHttpRequestObject();

	xmlHttp.onreadystatechange = alertContentsNoResponse;
	xmlHttp.open('POST', url, true);
//alert(parameters);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", parameters.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters);
}

function alertContentsNoResponse() {
   if (xmlHttp.readyState == 4) {
      if (xmlHttp.status == 200) {
//         alert(xmlHttp.responseText);
      } else {
         alert('There was a problem with the request.');
      }
   }
}


function uploadFile(obj) {
   var poststr = "name=" + encodeURI( document.getElementById("name").value ) +
                 "&email=" + encodeURI( document.getElementById("email").value) +
                 "&photo=" + encodeURI( document.getElementById("photo").value) +
                 "&comment=" + encodeURI( document.getElementById("comment").value +
                 "&submit=''");
//                 alert(poststr);
   makePOSTRequest('./view/upload.php', poststr);
}
