﻿

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



	var x = new Chain();
	var one = function(){
	var fade = new Fx.Style('splash_content_ns', 'opacity', {duration: 200, transition: Fx.Transitions.Sine.easeOut }).start(0,1);
	};
	var two = function(){
	var fadetwo = new Fx.Style('splash_content_basics', 'opacity', {duration: 200, transition: Fx.Transitions.Sine.easeOut }).start(0,1);
	};
	var three = function(){ 
	var fadethree = new Fx.Style('splash_content_fashion', 'opacity', {duration: 200, transition: Fx.Transitions.Sine.easeOut }).start(0,1);
	};
	var four = function() { 
	var fadefour = new Fx.Style('splash_content_kids', 'opacity', {duration: 200, transition: Fx.Transitions.Sine.easeOut }).start(0,1);
	};
	var five = function() { 
	var fadefour = new Fx.Style('splash_content', 'opacity', {duration: 200, transition: Fx.Transitions.Sine.easeOut }).start(0,1);
	};
	x.chain(five);
	x.chain(one);
	x.chain(three);
	x.chain(two);
	x.chain(four);

x.callChain.delay(200, x);
x.callChain.delay(400, x);
x.callChain.delay(600, x);
x.callChain.delay(800, x);
x.callChain.delay(1000, x);




//the slide-ins for the splash page


//the slide-ins for the splash page
	var oFXIn; 
	var oFXOut;
	
	$('splash_content_ns').addEvents({
		'mouseenter': function(){
			if($type(oFXIn) == 'object') oFXIn.cancel();
			resetTeasers(this.getFirst());
			oFXIn = new Fx.Style( 'teaser_pop_ns', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Quad.easeOut }).start(375,275);
		},
		'mouseleave': function(){
			if($type(oFXOut) == 'object') oFXOut.cancel();
			oFXOut = new Fx.Style('teaser_pop_ns', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Sine.easeOut }).start(275,375);
		}
	});

	$('splash_content_basics').addEvents({
		'mouseenter': function(){
			if($type(oFXIn) == 'object') oFXIn.cancel();
			resetTeasers(this.getFirst());
			oFXIn = new Fx.Style( 'teaser_pop_basics', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Quad.easeOut }).start(-100,0);
		},
		'mouseleave': function(){
			if($type(oFXOut) == 'object') oFXOut.cancel();
			oFXOut = new Fx.Style('teaser_pop_basics', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Sine.easeOut }).start(0,-100);
		}
	});
	
	$('splash_content_fashion').addEvents({
		'mouseenter': function(){
			if($type(oFXIn) == 'object') oFXIn.cancel();
			resetTeasers(this.getFirst());
			oFXIn = new Fx.Style( 'teaser_pop_fashion', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Quad.easeOut }).start(375,275);
		},
		'mouseleave': function(){
			if($type(oFXOut) == 'object') oFXOut.cancel();
			oFXOut = new Fx.Style('teaser_pop_fashion', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Sine.easeOut }).start(275,375);
		}
	});

	$('splash_content_kids').addEvents({
		'mouseenter': function(){
			if($type(oFXIn) == 'object') oFXIn.cancel();
			resetTeasers(this.getFirst());
			oFXIn = new Fx.Style( 'teaser_pop_kids', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Quad.easeOut }).start(-100,0);
		},
		'mouseleave': function(){
			if($type(oFXOut) == 'object') oFXOut.cancel();
			oFXOut = new Fx.Style('teaser_pop_kids', 'margin-top', {wait: true, duration: 300, transition: Fx.Transitions.Sine.easeOut }).start(0,-100);
		}
	});	

	// Try and improve the 'twitch-i-ness!' : ) 
	var resetTeasers = function(oElement){
		var aElements = new Array(
			$('teaser_pop_ns'),
			$('teaser_pop_basics'),
			$('teaser_pop_fashion'),
			$('teaser_pop_kids')
		);
		aElements.each(function(oTeaser, iIndex){
		   if(oTeaser.getProperty('id') != oElement.getProperty('id')){
			   // Hide
			   switch(oTeaser.getProperty('id')){
					case 'teaser_pop_ns':
						oTeaser.setStyle('margin-top',375);
					break;
					case 'teaser_pop_basics':
						oTeaser.setStyle('margin-top',-100);
					break;
					case 'teaser_pop_fashion':
						oTeaser.setStyle('margin-top',375);
					break;
					case 'teaser_pop_kids':
						oTeaser.setStyle('margin-top',-100);
					break;
			   }
		   }
		});
	}
	





 

});

