﻿var SmallTeaserBoxIndex = 0;
var SmallTeaserBoxes = new Array();

var BigTeaserBoxIndex = 0;
var BigTeaserBoxes = new Array();

var TestimonialSmallBoxIndex = 0;
var TestimonialSmallBoxes = new Array();

function HideRandomBox() {
    HideBox(Math.floor(Math.random() * BigTeaserBoxes.length));
}

function HideBox(BoxIndex) {
    if (SmallTeaserBoxes.length > BoxIndex)
        $('#' + SmallTeaserBoxes[BoxIndex]).remove();

    for (i = 0; i < BigTeaserBoxes.length; i++)
        if(i != BoxIndex)
            $('#' + BigTeaserBoxes[i]).remove();
}

function HideRandomTestimonialSmallBoxes() {
    HideTestimonialSmallBoxes(Math.floor(Math.random() * TestimonialSmallBoxes.length));
}

function HideTestimonialSmallBoxes(BoxIndex) {
    for (i = 0; i < TestimonialSmallBoxes.length; i++)
        if (i != BoxIndex)
            $('#' + TestimonialSmallBoxes[i]).remove();
}

var timer;
function HideBanner() {
    var Banners = $('.HomeBanner');

    if (Banners.length > 1) {
        var BoxIndex = GetVisibleBannerIndex(Banners.length);

        for (i = 0; i < Banners.length; i++) {
            if (i != BoxIndex)
                Banners.eq(i).hide();
            else
                Banners.eq(i).show();
        }

        setTimeout("HideBanner()", 5000)
    }
}

function GetVisibleBannerIndex(BannerCount) {
    var RANDOM_BANNER_COOKIE = "RandomBannerCookie";
    var BoxIndex;

    try {
        if ((BoxIndex = readCookie(RANDOM_BANNER_COOKIE)) == null) {
            BoxIndex = 0;
            createCookie(RANDOM_BANNER_COOKIE, BoxIndex, 1);
        }
        else
            BoxIndex = Number(BoxIndex) + 1;

        if (BoxIndex >= BannerCount)
            BoxIndex = 0;
    } catch (e) {
        BoxIndex = 0;
    }

    createCookie(RANDOM_BANNER_COOKIE, BoxIndex, 1);

    return BoxIndex;
}

function SetAdobeImage() {
    $('img.adobe').each(function() {
        $(this).attr('src', '/media/images/adobe.gif');
        $(this).attr('alt', '');
    });
}