/* MooTools Scripts for Web Design Hero Frontpage */

function titleBounce(parentDiv, topClass, bottomClass){

	var top = $(parentDiv).getElement(topClass);
	var bottom = $(parentDiv).getElement(bottomClass);
	
	var topBounce = new Fx.Style($(top),
	'margin-left', {duration: 300})
	.addEvent('onComplete', function() {
		var expandDiv = new Fx.Style($(top),
		'margin-left', {duration: 200});
		expandDiv.start(0);
		});
	topBounce.start(40);
	
	var bottomBounce = new Fx.Style($(bottom),
	'margin-left', {duration: 400})
	.addEvent('onComplete', function() {
		var expandDiv = new Fx.Style($(bottom),
		'margin-left', {duration: 250});
		expandDiv.start(0);
		});
	bottomBounce.start(20);
	
}


function titleCrossFade(parentDiv, fadeMeOut, fadeMeIn){

	var fadeMeOut = $(parentDiv).getElement(fadeMeOut);
	var fadeMeIn = $(parentDiv).getElement(fadeMeIn);


	if($(fadeMeOut).fx){$(fadeMeOut).fx.stop();}
	if($(fadeMeIn).fx){$(fadeMeIn).fx.stop();}
	$(fadeMeOut).fx = $(fadeMeOut).effect('opacity', {duration: 1000}).start(0);
	$(fadeMeIn).fx = $(fadeMeIn).effect('opacity', {duration: 1000}).start(1);
	
}

function titleWrapperEnter(parentDiv){
	titleCrossFade(parentDiv, '.topicTitlePictureColor', '.topicTitlePictureBW');
	titleBounce(parentDiv, '.topicTitleTop', '.topicTitleBottom');
}

function titleWrapperLeave(parentDiv){
	titleCrossFade(parentDiv, '.topicTitlePictureBW', '.topicTitlePictureColor');
}




function headerBounceEffect() {
	
	var x = new Chain();

	var one = function(){
		if($('eeWeb').fx){$('eeWeb').fx.stop();}
		var growDiv = new Fx.Style($('eeWeb'),
		'left', {duration: 200})
		.addEvent('onComplete', function() {
			var dd= new Fx.Style($('eeWeb'),
			'left', {duration: 100});
			dd.start(0);
		});
		growDiv.start(35);
	};
	
	var two = function(){
		if($('eeHero').fx){$('eeHero').fx.stop();}
		var herog = new Fx.Style($('eeHero'),
		'margin-left', {duration: 200})
		.addEvent('onComplete', function() {
			var herob= new Fx.Style($('eeHero'),
			'margin-left', {duration: 100});
			herob.start(0);
		});
		herog.start(-33);
	};

	x.chain(one);x.chain(one);x.chain(two);x.chain(two);
	x.callChain();x.callChain.delay(400, x);
	x.callChain.delay(1000, x);x.callChain.delay(1400, x);
	
}




function navImgSwap(img, dir, name){
	var img = $(img);
	
	if(dir.toString() == "in"){
		img.src =  'base/images/menu/menu_'+name+'_over.gif';
	}else{
		img.src =  'base/images/menu/menu_'+name+'.gif';
	}
}




window.addEvent('domready', function(){

	var x = new Chain();
	var one = function(){
		var herog = new Fx.Style($('selectorCenterHeader'),'opacity', {duration: 200});
		herog.start(1);
	};
	var two = function(){ headerBounceEffect(); };
	two.periodical(13000);
	
	
	x.chain(one); x.chain(two); //x.chain(two);
	x.callChain(); 	x.callChain.delay(2200, x); //x.callChain.delay(10200, x);
	
	
	//preload nav images
	var nav1 = new Asset.images('base/images/menu/menu_about_over.gif');
	var nav2 = new Asset.images('base/images/menu/menu_contact_over.gif');
	var nav3 = new Asset.images('base/images/menu/menu_home_over.gif');
	var nav4 = new Asset.images('base/images/menu/menu_portfolio_over.gif');
	var nav5 = new Asset.images('base/images/menu/menu_services_over.gif');

	
	
	
});




