/*
 * 	Easy Slider - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/3783/jquery-plugin-easy-image-or-content-slider
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 */

(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			orientation:	'', //  'vertical' is optional;
			speed: 			800			
		}; 
		
		var options = $.extend(defaults, options);  
		
		return this.each(function() {
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("ul", obj).width();
            var st=s-1;
			var h = obj.height(); 
			var t = 0;
			$("ul", obj).css('width',s*w);			
			$("li", obj).css('float','left');	
			$("#"+options.nextId).click(function(){
				animate("next");
                return false;
			});
			$("#"+options.prevId).click(function(){	
				animate("prev");
                return false;
			});	
			function animate(dir){
                if(dir == "next"){
					t = (t>=st) ? 0 : t+1;	
				} else {
					t = (t<=0) ? st : t-1;
				};
                p = -(t*w);
                $("ul",obj).animate(
                    { marginLeft: p }, 
                    options.speed
                    );
                };
		});
	  
	};

})(jQuery);
