﻿var i = 0;
var divs = 0;

$(document).ready(function(){
  setTimeout("StartScrolling()", 1000);
});

function StartScrolling()
{
    divs = $("#scroll > div").size();
    i = i + 1;
    if (i < (divs - 1))
    {
        $("#scroll div:nth-child(" + i + ")").animate({ height: 'hide', opacity: 'hide', marginTop: '-16px'}, 750);
        setTimeout("ScrollUp()", 1500);
    }
}

function ScrollUp()
{
    if (i < (divs - 1))
    {
        i = i + 1;
        if (i < 1) { i = 1; }
        $("#scroll div:nth-child(" + i + ")").animate({ height: 'hide', opacity: 'hide', marginTop: '-16px' }, 750);
        setTimeout("ScrollUp()", 1500);
    }
    else
    {
        ScrollDown();
    }
}

function ScrollDown()
{
    if (i > 0)
    {
        $("#scroll div:nth-child(" + i + ")").animate({ height: 'show', opacity: 'show', marginTop: '0' }, 200);
        i = i - 1;
        setTimeout("ScrollDown()", 250);
    }
    else
    {
        ScrollUp();
    }
}

