window.addEvent('domready', function() {
	
	//1.2.3 compatibility fix for $
	window.$ = document.id;
	
	//variables for making things more simple below
	var myStage = $('stage');
	var myMids = $$('li.mid img');	
	var myThumbs = $$('li.thumb img');
	
	myStage.set('opacity', .0001);
	$('thumbs').set('opacity', .0001);
	
	var theLoader = new Element('div', { 'id' : 'loader' });
	$('content').grab(theLoader);

	
	var theSources = new Array();
	myMids.each(function(el, i){
		var tempSrc = el.getProperty('src');
		theSources.push(tempSrc);
	});
	
	//preloading images here
	var myImages = new Asset.images(theSources, {
		onProgress: function(counter){
			//
		},

		onComplete: function(){
			theLoader.set('opacity', 0);
			myStage.tween('opacity', 1);
			$('thumbs').tween('opacity', 1);
			
			if(myMids.length > 0) {
				var myGallery = new GalleryDisplay({
					thumbsArray: myThumbs,
					midsArray: myMids,
					transitionTime: 1000, 
					imgContainer:myStage
				});
				myGallery.start();
			}
			
		}
		
	});
	//end images load
	
	
	
	
});