﻿var Lincoln = Lincoln || {}; Lincoln.Utils = Lincoln.Utils || {}; Lincoln.Utils.LargeRotator = function() {
    var currI = 0; var current = "#" + $('.promo').eq(currI).attr("id"); var rotItems = $(".rotator-controls").find("li.toggle").length; var intervalTime = 8000; var t = setInterval("Lincoln.Utils.AutoRotate(" + currI + ")", intervalTime); var pause = false; $(".promo").not(":eq(" + currI + ")").hide(); $(".rotator-controls li").eq(currI).addClass("active"); $(".rotator-controls").find("li a").click(function() {
        clearInterval(t); if ($(this).parents("li").hasClass("active")) { return false; }
        $(".rotator-controls").find(".active").removeClass("active"); $(this).parents("li").addClass("active"); var thrf = $(this).attr("href"); Lincoln.Utils.LargeRotator.Rotate(thrf); currI = $(".rotator-controls").find("li a").index($(this)); if (pause == false) { t = setInterval("Lincoln.Utils.AutoRotate(" + currI + ")", intervalTime); }
        return false;
    }); if ($(".rotator-controls .play")) { $(".rotator-controls").find(".play").hide().click(function() { $(this).hide(); $(".rotator-controls").find(".pause").show(); t = setInterval("Lincoln.Utils.AutoRotate(" + currI + ")", intervalTime); pause = false; }); }
    if ($(".rotator-controls .pause")) { $(".rotator-controls").find(".pause").click(function() { $(this).hide(); $(".rotator-controls").find(".play").show(); clearInterval(t); pause = true; }); }
    Lincoln.Utils.AutoRotate = function(l) {
        if (rotItems > 1 && pause == false) {
            if ((currI + 1) >= rotItems) { currI = 0; } else { currI++ }
            var next = $(".rotator-controls").find("li a").eq(currI).attr('href'); Lincoln.Utils.LargeRotator.Rotate(next); $(".rotator-controls").find(".active").removeClass("active"); $(".rotator-controls").find("li.toggle").eq(currI).addClass("active");
        } else { return; } 
    }; Lincoln.Utils.LargeRotator.Rotate = function(file) { $(current).hide(); $(file).fadeIn(); $(file).css({ "display": "block", "top": 0, "left": 0, "position": "relative" }); current = file; };
}; $(document).ready(function() { Lincoln.Utils.LargeRotator(); });
