$.fn.to_static = function() {

	return this.each(function(index,dom) {
			
			offtop = $(dom).position().top;
			offleft = $(dom).position().left;
			
			scrolled = $(window).scrollTop();
			
			$(window).bind('scroll', function(e){
				
				scrolled = $(window).scrollTop();
				
				if (scrolled > offtop) {
					$(dom).css({'position' : 'fixed', 'left' : offleft, 'top' : '0'});
				}
				
				if (scrolled < offtop) {
					$(dom).css({'position' : 'static'});
				}
			});
			
	});
}
