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

	//var myImages = Asset.images('/slide2/01.jpg', '/slide2/02.jpg', '/slide2/03.jpg', '/slide2/04.jpg', '/slide2/05.jpg', '/slide2/06.jpg', '/slide2/07.jpg');
	
	// Define photos
	var thumbList = [{"item": "1", "title": "Aerial View"}
						, {"item": "2", "title": "John's Island Rainbow"}
						, {"item": "3", "title": "Wabi Canoes"}
						, {"item": "4", "title": "Lolly Gag Lookout"}
						, {"item": "5", "title": "Sunrise"}
						, {"item": "6", "title": "Sunrise"}
						, {"item": "7", "title": "Burning W"}];
						
		
	// Load initial photo
	new Element('img').set({'src': '/img/slide2/01.jpg'
							, 'alt': '1'
							, 'id': 'headerPhoto'}).setStyle('z-index', '0')
		.inject($('brandingPhoto'), 'bottom');
	
	
	// Rotator
	
	var slideshow = function rotator() {
		var thisPic = $('headerPhoto').get('alt');
		change_photo(thisPic);
	};
	
	slideshow.periodical(10000);
	
	// main photo slow transition
	
	
	
	// Change Photo Slow
	function change_photo(curphoto) {
		
		var photo = parseInt(curphoto) + 1;
		parseInt(photo);
		if(photo > 7) {
			photo = 1;
		}
		
		var thisImg = Asset.image('/img/slide2/0'+photo+'.jpg', {
						onLoad: function() {
						
							
							var BPhide = new Fx.Tween($('brandingPhoto'), {
								'duration': '1600',
								onComplete: function() {
								$('headerPhoto').setStyles({'opacity': 0,'z-index': '0'});
								$('headerPhoto').set({'alt': photo, 'src': '/img/slide2/0'+photo+'.jpg'});								
									
								var BPtween = new Fx.Tween($('brandingPhoto'), {
									'duration': '1600'
								});
								BPtween.start('opacity', 0, 1);
									$('brandingPhoto').set('opacity', 1);
									$('headerPhoto').tween('opacity', 1);								
								}
							});
							BPhide.start('opacity', 1, 0);
						
						}
					});
		
						
						
	
		
	};
	
	
});
