


var AVProductPage = new Class({
	
	images_arr : null,
	
	initialize: function() {
		this.setThumbActions();
	},
	setThumbActions: function() {
		var thumbs_div = $$('.thumbs')[0];

		var target = thumbs_div.getParent().getElement(".image");
		if(target) {
			this.images_arr = target.getElements("img");
				thumbs_div.setStyles({
				display: 'block',
				cursor: 'pointer'
			});
		
			var thumbs = thumbs_div.getElements("div");
			thumbs.each(this.setThumbEvents.bind(this));
		}
	},
	setThumbEvents: function(thumb, i) {
		thumb.store("image", this.images_arr[i]);
		thumb.addEvent("mouseover", this.thumbOver);
	},
	
	thumbOver: function() {
		var img = this.retrieve("image");
		img.getParent().getElements("img").each(function(el) {
			if(el == img) {
				el.setStyle("display", "block");
			}else{
				el.setStyle("display", "none");
			}	
		});	
	}
});


document.addEvent("domready", function() {
	new AVProductPage();	
});
