// JavaScript Document
var AccImg = Class.create();

AccImg.prototype = {	
	productDetailsID: 'content_accessories_product_details',
	vestImgID: 'vestImg',
	tieImgID: 'tieImg',
	comboImgID: 'comboImg',
	
	comboImgFile: '/images/accessories_combo.gif',	
	
	//object functions - use 'this' to refer to functions and class variables
	initialize: function() {			
		
		if(!document.getElementById || !$(this.productDetailsID)) {return;}
		
		this.preLoadImgs();
		this.addImgRollovers();
		
	},	
	
	preLoadImgs: function () {
		var temp;		
		temp = new Image();		
		temp.src = $(this.comboImgID).src.replace(/.gif/,'_' + this.vestImgID.replace(/Img/,'') + '.gif');
		temp.src = $(this.comboImgID).src.replace(/.gif/,'_' + this.vestImgID.replace(/Img/,'') + '.gif');		
		
	},
	
	addImgRollovers: function() {
		
		addEvent($(this.vestImgID),'mouseover',this.imgOver,false);
		addEvent($(this.vestImgID),'mouseout',this.imgOut,false);
		
		addEvent($(this.tieImgID),'mouseover',this.imgOver,false);
		addEvent($(this.tieImgID),'mouseout',this.imgOut,false);
		
	},
	
	//event functions (must use object instance name to refer to class vars, NOT 'this')
	imgOver: function(e) {
		local_target = findTarget(e);
		
		if(!local_target) {return;}		
		
		$(myAccImg.comboImgID).src = $(myAccImg.comboImgID).src.replace(/.gif/,'_' + local_target.id.replace(/Img/,'') + '.gif');
	},
	
	imgOut: function(e) {
		local_target = findTarget(e);
		
		if(!local_target) {return;}
		
		$(myAccImg.comboImgID).src = myAccImg.comboImgFile;
	}
}	
	
addEvent(window, 'load', function() {myAccImg = new AccImg();}, false);