window.addEvent('domready', function(){
	
	new Fx.Elements($('body'), {
	    duration: 7000,
		transition: Fx.Transitions.Quint.easeOut
	}).start({
	    '0': {
			'background-color': ['#00aae1', '#ffffff']
	    }
	});
	
	new Fx.Elements($('slogan'), {
	    duration: 2222,
		transition: Fx.Transitions.Quint.easeOut,
		onComplete: function() {
			$('html').style.overflow = "auto";			
		}
	}).start({
	    '0': {
			'font-size': [333, 16],
			'color': ["#012345", "#456789"]
	    }
	});

	$('showcase').style.left = "0px";
	$('knob').style.left = "0px";
	
	$$('#showcase li').each(function(button, index){
		button.addEvent('click', function() {	
			new Fx.Elements($('showcase'), {
			    duration: 222,
				transition: Fx.Transitions.Sine.easeIn,
				onComplete: function() {
					slidernav.set(((parseInt($('showcase').style.left) * -1)  /  ($('showcase').clientWidth - $('content').clientWidth)) * 100);
				}
			}).start({
			    '0': {
					'left': [parseInt($('showcase').style.left), ((($('showcase').clientWidth / $$('#showcase li').length) * (index)) * -1) + (($('showcase').clientWidth / $$('#showcase li').length) / 2 )]
			    }
			});
			
			new Fx.Elements(button, {
			    duration: 1000,
				transition: Fx.Transitions.Bounce.easeOut,
				onStart: function() {
					setTimeout("SqueezeBox.fromElement($$('.boxed')[" + index + "],{ parse: 'rel'});",800);
				}
			}).start({
			    '0': {
					'margin-top': [-42, 0]
			    }
			});
		});
		
		if ($$('#showcase li').getLast() == button) { 
			$('showcase').set('styles', {'width': (button.clientWidth * (index + 1))});

			new Fx.Elements($('showcase'), {
			    duration: 4000,
				transition: Fx.Transitions.Quint.easeInOut
			}).start({
			    '0': {
					'left': [(($('showcase').clientWidth - $('content').clientWidth) * -1), 0]
			    }
			});
			
			new Fx.Elements($('knob'), {
			    duration: 4000,
				transition: Fx.Transitions.Quint.easeInOut
			}).start({
			    '0': {
					'margin-left': [($('content').clientWidth - $('knob').clientWidth), 0]
			    }
			});
		}
	});

	var slidernav = new Slider($('scrollbar'), $('scrollbar').getElement('.knob'), {
		snap: true,
		wheel: true,
		onChange: function(value){
			$('showcase').setStyle('left', (($('showcase').clientWidth - $('content').clientWidth) * ((value) / 100) * -1));
		}
	}).set(0);

	var sections = new Accordion('.sectionheader', '.sectionbody', {
		opacity: true,
		display: 0,
		duration: 666
	}, $('content'));

	$('more').addEvent('mouseenter', function() {
		$('more').addClass('hidden');
		$('menu').removeClass('hidden');
		new Fx.Elements($('menu'), {
	    	duration: 333,
			transition: Fx.Transitions.Sine.easeIn
			}).start({
	    		'0': {
					'opacity': [0,1]
	    		}
		});
	});
		
	$$('#menu li').each(function(button, index){
		button.addEvent('click', function() {
			sections.display(index);
		});

		button.addEvent('mouseenter', function() {
				button.set('styles', {
					'background-color': '#89ABCD',
					'color': '#123456'
				});
		});

		button.addEvent('mouseleave', function() {
				button.set('styles', {
					'background-color': '#123456',
					'color': '#456789'	
				});
		});
	});
	
	$('closeshowcasewindow').addEvent('click', function() {
		closeShowcase();
	});
	
    SqueezeBox.initialize({
		handler:'iframe'
    });
 

	SqueezeBox.assign($$('a.boxed'), {
		parse: 'rel'
	});
});

function closeShowcase() {
	new Fx.Elements($('showcasewindow'), {
    	duration: 333,
		transition: Fx.Transitions.Sine.easeIn
		}).start({
    		'0': {
				'opacity': [1,0],
				'visibility': ["visible","hidden"]
    		}
	});
}

function move(value) {
	alert('here'+value);
}