// object constructor
function csnSmartImageObject(imgURI,preload) {
  // define local properties
  this.URI = imgURI;
  // we don't need this image until we are ready to load
  this.imageobj = null;
	
  // attach object's methods
  this.load = csnSmartImageObjectLoad; //  force the loading of the image
  this.getImage = csnSmartImageObjectGetImage; /* this function will 
    retrieve the source of the image from this object for use by other
    javscript objects */
	
  // complete constuctor
  if (preload) { // if preload is true 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
    /* 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;
  }
}
