var loadImage = new Image();
loadImage.src = '/images/spinner.gif';
var errorImage = new Image();
errorImage.src = '/images/error_01.gif';
var newImage;
var ContentID;

function handleLoad(containerid)
{
	document.getElementById(containerid).innerHTML=""
	document.getElementById(containerid).appendChild(newImage);
}

function handleError(containerid)
{
	document.getElementById(containerid).innerHTML=""
	document.getElementById(containerid).appendChild(errorImage);
}

function handleAbort(containerid)
{
	document.getElementById(containerid).innerHTML=""
	document.getElementById(containerid).appendChild(errorImage);
}

function ajaxImage(url, containerid)
{

	newImage = new Image();
	
	//Load the waiting image
	document.getElementById(containerid).innerHTML="<table bgcolor='white' width='100%'><tr><td align='center' valign='middle'><img src='/images/spinner.gif' /><br><font size='2'>Loading Image...</font></td></tr></table>"
	
	//Event Handling
	 newImage.onload = ajaxImage.prototype.onload;
   newImage.onerror = ajaxImage.prototype.onerror;
   newImage.onabort = ajaxImage.prototype.onabort;
	
	//Load image
	newImage.src = url;	
	newImage.containerid = containerid;
	
}


ajaxImage.prototype.onload = function()
{

   this.bLoaded = true;
   handleLoad(this.containerid)

}

ajaxImage.prototype.onerror = function()
{

   this.bError = true;
   handleError(this.containerid)

}

ajaxImage.prototype.onabort = function()
{

   this.bAbort = true;
   handleAbort(this.containerid)

}