/*
 *  JavaScript for the Kirkpatrick Bank Homepage
 *  by Brandon McKinney / Staplegun
 *  created 08 27 2008
 *
 *  Provides functions specific to the homepage
 */

window.addEvent('domready', function(){
	window.addEvent('load', function(){
		// Set a 3 second delay for the promo to appear
		setTimeout(function(){
			// Control placement of the promo on the homepage
			var wrapperSize = $('wrapper').getSize();
			var promoSize = $('promoDiv').getScrollSize();
			var promoLeft = wrapperSize.x-promoSize.x + 'px';
			$('promoDiv').setStyle('marginLeft', promoLeft);
	
			// Get the total size of the promo area
			var promoScrollSize = $('promoImg').getScrollSize();
	
			// Set up the Fx.Morph for the promo
			var promoFx = new Fx.Morph('promoDiv', {
				duration: 2000,
				transition: Fx.Transitions.Quart.easeOut
			});
	
			// Position the 'X' in the promo
			var promoXSize = $('promoX').getScrollSize();
			$('promoX').setStyles({
				'marginTop' : promoScrollSize.y-promoXSize.y,
				'marginLeft' : promoScrollSize.x-promoXSize.x
			});
	
			// Show the promo
			promoFx.start({
				'height' : promoScrollSize.y
			});
	
			// Set an handler for promoX.click
			$('promoX').addEvent('click', function(){
				promoFx.start({
					'height' : 0
				});
			});
		}, 2000);
	});
});
