//	Class::AjaxMapImage
	AjaxMapImage = {};
	
	AjaxMapImage.initialize = function()
		{
		//	Change the loading message here...
			AjaxMapImage.LoaderMessage = "<img src=\"AjaxLoadIcon.gif\" /><p>Loading map</p>";
			AjaxMapImage.ImageId = "Image";
			AjaxMapImage.LoaderId = "Loader";
		}
		
	AjaxMapImage.initialize();
	
	AjaxMapImage.update = function(_containter, _uri)
		{
		
			
		//	Create id for image
			var ImageId = _containter + AjaxMapImage.ImageId;
		//	Creat id for the loader
			var LoaderId = _containter + AjaxMapImage.LoaderId;
		//	Select the map container [_container]
			var Container = Utilities.getElement(_containter);
		//	Remove existing image from the container
			if (Utilities.getElement(ImageId) != null)
				{
				//	Hide the image before removing
					Utilities.toggle(ImageId);
					Utilities.removeElement(Utilities.getElement(ImageId));
				}
		//	Create the image element [_uri] and set its status to Loading
			var ImageElement = Utilities.createElement("img",{id:ImageId,src:_uri});
		//	Create the loading layer
			var Loader = Utilities.createElement("div",{id:LoaderId,className:'Loader',innerHTML:AjaxMapImage.LoaderMessage});
		//	Append the loader to the container
			Utilities.appendChild(Container,Loader);
		//	Append the image to the container
			Utilities.appendChild(Container,ImageElement);
		//	Hide the image during loading
			Utilities.toggle(ImageId);
		//	Check to see if the image has finished loading [milliseconds]
			setTimeout("AjaxMapImage.loadStatus('"+_containter+"')",500);
		}
	
	AjaxMapImage.loadStatus = function(_containter)
		{
		//	Create id for image
			var ImageId = _containter + AjaxMapImage.ImageId;
		//	Creat id for the loader
			var LoaderId = _containter + AjaxMapImage.LoaderId;
		//	Select the image tag
			var ImageElement = Utilities.getElement(ImageId);
		//	Check to see if the image is loaded, returns boolean
			if(ImageElement.complete)
				{
				//	Evaluated to True, the image is loaded
				//	Select the Loader object
					var Loader = Utilities.getElement(LoaderId);
				//	Remove the Loader object
					Utilities.removeElement(Loader);
				//	Show the image
					Utilities.toggle(ImageId);
				}
			else
				{
				//	Evaluated to False, image is still loading
				//	Recursive call to check if image has finished loading [milliseconds]
					setTimeout("AjaxMapImage.loadStatus('"+_containter+"')",1000);
				}
		}


//	Class::Utilities
	Utilities = {};
	
	Utilities.getElement = function(_id) {
			return document.getElementById(_id);
	}
	
	Utilities.toggle = function(_id) {
		this.getElement(_id).style.display = (this.getElement(_id).style.display == '')? 'none' : '';
	}
	
	Utilities.createElement = function(_element, _attributes) {
		var element = document.createElement(_element);
		for (attribute in _attributes) {
			element[attribute] = _attributes[attribute];
		}
		return element
	}
	
	Utilities.removeElement = function(_element) {
		_element.parentNode.removeChild(_element);	
	}
	
	Utilities.appendChild = function() {
		
		if (this.appendChild.arguments.length > 1) {
			var a = this.appendChild.arguments[0];
			for (var i=1;i <this.appendChild.arguments.length; i++) {
				if (arguments[i]){
					a.appendChild(this.appendChild.arguments[i]);
				}
			}
			return a;
		}
		else {
			return null;
		}
	}