

var ImageTransition = new Class({
	options: {
		objControl: null,
		objThumb: null,
		objDetail: null,
		strNewImage: '',
		objStatus: null
	},
	initialize: function(options)
	{
		this.setOptions(options);
		this.StartTransition(
			this.options.objControl,
			this.options.objThumb,
			this.options.objDetail,
			this.options.strNewImage,
			this.options.objStatus
		);
	},
	StartTransition: function(objControl, objThumb, objDetail, strNewImage, objStatus){
		if(objControl && objThumb && objDetail && strNewImage != '')
		{
			strImgPath = objDetail.src;
			arrImgPath = strImgPath.split('/');
			strImgPath = "";
			
			for(var i=0; i<(arrImgPath.length - 1); i++)
			{
				strImgPath += arrImgPath[i] + "/"
			}
			var arrImages = [strImgPath + strNewImage];
			
			objControl.addEvent('click', function(e){
				// set classes
				
				// first find objects with "current" class
				$$('#productImagePager img.current')[0].className = '';
				$$('#productImagePager div.productThumbLeftCurrent')[0].className = 'productThumbLeft';
				
				// now set the current classes
				objThumb.className = "current";
				objStatus.className = "productThumbLeftCurrent";
				
				// Load new image
				new Asset.images(arrImages, {
					onComplete: function(){
						// create new Fx
						var fadeFx = new Fx.Style(objDetail.id, 'opacity', {
							duration: 200, 
							transition: Fx.Transitions.Quart.easeInOut,
							onComplete: function(){objDetail.src = strImgPath + strNewImage;}
						});
						
						// fade out
						fadeFx.start(1,0);
						// fade in
						fadeFx.start.pass([0,1], fadeFx).delay(500);
					}
				});
			});
		}
	}
});

ImageTransition.implement(new Options, new Events);




var CachedImages = new Class({
	options: {
		arrImages: ''
	},
	initialize: function(options){
		this.setOptions(options);
		this.CachedImages(this.options.arrImages);
	},
	CachedImages: function(arrImages){
		if(arrImages.length > 0)
		{
			// Preload images
			new Asset.images(arrImages, {

			});
		}
	}
});

CachedImages.implement(new Options, new Events);






window.onload = function()
{
	// initialization functions
	var arrImages = new Array(
    
		//"../images/navigation/nav_aboutus_on.gif",
		//"../images/navigation/nav_atriumevents_on.gif",
		//"../images/navigation/nav_contactus_on.gif",
		//"../images/navigation/nav_customerservice_on.gif",
		//"../images/navigation/nav_mediacoverage_on.gif",
		//"../images/navigation/nav_museum_on.gif",
		//"../images/navigation/nav_newsandtravels_on.gif",
		//"../images/navigation/nav_store_on.gif",
		//"../images/icons/icon_leftnav_arrow_up.gif",
		//"../images/shop/bg_product_detail_row.gif",
		//"../images/bg_product_thumb_arrow.gif"
    
	);
	
	new CachedImages({ arrImages: arrImages });
}
