/**
 * @author Paul Chan / KF Software House 
 * http://www.kfsoft.info
 *
 * Version 0.5
 * Copyright (c) 2010 KF Software House
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
	
(function($) {

    var _options = null;

	jQuery.fn.MyGoogleStyleFloatingMenu = function(options) {
		_options = $.extend({}, $.fn.MyGoogleStyleFloatingMenu.defaults, options);
		
		return this.each(function()
		{
			var floatingMenu = $(this);
			var fm_top = $(floatingMenu).parent().offset().top + "";
			fm_top = fm_top.replace(/px/, "");

			$(floatingMenu).attr("org_fm_top", fm_top);
			
			$(window).scroll(function(){
				var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;

				if (scrollTop >=fm_top)
				{
					$(floatingMenu).css("position", "fixed");
					$(floatingMenu).css("top", "0px");
					
					window.status = scrollTop + " => " + $(floatingMenu).offset().top;
				}
				else if (scrollTop <=fm_top)
				{
					$(floatingMenu).css("position", "static");
					$(floatingMenu).css("top", fm_top+"px");
				}
			});
		});
	}
	
	//default values
	jQuery.fn.MyGoogleStyleFloatingMenu.defaults = {
	};
})(jQuery);
