(function($){  
	$.fn.horizontalSlider = function() {
		return this.each(function() {
			var obj = $(this);
			var windowDiv = $('div.window', obj);
			var ol = $('ol', obj);
			var lis = $('li', ol);	
			var width = 0;
			
			lis.each(function() {
				width += $(this).outerWidth();
			});
			ol.width(width);

			$('a.arrow.right', obj).click(function() {
				lis.each(function() {
					var left = $(this).offset().left - ol.offset().left;
					if(left + $(this).outerWidth() > windowDiv.scrollLeft() + windowDiv.width()) {
						windowDiv.animate({ scrollLeft: left }, 300);
						return false;
					}
				});
				return false;
			});
			$('a.arrow.left', obj).click(function() {
				lis.each(function() {
					var left = $(this).offset().left - ol.offset().left;
					if(left >= windowDiv.scrollLeft()) {
						windowDiv.animate({ scrollLeft: left - windowDiv.width() }, 300);
						return false;
					}
				});
				return false;
			});
		});
	}
})(jQuery);
