// object constructor
function csnSmartImageObject(imgURI,preload) {
	// define local properties
	this.URI = imgURI;
	this.imageobj = null; // we don't need this image until we are ready to load it
	
	// attach object's methods
	this.load = csnSmartImageObjectLoad; // this fuction will force the loading of the image
	this.getImage = csnSmartImageObjectGetImage; // this function will retireve the source of the image from this object for use by other javscript objects
	
	// complete constuctor
	if (preload) { // if preload is true we want to load the image up right away
		this.load();
	}
}

// define object's methods
function csnSmartImageObjectLoad() {
	this.imageobj = new Image(); // create the image object
	this.imageobj.src = this.URI;
}

function csnSmartImageObjectGetImage() {
	if (this.imageobj) { // if we already have it, send the src along
		return this.imageobj.src;
	} else { // if not send the URI to the source back, process a concurrent load here
		/* note, it may be better form to load() and then return the full
			source when its done loading, but this is a much easier way to
			code it and works because the image.src is "overloaded" and can
			handle either case */
		this.load();
		return this.URI;
	}
}