// JavaScript Document
(function ($) { 
	var vscrollid = 0; 
	$.fn.vScroll = function (options) { 
		var options = $.extend({}, { speed: 500, height: 300, upID: "#up-arrow", downID: "#bottom-arrow", cycle: true }, options);
 	return this.each(function () { 
		vscrollid++; 
		obj = $(this);
		var newid = vscrollid; 
		obj.css("overflow", "hidden");
		obj.css("position", "relative");
		obj.css("height", options.height + "px");
		 obj.children().each(function (intIndex) { $(this).addClass("vscroll-" + intIndex) });
		var itemCount = 0; 
 		var divH = 163;
	$(options.downID).click(function () { 
		var nextCount = itemCount + 1; 
		if ($('.vscroll-' + nextCount).length) { 
			//var divH = ($('.vscroll-' + itemCount).outerHeight());
			
 			itemCount++; 
 			$("#vscroller-" + newid).animate({ top: "-=" + divH + "px" }, options.speed) 
 		}  else  { 
			if (options.cycle) { 
 	itemCount = 0; 
 	$("#vscroller-" + newid).animate({ top: "0" + "px" }, options.speed) } 
		} 
	});
	$(options.upID).click(function () { 
		var prevCount = itemCount - 1; 
 		if ($('.vscroll-' + prevCount).length) { 
			itemCount--; 
			//var divH = $('.vscroll-' + itemCount).outerHeight();
			
 			$("#vscroller-" + newid).animate({ top: "+=" + divH + "px" }, options.speed) 
		} 
	});
 	obj.children().wrapAll("<div style='position: relative; top: 0' id='vscroller-" + vscrollid + "'></div>") 
	}) } })(jQuery);

