﻿// top banner
var homeTopBanner = {
    startIndex: Object,
    init: function () {
        this.startIndex = 0;

        $("#homePageBannerRotator").cycle({
            cleartype: false,
            fx: 'fade',
            speed: 'slow',
            startingSlide: homeTopBanner.startIndex,
            timeout: 11000,
            pager: '#bannerRotatorPager',
            pagerAnchorBuilder: function (idx, slide) {
                return '<li><a href="#">' + slide.title + '</a></li>';
            }
        });
    }
}

// content block rotator
var homeContentBlockRotator = {
    startIndex: Object,
    init: function () {
        this.startIndex = 0;

        $("#homePageContentBlockRotator").cycle({
            cleartype: false,
            fx: 'fade',
            speed: 'slow',
            startingSlide: homeContentBlockRotator.startIndex,
            timeout: 0,
            pager: '#homePageContentBlockPager',
            pagerAnchorBuilder: function (idx, slide) {
                return '<li><a href="#">' + idx + '</a></li>';
            }
        });
    }
}

function initializeHome() {
    homeTopBanner.init();
    homeContentBlockRotator.init();
}

$(function () {
    initializeHome();
    var hn=window.location.pathname.toLowerCase();
    var ihg=!!(hn.match(/(forhim|forher|forfamily|forpet|giftgiving)/));
    if(ihg){
        var brp = $('#bannerRotatorPager').children().length*129;
        $('#bannerRotatorPager').width(brp);
        $('#bannerNav div.HorizontalSpacer').width(965-brp-5);
    }
});
