
/*Begin Image manipulation code */

/*function ImageSwapper(swp)
*	swp = {tagname:'image Name', onImageUrl:'onImageUrl', offImageUrl:'onImageUrl', clickedImageUrl:'clickedImageUrl'}
* Sample use case: submit button
*	isSUB = new ImageSwapper({tagname:"subBtn",onImageUrl:"submit_off.gif", offImageUrl:"submit_off.gif", clickedImageUrl:"submit_click.gif"});
*	Bind to event handler: onMouseDown="isSUB.clickImage()" onMouseUp="isSUB.turnImageOff()" onMouseOut="isSUB.turnImageOff()", etc. 
*/

function ImageSwapper(swp){
  //properties
  this.tagname 			= swp.tagname;
  this.offImage 		= new Image();
  this.offImage.src = swp.offImageUrl;
  this.onImage 			= new Image();
  this.onImage.src 	= swp.onImageUrl;
  this.clickedImage = new Image();
  this.clickedImage.src = swp.clickedImageUrl;  
  // methods
  this.turnImageOn 	= ImageSwapper_turnImageOn;
  this.turnImageOff = ImageSwapper_turnImageOff;
  this.clickImage 	= ImageSwapper_clickImage; 
}

function ImageSwapper_turnImageOn(){
  if (document.images) {
    document[this.tagname].src = this.onImage.src;        
  }
}

function ImageSwapper_turnImageOff(){
  if (document.images) {
    document[this.tagname].src = this.offImage.src;        
  }
}

function ImageSwapper_clickImage(){
  if (document.images) {
    document[this.tagname].src = this.clickedImage.src;        
  }
}

/* End Image manipulation code */


