/*!
 * Contained Sticky Scroll v1.1
 * http://blog.echoenduring.com/2010/11/15/freebie-contained-sticky-scroll-jquery-plugin/
 *
 * Copyright 2010, Matt Ward
*/
(function( $ ){

  $.fn.containedStickyScroll = function( options ) {
  
	var defaults = {  
		easing: 'linear',
		duration: 500,
		queue: false
	}  
                  
	var options =  $.extend(defaults, options);
    var $getObject = $(this).selector;
    
jQuery(window).scroll(function() {
    	if(jQuery(window).scrollTop() > 559){
	        if(jQuery(window).scrollTop() > (jQuery($getObject).parent().offset().top)){
	        	jQuery($getObject).animate({ top: (jQuery(window).scrollTop() - jQuery($getObject).parent().offset().top)+80 + "px" }, 
	            { queue: options.queue, easing: options.easing, duration: options.duration });
	        }
	        else if(jQuery(window).scrollTop() < (jQuery($getObject).parent().offset().top)){
	        	jQuery($getObject).animate({ top: "445px" },
	            { queue: options.queue, easing: options.easing, duration: options.duration });
	        }
	} else jQuery($getObject).animate({ top: "559px" },{ queue: options.queue, easing: options.easing, duration: options.duration });
       //	if(jQuery(window).scrollTop()==0)jQuery($getObject).animate({ top: "180px" },{ queue: options.queue, easing: options.easing, duration: options.duration });
});

 }
})( jQuery );

