(function($)
{
	$.fn.extend(
	{ 
		//plugin name - imageScroll
		imageScroll: function( options )
		{

			//Settings list and the default values
			var defaults = 
			{
				width: 250,
				height: 250,
				duration: 1000,
				easing: 'linear' // http://jqueryui.com/demos/effect/#easing
			};
			
			var options = $.extend( defaults, options );
		
    		return this.each( function()
			{
				var object = $(this);				
				
				var imgWidth = object.width();
				var imgHeight = object.height();
				
				object.css( 'position', 'relative' );
				
				object.wrap( '<div style="width:' + options.width + 'px; height:' + options.height + 'px; display:block; overflow:hidden;" />' );
				
				if ( (imgWidth / imgHeight) > (options.width / options.height) )
				{
					object.css( 'height', options.height );
					
					$(this).mouseenter(
						function()
						{
							var w = $(this).width();
							
							if ( w > options.width )
							{
								$(this).clearQueue();
								$(this).animate({ 
									left: "-" + ( w - options.width ) + "px"
								}, options.duration, options.easing);
							}
						}
					);
					
					$(this).mouseleave(
						function()
						{
							var w = $(this).width();
							
							if ( w > options.width )
							{
								$(this).animate({ 
									left: "0px"
								}, options.duration, options.easing);
							}
						}
					);
				}
				else
				{					
					object.css( 'width', options.width );
				
					$(this).mouseenter(
						function()
						{
							var h = $(this).height();
							
							if ( h > options.height )
							{
								$(this).clearQueue();
								$(this).animate({ 
									top: "-" + ( h - options.height ) + "px"
								}, options.duration, options.easing);
							}
						}
					);
					
					$(this).mouseleave(
						function()
						{
							var h = $(this).height();
							
							if ( h > options.height )
							{
								$(this).animate({ 
									top: "0px"
								}, options.duration, options.easing);
							}
						}
					);
				}

				
    		});
    	}
	});
})(jQuery);



