function BannerRotator(_tabStripId, _headerDivId, _intervalMs, _cookiePrefix) {
    this.intervalMs = (!_intervalMs || _intervalMs == null) ? 0 : _intervalMs;
    this.tabStripId = (!_tabStripId || _tabStripId == null) ? null : _tabStripId;
    this.headerDivId = (!_headerDivId || _headerDivId == null) ? null : _headerDivId;
    this.cookiePrefix = (!_cookiePrefix || _cookiePrefix == null) ? "" : _cookiePrefix;
    this.currentInterval = null;
    this.isAdvancing = null;
    this.images = new Array();
    var me = this;

    this.clearBannerInterval = function () {
        if (this.currentInterval) {
            window.clearInterval(this.currentInterval);
            this.currentInterval = null;
        }
    };

    this.nextBanner = function (e) {
        if ((!e || e != "auto") && this.currentInterval) {
            this.clearBannerInterval();
        }

        if (this.tabStripId != null) {
            var tabstrip = $find(this.tabStripId);
            if (tabstrip != null) {
                this.isAdvancing = true;
                var nextIndex = (tabstrip.get_selectedIndex() + 1);
                if (nextIndex >= tabstrip.get_tabs().get_count()) {
                    nextIndex = 0;
                }
                this.selectBanner(nextIndex);
                this.isAdvancing = false;
            }
        }
    };

    this.selectBanner = function (index) {
        if (index > -1 && index < this.images.length) {
            this.isAdvancing = true;
            var tabstrip = $find(this.tabStripId);
            if (tabstrip != null) {
                tabstrip.set_selectedIndex(index);
            }
            this.setHeaderImage(index);
            this.isAdvancing = false;
        }
    };

    this.pauseAdvance = function () {
        this.clearBannerInterval();
    };

    this.resumeAdvance = function () {
        if (!this.currentInterval && this.intervalMs > 0) {
            this.currentInterval = window.setInterval(function () { me.nextBanner("auto"); }, this.intervalMs);
        }
    };

    this.stopAdvance = function () {
        if (!this.isAdvancing) {
            this.clearBannerInterval();
        }
    };

    //updates the header css background image
    this.setHeaderImage = function (index) {
        if (index > -1 && index < this.images.length) {
            var image = this.images[index];
            var cookieName = this.cookiePrefix + "headerbgimage";
            //from common.js
            setCookie(cookieName, image);
            if (this.headerDivId != null) {
                var headerDiv = document.getElementById(this.headerDivId);
                if (headerDiv != null) {
                    headerDiv.style.backgroundImage = "url('" + image + "')";
                }
            }
        }
    };

    this.clearBannerInterval = function () {
        if (this.currentInterval) {
            window.clearInterval(this.currentInterval);
            this.currentInterval = null;
        }
    };

    this.selectTab = function (sender, args) {
        this.clearBannerInterval();
        var tabstrip = $find(this.tabStripId);
        var nextIndex = tabstrip.findTabByText(args.get_tab().get_text()).get_index();
        if (nextIndex >= tabstrip.get_tabs().get_count()) {
            nextIndex = 0;
        }
        this.automaticAdvance = true;
        tabstrip.set_selectedIndex(nextIndex);
        this.automaticAdvance = false;
    };
}

function ClickBanner(url, title, name) {
    //GSA tracking
//    if (pageTracker != undefined) {
//        pageTracker._trackPageview(title + '_' + name);
    //    }

    // Call Omniture event21
    //trackEvent21(title);

    if (url != null && url != undefined) {
        if (url.indexOf("http") == 0 || url.indexOf("ftp") == 0) {
            var ref = window.open(url);
            if (ref == null) {
                window.location = url;
            }
        }
        else if (url.indexOf("javascript:", 0) > -1) {
            var scriptUrl = new String(url).substr(11);
            eval(scriptUrl);
        }
        else {
            location.href = url;
        }
    }
}

function OmnitureBanner() {
    // SiteCatalyst - Banner Tracking
    s.linkTrackVars = "prop4,eVar15";
    s.linkTrackEvents = "";
    s.prop4 = "Home | Background Image";
    s.eVar15 = "www.optumhealth.com";
    s.tl(this, 'o', 'background image nav');
}


