/* Roll Over Images
 *
 * Require Prototype for getElementsByClassName and eventHandler.bind
 *
/*----------------------last updated: DBC\Leo @ 2-14-07 ---*/
DBC.ROImages = function() {
	this.className = "";
	this.postfix = "_ro";
	if (arguments.length >0) {
		this.className = arguments[0]; //first argument is the classname of the images
	}
	if (arguments.length >1) {
		this.postfix = arguments[1]; //second argument (optional) is the postfix for the roll over images
	}
	
	  
	 
	this.init = function() {
		var imgs = document.getElementsByClassName(this.className);
		if (imgs.length) {
			this.imageList = new Array(imgs.length)
			for (var i=0; i<this.imageList.length; i++) {
				this.imageList[i] = new Object();
				this.imageList[i].img = imgs[i];
				this.imageList[i].origSrc = imgs[i].src;
				this.imageList[i].roSrc = imgs[i].src;
	
				var src_file = imgs[i].src.split(".");
				if (src_file.length > 1) {
					this.imageList[i].roSrc = "";
					for (var x=0; x<src_file.length-2; x++) {
						this.imageList[i].roSrc += (src_file[x] + ".");
					}
					this.imageList[i].roSrc += (src_file[src_file.length-2] + this.postfix + "." + src_file[src_file.length-1]);
					
					//preload the roll over image
					var preloadImg = new Image();
					preloadImg.src = this.imageList[i].roSrc;
				}
				
				this.imageList[i].show_roSrc = function() {
					this.img.src = this.roSrc;
					if (this.img.id == "our_chef") {
						mouseOnSpecial();
			
					}
				}
				this.imageList[i].show_origSrc = function() {
					this.img.src = this.origSrc;
					if (this.img.id == "our_chef") {
									mouseOffSpecial();
					}
				}
				imgs[i].onmouseover = this.imageList[i].show_roSrc.bind(this.imageList[i]);
				imgs[i].onmouseout = this.imageList[i].show_origSrc.bind(this.imageList[i]);
			}
		}
	}
}