// addLoadEvent function courtesy of Simon Willison 
// http://www.webreference.com/programming/javascript/onloads/
function addLoadEvent(func) 
{ 
	var oldonload = window.onload; 
	
	if (typeof window.onload != 'function') 
	{
		window.onload = func; 
	} 
	else 
	{ 
		window.onload = function() 
		{
			if (oldonload) 
			{
				oldonload(); 
			} 
			func(); 
		} 
	}
}

function getAttributeValue(element, attribute)
{
	// Loop through the attributes, see if there is a match
	for (var i = 0; i < element.attributes.length; i++)
	{
		if (element.attributes[i].name == attribute)
			return element.attributes[i].value
	}
	
	// If there is no match, return null
	return null;
}

function getElementStyle(element, style)
{
	if (getComputedStyle)
		return getComputedStyle(element, null)[style];
	else
		return element.currentStyle[style]; // Test this on IE
}

// Function taken from W3Schools.  http://www.w3schools.com/ajax/ajax_example_suggest.asp
function getXmlHttpRequestObject()
{
	if (window.XMLHttpRequest)
	{
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

var documentImages = new Array();

function saveImageData()
{
	for (var i = 0; i < window.document.images.length; i++)
	{
		documentImages[i] = window.document.images[i].src;
		
		// Yes, seriously.  Theses lines actually do something, DON'T delete them.
		//window.document.images[i].height = window.document.images[i].height;
		//window.document.images[i].width = window.document.images[i].width;
		
		window.document.images[i].src = "";
	}
}

function restoreImageData()
{
	for (var i = 0; i < window.document.images.length; i++)
	{
		window.document.images[i].src = documentImages[i];
	}
}