/* 

	Martin Smith
	created by Ryan Mitchell (ryan@rtnetworks.net)

*/
window.addEvent('domready',function() {

	// initial delay
	var delay = 2000;
	
	// space to hold functions that should be run on section change
	var onchange = "";
	
	// hide lots of things
	$('motif').fade('hide'); 
	$('logo').fade('hide'); 
	$$('#main img').each(function(el) { el.fade('hide') });
	$('links').fade('hide'); 
	$('gallery_images').fade('hide'); 
	$('scrollarea').fade('hide');
	$$('#gallery_images img').each(function(el) { el.fade('hide') });  
	
	var runchange = function() {
	
		try { eval(onchange); }
		catch(e) { }
		
		onchange = '';
	
	};
	
	// preload all images
	var i = [
		'images/overview-on.gif',
		'images/contact-on.gif',
		'images/contact-image.jpg',
		'images/msmith-on.gif',
		'images/contact-details.gif',
		'images/1-text.gif',
		'images/1-image.jpg',
		'images/1-image2.jpg',
		'images/2-text.gif',
		'images/2-image.jpg',
		'images/2-image2.jpg',
		'images/3-text.gif',
		'images/3-image.jpg',
		'images/3-image2.jpg',
		'images/1.gif',
		'images/2.gif',
		'images/3.gif',
		'images/4.gif',
		'images/5.gif',
		'images/6.gif',
		'images/1-on.gif',
		'images/2-on.gif',
		'images/3-on.gif',
		'images/4-on.gif',
		'images/5-on.gif',
		'images/6-on.gif',
		'images/neven-splash.jpg',
		'images/neven-text.gif',
		'images/neven-logo.gif',
		'images/overview-splash.jpg',
		'images/design-text.gif',
		'images/joinery-text.gif',
		'images/detail-text.gif',
		'images/click-here-to-open.gif',
		'images/click-here-to-close.gif',
		'images/gallery/Freestanding/1.jpg',
		'images/gallery/Freestanding/2.jpg',
		'images/gallery/Freestanding/3.jpg',
		'images/gallery/Freestanding/4.jpg',
		'images/gallery/Freestanding/5.jpg',
		'images/gallery/Freestanding/6.jpg',
		'images/gallery/Georgian/1.jpg',
		'images/gallery/Georgian/2.jpg',
		'images/gallery/Georgian/3.jpg',
		'images/gallery/Georgian/4.jpg',
		'images/gallery/Georgian/5.jpg',
		'images/gallery/Georgian/6.jpg',
		'images/gallery/Georgie/1.jpg',
		'images/gallery/Georgie/2.jpg',
		'images/gallery/Georgie/3.jpg',
		'images/gallery/JulieCooper/1.jpg',
		'images/gallery/JulieCooper/2.jpg',
		'images/gallery/JulieCooper/3.jpg',
		'images/gallery/NevenMaguire/1.jpg',
		'images/gallery/NevenMaguire/2.jpg',
		'images/gallery/NevenMaguire/3.jpg',
		'images/gallery/NevenMaguire/4.jpg',
		'images/gallery/NevenMaguire/5.jpg',
		'images/gallery/NevenMaguire/6.jpg',
		'images/gallery/Nevil/1.jpg',
		'images/gallery/Nevil/2.jpg',
		'images/gallery/Nevil/3.jpg',
		'images/gallery/Nevil/4.jpg',
		'images/gallery/Nevil/5.jpg',
		'images/gallery/Peter/1.jpg',
		'images/gallery/Peter/2.jpg',
		'images/gallery/Peter/3.jpg',
		'images/gallery/Peter/4.jpg',
		'images/gallery/Peter/5.jpg',
		'images/gallery/Smith/1.jpg',
		'images/gallery/Smith/2.jpg',
		'images/gallery/Smith/3.jpg',
		'images/gallery/Smith/4.jpg',
		'images/gallery/Steen/1.jpg',
		'images/gallery/Steen/2.jpg',
		'images/gallery/Steen/3.jpg'
	];
		
	i.each(function(e) { var img = new Element('img',{ src: e } ); });

	
	// set up home function
	window.gohome = function() {
	
		if($('home-img') == null) {
		
			runchange();
			
			// choose a random number, either 1 or 2
			var rand = Math.ceil(Math.random()*2);
			
			var image = (rand==1) ? '': '2';
	
			$$('#main').each(function(el) {
			
				var img = new Element('img',{
					id: 'home-img',
					src: 'images/'+window.splashimage+'-image'+image+'.jpg',
					alt: 'image',
					styles : {
						'margin-top': '-377px'
					}
				});
				
				img.fade('hide');
				img.inject(el);
				img.set('tween',{duration:2000});
				img.tween('opacity',1);
				(function() { $("main_text_img").fade(0); }).delay(1600);
			
			});
			
			onchange += '$("home-img").dispose(); ';
			
			// what text are we showing?
			window.splashimage++;
			if(window.splashimage == 4) window.splashimage = 1;
			
			(function() {
				
				if($('home-img') != null) {
				
					$('home-img').tween('opacity',0);
						  
					(function() { runchange();
					
						window.gohome();
					
					}).delay(2100);
				
				}
				
			}).delay(10000);
		
		}
	
	} // end home function
	
	// contact us
	window.contact = function() {
		
		if($('contact-details') == null) {

			runchange();

			// turn link white
			$("contact").setProperty("src",$("contact").getProperty("src").replace(".gif","-on.gif"));
		
			// what do i do on a new link being clicked?
			onchange += '$("contact").setProperty("src",$("contact").getProperty("src").replace("-on.gif",".gif"));';
			
			var details = new Element('img',{
			
				id: 'contact-details',
				src: 'images/contact-details.gif',
				usemap: '#contact-map'
			
			});
			
			var map = new Element('map',{
				'name': 'contact-map',
				'id': 'contact-map',
				'html': '<area shape="rect" coords="-1,50,197,66" href="mailto:info@martinsmithdesign.com?subject=Web inquiry:" />'
			});
			
			details.inject($('mid-left'));
			map.inject($('mid-left'));
			
			var img = new Element('img',{
				id: 'contact-img',
				src: 'images/contact-image.jpg',
				alt: 'contact',
				styles : {
					'margin-top': '-377px'
				}
			});
			
			img.fade('hide');
			img.inject($('main'));
			img.set('tween',{duration:2000});
			img.tween('opacity',1);
			
			// what do i do on a new link being clicked?
			onchange += '$("contact-map").dispose(); $("contact-details").dispose(); $("contact-img").dispose();';
		
		}

	
	} // end contact
	
	// overview
	window.overview = function() {
		
		if($('overview-img') == null) {
		
			runchange();
	
			// turn link white
			$("overview").setProperty("src",$("overview").getProperty("src").replace(".gif","-on.gif"));
		
			// what do i do on a new link being clicked?
			onchange += '$("overview").setProperty("src",$("overview").getProperty("src").replace("-on.gif",".gif"));';
			
			var img = new Element('img',{
				id: 'overview-img',
				src: 'images/overview-splash.jpg',
				alt: 'overview',
				styles : {
					'margin-top': '-377px'
				}
			});
			
			img.fade('hide');
			img.inject($('main'));
			img.set('tween',{duration:2000});
			img.tween('opacity',1);
			
			// what do i do on a new link being clicked?
			onchange += '$("overview-img").dispose();';
			
			(function() {
					  
				img.tween('opacity',0);
				
				(function() {
			
					if($("overview-img")) $("overview-img").dispose();
			
					var img = new Element('img',{
					
						id: 'overview-text',
						src: 'images/design-text.gif',
						usemap: '#overview-map',
						alt: 'overview text',
						styles : {
							'margin-top': '-377px'
						}
					
					});
					
					var map = new Element('map',{
						'name': 'overview-map',
						'id': 'overview-map',
						'html': '<area shape="rect" coords="7,90,54,110" href="javascript:void(0);" onclick="window.overview_sub(\'design\');"><area shape="rect" coords="77,90,211,110" href="javascript:void(0);" onclick="window.overview_sub(\'joinery\');"><area shape="rect" coords="230,90,275,110"  href="javascript:void(0);" onclick="window.overview_sub(\'detail\');">'
					});
				
					img.inject($('main'));
					map.inject($('main'));
					
					// what do i do on a new link being clicked?
					onchange = '$("overview").setProperty("src",$("overview").getProperty("src").replace("-on.gif",".gif")); \
					$("overview-text").dispose(); $("overview-map").dispose();';
						  
				}).delay(2100);
			
			}).delay(5000);

		}
	
	} // end overview
	
	// overview sub
	window.overview_sub = function(e) {
	
		$('overview-text').setProperty('src','images/'+e+'-text.gif');
	
	}
	
	// msmith
	window.msmith = function() {
		
		if($('msmith-img') == null) {
	
			runchange();
	
			// turn link white
			$("msmith").setProperty("src",$("msmith").getProperty("src").replace(".gif","-on.gif"));
		
			// what do i do on a new link being clicked?
			onchange += '$("msmith").setProperty("src",$("msmith").getProperty("src").replace("-on.gif",".gif"));';
			
			var img = new Element('img',{
				id: 'msmith-img',
				src: 'images/neven-splash.jpg',
				alt: 'contact',
				styles : {
					'margin-top': '-377px'
				}
			});
			
			img.fade('hide');
			img.inject($('main'));
			img.set('tween',{duration:2000});
			img.tween('opacity',1);
			
			// what do i do on a new link being clicked?
			onchange += '$("msmith-img").dispose();';
			
			(function() {
					  
				img.tween('opacity',0);
				
				(function() {
			
					$("msmith-img").dispose();
				
					var img = new Element('img',{
						id: 'msmith-img2',
						src: 'images/neven-text.gif',
						alt: 'neven maguire',
						usemap: '#neven-map',
						styles : {
							'margin-top': '-377px'
						}
					});
					
					var map = new Element('map',{
						'name': 'neven-map',
						'id': 'neven-map',
						'html': '<area shape="rect" coords="7,94,145,110" href="javascript:void(0);" onclick="window.showgallery(\'NevenMaguire\');" /><area shape="rect" coords="170,94,305,110" href="http://www.macneanrestaurant.com" target="_blank" />'
					});
					
					img.fade('hide');
					img.inject($('main'));
					img.set('tween',{duration:2000});
					img.tween('opacity',1);
					map.inject($('main'));
					
					var details = new Element('img',{
					
						id: 'neven-logo',
						src: 'images/neven-logo.gif'
					
					});
				
					$('mid-left-cont').setProperty('valign','top');
					details.inject($('mid-left'));
					
					onchange = '$("msmith").setProperty("src",$("msmith").getProperty("src").replace("-on.gif",".gif")); \
					$("msmith-img2").dispose(); \
					$("neven-logo").dispose(); \
					$("mid-left-cont").setProperty("valign","bottom");\
					$("neven-map").dispose();';
				
				}).delay(2100);
				
			}.bind(this)).delay(5000);
	
		}
	
	} // end msmith
	
	// gallery
	window.showgallery = function(g) {
	
		runchange();
		
		window.gallerystep = 1;
		window.gallerymax = 0;
		window.clickable = 0;
		
		var h = '';
		
		// gallery html
		switch(g) {
			
			case "Freestanding":
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',4);"><img src="images/4.gif" alt="4" id="gallery_sub_4" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',5);"><img src="images/5.gif" alt="5" id="gallery_sub_5" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',6);"><img src="images/6.gif" alt="6" id="gallery_sub_6" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.clickable = 3;
				window.gallerymax = 6;
			
			break;
			
			case "Nevil":
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',4);"><img src="images/4.gif" alt="4" id="gallery_sub_4" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',5);"><img src="images/5.gif" alt="5" id="gallery_sub_5" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.gallerymax = 5;
			
			break;
			
			case "NevenMaguire":
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',4);"><img src="images/4.gif" alt="4" id="gallery_sub_4" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',5);"><img src="images/5.gif" alt="5" id="gallery_sub_5" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',6);"><img src="images/6.gif" alt="6" id="gallery_sub_6" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.gallerymax = 6;
			
			break;
			
			case "Georgian": 
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',4);"><img src="images/4.gif" alt="4" id="gallery_sub_4" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',5);"><img src="images/5.gif" alt="5" id="gallery_sub_5" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',6);"><img src="images/6.gif" alt="6" id="gallery_sub_6" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.gallerymax = 6;
			
			break;

			case "Peter": 
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',4);"><img src="images/4.gif" alt="4" id="gallery_sub_4" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',5);"><img src="images/5.gif" alt="5" id="gallery_sub_5" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.clickable = 2;
				window.gallerymax = 5;
			
			break;
			
			case "Georgie":
			case "JulieCooper":  
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.gallerymax = 3;
			
			break;
						
			case "Smith": 
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',4);"><img src="images/4.gif" alt="4" id="gallery_sub_4" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.gallerymax = 4;
			
			break;
			
			case "Steen": 
			
				h = '<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep-1);"><img src="images/scrollleft.gif" alt="1" id="gallery_scrollleft" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',1);"><img src="images/1-on.gif" alt="1" id="gallery_sub_1" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',2,true);"><img src="images/2.gif" alt="2" id="gallery_sub_2" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',3);"><img src="images/3.gif" alt="3" id="gallery_sub_3" /></a>\
				<a href="javascript:void(0);" onclick="window.showgallery_sub(\''+g+'\',window.gallerystep+1);"><img src="images/scrollright.gif" alt="1" id="gallery_scrollright" /></a>';
			
				window.clickable = 2;
				window.gallerymax = 3;
			
			break;
			
		}
		
		var bg = new Element('div',{
			id: 'galleryi',
			styles: {
				'margin-top': '-377px',
				'width':'582px',
				'height':'377px',
				'background-position':'top left',
				'background-repeat':'no-repeat',
				'background-image':'url(../images/gallery/'+g+'/1.jpg)'
			},
			html: ''
		
		});
		
		var subs = new Element('p',{
			id: 'numbers',
			styles: {
				'padding':'356px 0px 0px 8px',
				'color': '#fff'
			},
			html: h
		});
		
		subs.inject(bg);
		bg.inject($('main'));
		
		onchange += '$("galleryi").dispose();';
		
		window.showgallery_sub(g,1);
	
	} // end gallery
	
	window.showgallery_sub = function(g,i) {
	
		if((i>=1) && (i<=window.gallerymax)) {
			
			if($('click-to-open')) $('click-to-open').dispose();
	
			$('galleryi').setStyle('background-image','url(../images/gallery/'+g+'/'+i+'.jpg)');
			
			$$('#numbers img').each(function(e) { e.setProperty('src',e.getProperty('src').replace('-on.gif','.gif')); });
			$('gallery_sub_'+i).setProperty('src',$('gallery_sub_'+i).getProperty('src').replace('.gif','-on.gif'));
			
			window.gallerystep = i;
			
			// can we click on the image
			if(i == window.clickable) {
				
				var subs = new Element('span',{
					id: 'click-to-open',
					styles: {
						'padding': '2px 0px 0px 10px',
						'color': '#fff'
					},
					html: '<a href="javascript:void(0);" onclick="$(\'galleryi\').setStyle(\'background-image\',\'url(../images/gallery/'+g+'/'+i+'-click.jpg)\'); $(\'click-close\').setStyle(\'display\',\'inline\'); $(\'click-open\').setStyle(\'display\',\'none\');" id="click-open"><img src="images/click-here-to-open.gif" /></a><a href="javascript:void(0);" onclick="$(\'galleryi\').setStyle(\'background-image\',\'url(../images/gallery/'+g+'/'+i+'.jpg)\'); $(\'click-close\').setStyle(\'display\',\'none\'); $(\'click-open\').setStyle(\'display\',\'inline\');" id="click-close" style="display:none;"><img src="images/click-here-to-close.gif" /></a>'
				});
				
				subs.inject($('numbers'));
				
				var img = new Element('img',{ src: 'images/gallery/'+g+'/'+i+'-click.jpg' } );
				
			}
		
		}
	
	}
	
	var imgCount = 1;
	window.step = 0;
					
	window.slider = new Slider($('scrollbar'),$('scrollnob'), {
		mode: 'horizontal',
		steps: imgCount
	}).set(0);
	
	window.slider.addEvent('onChange',function(step) { 
	
		var scroll = $('gallery_images').getScrollSize();
		new Fx.Scroll($('gallery_images')).set((step/imgCount) * (scroll.x + 300),0);
		window.step = step;
	
	});
	
	$('scroll_left').addEvent('mouseover',function() {
	
		window.myPeriodical = (function(){
			if(window.step <= 0) $clear(window.myPeriodical);
				window.slider.set(window.step--);
		}).periodical(150, window.slider);
	
	});
	$('scroll_left').addEvent('mouseout',function() {
	
		$clear(window.myPeriodical);
	
	});
	
	$('scroll_right').addEvent('mouseover',function() {
	
		window.myPeriodical = (function(){
			if(window.step == window.slider.options.steps) $clear(window.myPeriodical);
				window.slider.set(window.step++);
		}).periodical(150, window.slider);
	
	});
	$('scroll_right').addEvent('mouseout',function() {
	
		$clear(window.myPeriodical);
	
	});


	// flash borders
	$('screen').set('tween',{ duration: 1000 });
	(function() { $('screen').tween('border-left-color','#ffffff'); }).delay(delay);
	(function() { $('screen').tween('border-top-color','#ffffff'); }).delay(delay+1000);
	(function() { $('screen').tween('border-right-color','#ffffff'); }).delay(delay+2000);
	(function() { $('screen').tween('border-bottom-color','#ffffff'); }).delay(delay+3000);
	
	// fade in background motif
	(function() { $('motif').fade(1); }).delay(delay+5000);
	
	// fade in logo
	(function() { $('logo').fade(1); }).delay(delay+7000);
	
	// fade in dividing line
	(function() { $('main').set('tween',{ duration: 1000 }); $('main').tween('border-left-color','#ffffff'); }).delay(delay+8000);
	
	// fade in text
	(function() { $$('#main img').each(function(el) { el.fade(1) }); }).delay(delay+9000);
		
	// show home stuff
	window.gohome.delay(delay+10000);
	
	// fade in links
	(function() { $('links').fade(1); }).delay(delay+12000);
	
	// fade in gallery nav line
	(function() { $('gallery').set('morph',{ duration: 1000 }); $('gallery').morph({'border-left-color':'#ffffff','border-right-color':'#ffffff'}); }).delay(delay+13000);
	
	(function() { $('scrollarea').fade(1); $('gallery_images').fade(1); }).delay(delay+13400);
	
	var initial = 0;
	
	// fade in gallery images
	(function() { $$('#gallery_images img').each(function(el) { (function() { el.fade(1); }.bind(this)).delay(initial); initial += 200; }); }.bind(this)).delay(delay+14000);

	$$('#gallery_images img').each(function(i) { 
		i.addEvent('mouseover',function() { i.setProperty('src',i.getProperty('src').replace('.jpg','-colour.jpg')); }.bind(this)); 
		i.addEvent('mouseout',function() { i.setProperty('src',i.getProperty('src').replace('-colour.jpg','.jpg')); }.bind(this));
		var img = new Element('img',{ src: i.getProperty('src').replace('.jpg','-colour.jpg') } );
	}.bind(this)); 
		
});