(function($){  
	$.fn.slide = function(options){
		var defaults = {  
			Width: 500,
			Height: 500,
			Speed: 1500,
			NextClass: "Next",
			PrevClass: "Prev",
			Direction: "vertical",
			Offset: 1,
			Restart: true,
			RestartSpeed: options.Speed * 4,
			/*Wobble: false, */ /* this was removed, because its terrible */
			Auto: false
		};
		
	  var options = $.extend(defaults, options);  
		return this.each(function(){
			obj = $(this);
			$("."+options.NextClass).attr("href","javascript:void(0);");
			$("."+options.PrevClass).attr("href","javascript:void(0);");			
			$("li",obj).css("width", options.Width);
			$("li",obj).css("height", options.Height);
			if(options.Offset <= 1){ $(obj).css("width", options.Width); $(obj).css("height", options.Height); }
			if(options.Direction == "vertical"){
				var Max = parseInt(($("li", obj).length - options.Offset) * options.Height);
			} else var Max = parseInt(($("li", obj).length - options.Offset) * options.Width);
			var Low = "-"+Max;
			if(options.Direction !== "vertical"){
				$("ul",obj).css("width", (Max+100) + (options.Offset * options.Width)+"px");
				$("li",obj).css("float", "left");
			}
			$("."+options.NextClass).click(function(){ doMove("next",false);  });
			$("."+options.PrevClass).click(function(){ doMove("prev",false); });
			
			//setTimeout(function(){}, 2000);
				
			function doMove(dir, auto){
				if($(':animated', obj).length){
					return false;
				} else {
					var Ran = "n";
					if(dir.length > 0){
						if(options.Direction == "vertical"){
							var CssAttr = "margin-top";
							var AnimateAttr = "marginTop";
						} else {
							var CssAttr = "margin-left";
							var AnimateAttr = "marginLeft";
						}
						var Height = options.Height;
						var Curr = $("ul", obj).css(CssAttr);
						var Curr = parseInt(Curr.substr(0,Curr.length-2));
						switch(dir){
							case "next" :
								if(options.Direction !== "vertical"){
									var Moving = ((options.Width - Curr));
								} else var Moving = ((Height - Curr));
								if(Curr > Low){
									eval("$('ul',obj).animate({ "+AnimateAttr+": '-'+Moving }, options.Speed)");
									Ran = "y";
								}
								break;
							case "prev" :
								if(options.Direction !== "vertical"){
									var Moving = ((options.Width + Curr));
								} else var Moving = ((Height + Curr));
								if(Curr < 0){
									eval("$('ul',obj).animate({ "+AnimateAttr+": Moving }, options.Speed)");
									Ran = "y";
								}
								break;
						}
						if(auto){
							doMove(dir,auto);
						}
						if(options.Restart){
							if(Ran !== "y"){
								if(dir == "next"){
									var ResetVal = "0px";
									if(ResetVal.length > 0) eval("$('ul',obj).animate({ "+AnimateAttr+": ResetVal }, "+options.RestartSpeed+")");
								}
							}
						}
					}
				}
			}
		});
};})(jQuery);  