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