(function($){
		$.fn.filmstrip = function(options){
			var defaults = {
				prevId: 		'prevBtn',
				nextId: 		'nextBtn',
				orientation:	'horizontal',
				speed: 			800,
				easing:			'swing',
				visableSlides:	3		
			}; 
			var options = $.extend(defaults, options); 
			return this.each(function() { 
				var obj = $(this);
				//calc number of slides
				var s = $("li", obj).length;
				if(options.orientation == "vertical"){		
					//calc height of container: 'slide height' x 'number slides visable'
					var h = $("li", obj).height() * options.visableSlides;
					//set container height
					$(obj).height(h);
					//slide width
					var w = $("li", obj).width();
					//set container height
					$(obj).width(w);
				}
				else{
					var h = $("li", obj).height();//slide height
					$(obj).height(h);//set container height
					var w = $("li", obj).width() * options.visableSlides;//calc width of container
					$(obj).width(w);//set container height
					$("li", obj).css('float','left');//float elements
					$("ul", obj).css('width',s*w);//set ul width
				}
				var np = (s/options.visableSlides);//calc number of pages	
     			if(s % options.visableSlides >= 1){
					np = parseInt(np) + 1;
				}
				var ts = np-1;//calc last page
				var t = 0;//initialize page counter
				var cont = true;//initialize variable used in slide callback to prevent user from going ape on next/prev buttons, will not slide until previous slide is finished.
				if(t<=0){
					$('#'+options.nextId).addClass('enabled');//initialize nextBtn
					$('#'+options.prevId).addClass('disabled');//initialize prevBtn
				}
				$('#'+options.nextId).click(function(){
					if(cont === true){
						slide('next',options.orientation);
					}
					if (t>=ts) {
						$(this).removeClass('enabled');
						$(this).addClass('disabled');
					}
						$('#'+options.prevId).addClass('enabled');
						$('#'+options.prevId).removeClass('disabled');
				});
				$('#'+options.prevId).click(function(){
					if(cont === true){
						slide('prev',options.orientation);
					}
					if (t<=0) {
						$(this).removeClass('enabled');
						$(this).addClass('disabled');
					}
						$('#'+options.nextId).addClass('enabled');
						$('#'+options.nextId).removeClass('disabled');
				});
				function slide(direction,orientation){
					cont = false;
					if(direction == "next"){
						t = (t>=ts) ? ts : t+1;
						
					} else {
						t = (t<=0) ? 0 : t-1;
					}
					if(orientation == "vertical") {
						var p = (t*h*-1);
						$("ul",obj).animate({ marginTop: p },options.speed,options.easing,function(){cont = true;});		
					} 
					else {
						var p = (t*w*-1);
						$("ul",obj).animate({ marginLeft: p },options.speed,options.easing,function(){cont = true;});	
					}	
				};
			});
		};
	})(jQuery);


