
	
	//avoid conflict with other script
    $j=jQuery.noConflict();

    $j(document).ready(function($) {

	//this is the floating content
	var $floatingbox = $('#floating-box');
	
	if($('#scroll').length > 0){
	
		var bodyY = parseInt($('#scroll').offset().top) - 20;
		var originalX = $floatingbox.css('margin-left');
	
		$(window).scroll(function () { 
		  
			var scrollY = $(window).scrollTop();
			var isfixed = $floatingbox.css('position') == 'fixed';
			
			if($floatingbox.length > 0){							
	
				if ( scrollY > bodyY && !isfixed ) {
					$floatingbox.stop().css({
						position: 'fixed',
						left: '50%',
						top: 0,
						marginLeft: -560
	
					});
				} else if ( scrollY < bodyY && isfixed ) {
					$floatingbox.css({
						position: 'relative',
						left: 0,
						top: 0,
						marginLeft: originalX
					});
				}
				
			}
	
		});
	}
});

