var nSlide = 0;
var SlideTime = 300;
var step = 10;
var crStep;
var dx;
var dt = Math.round(SlideTime / step);
var maxSlide = 0;
var b = 0;

function move(c)
{
	if (nSlide + c < 0) return;
	if (nSlide + c == maxSlide + 1) return;
	nSlide += c;

	if (crStep) crStep+=4;
	else if (!crStep) {
    	crStep = step;

	$("#slide").everyTime(dt, 'slideTimer', function(i) {
		var ofs = 0;
		$("#slide > div > div:lt("+nSlide+")").each(function() { ofs += this.clientHeight||this.offsetHeight; });
		dx = ( ofs + parseInt($("#slide div").css("top")) ) / crStep;

		var p = Math.round(parseInt($("#slide div").css("top")) - dx);


		if ($("#slide > div").height() < - p + $("#slide").height()) {
			crStep = 1;
			p = - $("#slide > div").height() + $("#slide").height();
		}

		$("#slide > div").css("top",  p + "px");

		crStep--;
		if (!crStep) $("#slide").stopTime('slideTimer');

	});

	}

}

$(document).ready(function(){

s = "";
$("#slide > div").height() + $("#slide").height()

$("#slide > div > div").each(function(){
	if ($("#slide > div").height() > this.offsetTop + $("#slide").height()) maxSlide++;
});

$('#slide').mousewheel(function(event, delta) {
	if (delta > 0) move(-1);
	else if (delta < 0) move(1);
	event.stopPropagation();
	event.preventDefault();
});

});

