﻿/// <reference path="jquery-1.4.1-vsdoc.js" />


$(document).ready(function () {
    var speed = 60;
    var delay = 3000;
    var mheight = $("#marquee").attr("height");
    var kjoer;
    $("<div></div>").addClass("alternate").height(mheight).css("position", "relative").css("overflow", "hidden").css("height", "370px").prependTo("#rollerText");
    $("<div></div>").addClass("scroller").css({ "position": "absolute", "top": "0px" }).appendTo(".alternate");
    $("#marquee").hide().children().appendTo("div.scroller");
    var dim = $(".scroller").clone().appendTo(".alternate").height();
    $(".scroller:eq(1)").css("top", dim);

    function scroll() {
        $(".scroller").each(function () {
            var a = parseInt($(this).css("top"));
            $(this).css("top", a - 1);
            if (a < (0 - dim)) tick($(this));
        });
    };

    function tick(obj) {
        obj.css("top", dim);
    };

    function wait() {
        kjoer = setInterval(scroll, speed);
    }
    var go = setTimeout(wait, delay)
    $(".scroller").hover(function () { clearTimeout(go); clearInterval(kjoer); }
  , function () { kjoer = setInterval(scroll, speed); })
});

