(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		'<',
			nextId: 		'nextBtn',	
			nextText: 		'>',
			orientation:	'', //  'vertical' is optional;
			speed: 			800			
		}; 
		
		var options = $.extend(defaults, options);  
		var timer = setInterval(auto,4000);
		function play(){ timer;};
		function auto(){
				$("a","#"+options.nextId).trigger("click")
			};
		function reset(){ clearTimeout(timer);timer = setInterval(auto,4000);};
		play();
		return this.each(function() {  
			obj = $(this); 				
			var s = $("li", obj).length;
			var w = obj.width(); 
			var h = obj.height(); 
			var ts = s-1;
			var t = 0;
			var vertical = (options.orientation == 'vertical');
			$("ul", obj).css('width',s*w);			
			if(!vertical) $("li", obj).css('float','left');
				
			$("a","#"+options.prevId).css("color","#006f6a");
			$("a","#"+options.nextId).css("color","#006f6a");
			$("#s1").css("color","#006f6a");	
			$("a","#"+options.nextId).click(function(){		
				animate("next");reset();play();
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev");reset();play();
			});	
			function animate(dir){
				if(dir == "next"){
					t = (t>=ts) ? 0 : t+1;	
					n = t +1;
				} else {
					t = (t<=0) ? ts : t-1;
					n = t +1;
				};								
				if(!vertical) {
					p = (t*w*-1);
					$("#imgslide",obj).animate(
						{ marginLeft: p }, 
						options.speed
					);$("div.tmpSlideshowControl").css("color","white");$("#s"+n).css("color","#006f6a");				
				} else {
					p = (t*h*-1);
					$("#imgslide",obj).animate(
						{ marginTop: p }, 
						options.speed
					);$("div.tmpSlideshowControl").css("color","white");$("#s"+n).css("color","#006f6a");					
				}
			};
		});
	  
	};

})(jQuery);
