var xmlHttp = GetXmlHttpObject()

function changeImage(img,med){
	//document.getElementById('img_area').innerHTML = "<img id='current_image' src='"+img+"' alt=image title=''/>";
	xmlHttp.open("GET", "serverProxy.php?section=utility&type=imgInfo&medium="+med+"&img="+img, true);  
  // define the method to handle server responses
  xmlHttp.onreadystatechange = updateImageInfo;
  // make the server request
  xmlHttp.send(null);
}
	
function updateImageInfo(){
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
			document.getElementById('content').innerHTML = xmlHttp.responseText;
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }	
}

function purgeThumbs(med){
	xmlHttp.open("GET", "serverProxy.php?section=utility&type=purge&medium="+med, true);  
  // define the method to handle server responses
  xmlHttp.onreadystatechange = function(){
	  if (xmlHttp.readyState == 4) 
  	{
	    // status of 200 indicates the transaction completed successfully
	    if (xmlHttp.status == 200) 
	    {
				//alert('Thumbs purged. Please refresh.' + xmlHttp.responseText);
	    } 
	    // a HTTP status different than 200 signals an error
	    else 
	    {
	      alert("There was a problem accessing the server: " + xmlHttp.statusText);
	    }
  	}	
	};
  // make the server request
  xmlHttp.send(null);
}

function GetXmlHttpObject()
{
	  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)


    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}
