$.fn.scrollImages = function(options) {
	
	var defaults = {
		direction: "right",
		imageWidth: 106,
		duration: 200,
		size: 7,
		container: "thumbnails_container"
	};
		
	var o = jQuery.extend(defaults, options);	
	var el = $("#" + o.container);		
	var pos = Math.round(el.position().left);
	var scrollLeft = -pos/o.imageWidth;
	var scrollRight = o.size + scrollLeft + 1;
	
	var active = el.find(".active");
	if(o.direction == "right") {
		if (active.is(":first-child")) {
	 		pos = 0;	
	 	} else if (active.is(":nth-child(" + scrollRight + ")")) {	 		 
	 		pos -= o.imageWidth;
	 	}
	} else {
		if (active.is(":last-child")) {
			pos = (el.parent().width() - el.width());	
		} else if (active.is(":nth-child(" + scrollLeft + ")")) {
			pos += o.imageWidth;
		}
	}
	el.stop().animate({ left:pos + "px" }, o.duration, "linear");
};

