(function($) {
	$.fn.slideVertical = function (vars) {
		
		var element = this;
		var items = $("#" + element[0].id + " ." + element[0].id + "Item");
		var timeOut = (vars.timeOut != undefined) ? vars.timeOut : 4000;
		var current = null;
		var start = true;
				
		items.each(function(i) {
			
			if(items.length > 1) {
				$(items[i]).mouseover(function() {
					clearInterval(timeOutFn);
				});
				
				$(items[i]).mouseout(function() {
					timeOutFn = setInterval(makeScroll, timeOut);
				});
			};
		
		});
		
		var makeScroll = function () {
			current = (current != null) ? current : items[(items.length-1)];
			var currNo = jQuery.inArray(current, items) + 1;
			start = (currNo == items.length) ? true : false;
			currNo = (currNo == items.length) ? 0 : (currNo - 1);

			$(items[currNo]).css("top",(parseInt(element[0].offsetHeight)+40)+"px");
			$(items[currNo]).css("display","block");

			if(start) {
				$(items[currNo]).animate({top: "0"}, 800, function() {
					start = false;
				});
			} else {
				$(items[currNo]).animate({top: "0"}, 800);
			};

			current = items[(currNo+1)];
			var prevNo = (currNo == 0) ? (items.length - 2) : (currNo - 1);
			if($(items[prevNo]).css("display")=="block") {
				$(items[prevNo]).animate({top: "-"+parseInt(element[0].offsetHeight)+"px"}, 800);				
			};
		};
		
		makeScroll();
		if(items.length > 1) {
			timeOutFn = setInterval(makeScroll, timeOut);
		};
	};
	
})(jQuery);  
