(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			ulId	:		'',
			orientation:	'', //  'vertical' is optional;
			speed: 			800			
		}; 
		
		var options = $.extend(defaults, options);  
		
		return this.each(function() {  
			obj = $(this); 				
			var s = $("li", obj).length; //li 길이
			var w = obj.width(); 
			var h = obj.height(); 
			var ts = s-1;
			var t = 0;
			var vertical = (options.orientation == 'vertical');
//			$("#"+options.ulId).css('width',s*w);			
			if(!vertical) $("li", obj).css('float','left');
			
			$("#"+options.prevId).fadeTo('nomal', 0.2);
			$("#"+options.nextId).fadeTo('nomal', 1);
			$("#"+options.nextId).click(function(){		
				//alert('click = ' + options.nextId);
				animate("next");
				if (t>=ts) $(this).fadeTo('nomal', 0.2);
				$("#"+options.prevId).fadeTo('nomal', 1);
			});
			$("#"+options.prevId).click(function(){		
				//alert('click' + options.prevId);
				animate("prev");
				if (t<=0) $(this).fadeTo('nomal', 0.2);
				$("#"+options.nextId).fadeTo('nomal', 1);
			});	
			function animate(dir){
				if(dir == "next"){
					t = (t>=ts) ? ts : t+1;
				} else {
					t = (t<=0) ? 0 : t-1;
				};
				if(!vertical) {
					p = (t*w*-1);
					$("#"+options.ulId).animate(
						{ marginLeft: p }, 
						options.speed
					);				
				} else {
					p = (t*h*-1);
					$("#"+options.ulId).animate(
						{ marginTop: p }, 
						options.speed
					);					
				}
			};
			if(s>1) $("#"+options.nextId).fadeTo('nomal', 1);
		});
	  
	};

})(jQuery);