

(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			nextId: 		'nextBtn',
			speed: 			400		
		}; 
		
		var options = $.extend(defaults, options);  
		
		return this.each(function() {  
			obj = $(this);
			var s = $("#slide", obj).length;
			var ts = s;
			var t = 1;
			var w = $("#slide").width();
			
			$(".t1").css('float', 'left');
			$(".t2").css('float', 'left');
			$(".t3").css('float', 'left');
			$(".t2").css('width', 0);
			$(".t3").css('width', 0);
			$(".p2").hide();
			$(".p3").hide();
			$(obj).before('<div class="slider_nav"><div id="'+ options.nextId +'"><a href=\"javascript:void(0);\"><img src="skins/vertu/img/strelka-bg.png" /></a></div><div id="'+ options.prevId +'"><a href=\"javascript:void(0);\"><img src="skins/vertu/img/strelka-bg.png" /></a></div></div>');
			$("a","#"+options.prevId).hide();
			$("a","#"+options.nextId).hide();
			$("a","#"+options.nextId).click(function(){		
				animate("next");
				if (t>=ts) $(this).fadeOut();
				$("a","#"+options.prevId).fadeIn();
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev");
				if (t<=1) $(this).fadeOut();
				$("a","#"+options.nextId).fadeIn();
			});	
			function animate(dir){
				
				if(dir == "next"){
					
					$(".t"+t).fadeOut("slow");
					
					t = t+1;
					
					var wbody = $("body").width();
					$(".t"+t).animate({ width: wbody-50 }, options.speed);
					$(".p"+t).fadeIn();
					
				} else {
					
					$(".t"+t).animate({ width: 0 }, options.speed);
					$(".p"+t).fadeOut();
					t = t-1;
					
					//$(".t"+t).animate({ width: w }, options.speed);
					$(".t"+t).fadeIn("slow");
					$(".p"+t).fadeIn();
					
					
				};	
				
			};
			if(s>1) $("a","#"+options.nextId).fadeIn();	
		});
	  
	};

})(jQuery);
