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

window.addEvent('domready', function(){
	
	/* delegate globals */
	
	banner = $('static_right');
	
	/* Fix top placement of static right banner */
	top = $('rightWing').getFirst('div.bannerC').getSize().y + 10;
	$('static_right').setStyle('top',top+'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;

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

});
