/*
 * 	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.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
/*
 *	markup example for $("#images").easySlider();
 *	
 * 	<div id="images">
 *		<ul>
 *			<li><img src="images/01.jpg" alt="" /></li>
 *			<li><img src="images/02.jpg" alt="" /></li>
 *			<li><img src="images/03.jpg" alt="" /></li>
 *			<li><img src="images/04.jpg" alt="" /></li>
 *			<li><img src="images/05.jpg" alt="" /></li>
 *		</ul>
 *	</div>
 *
 */

(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			speed: 			800			
		}; 
		
		var options = $.extend(defaults, options);  
		
		return this.each(function() {  
			obj = $(this); 				
			var s = $("img", obj).length;
			var w = obj.width();
			var h = 41; 
			var ts = s + 1;
			var t = 0;
			var pval = '+'
			var imgwidth = $("img", obj).width();			
			$("#nextBtn").click(function(){	
				animate("next");

			});
			$("#prevBtn").click(function(){	
				animate("prev");	
			});	
			function animate(dir){
				if(dir == "next"){
					t = (t>=ts) ? ts : t+1;
					pval ='-';
				} else {
					t = (t<=0) ? 0 : t-1;
					pval='+';
				};								
				
					p = (t*(w+10)*-1);		
					$("img",obj).animate(
						{ left: p}, 
						options.speed
					);				

			};
		});
	  
	};

})(jQuery);
