/* init globals */
var banner;
var scrollFx;
var top_height;

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

	/* delegate globals */
	
	banner = $('static_right');
	
	/* Fix top placement of static right banner */
	top_height = $('rightWing').getFirst('div.bannerC').getSize().y + 10;
	$('static_right').setStyle('top',top_height+'px');

	/* init FX class */
	scrollFx = new Fx.Morph(banner,{
		duration: 250,
		link: 'cancel'
	});
	
	/* Fix topwing height */
	var topWingC = $('topWing').getFirst('div.bannerC');
	topWingC.setStyle('height',(topWingC.getSize().y < 150 ? '0px':'150px'));
	
});

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

	/*
		Check to maintain a visible static banner 
	*/

		if(banner !== undefined)
		{
			var winScroll = window.getScroll();
			var diff = winScroll.y - top_height;

			var new_y = diff+top_height;
	 		if(new_y>top_height)
	 		{
				scrollFx.start({
	 				'top' : new_y+'px'
	 			});
	 		}
	 		else
	 		{
				scrollFx.start({
			 		'top' : top_height+'px'
				});
	 		}
		}

});
