﻿function formatText(index, panel) {
    return index + "";
}
var anythingbanner = {
    init: function () {
        $('.banner').anythingFader({
            //Disabled for American Heart Month Feb 2012
			autoPlay: false,                 // This turns off the entire FUNCTIONALITY, not just if it starts running or not
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            delay: 12000,                    // How long between slide transitions in AutoPlay mode
            animationTime: 600,             // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
            pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
            startText: "Start",
            stopText: "Stop",
            navigationFormatter: null
        });
    }
};
// Bookmark link
var bookmark = {
    init: function () {
        if (window.opera) {
            if (jQuery(".bookmark").attr("rel") != "") {
                jQuery(".bookmark").attr("rel", "sidebar");
            }
        }
        jQuery(".bookmark").click(function (event) {
            event.preventDefault();
            var url = this.href;
            var title = this.title;

            if (window.sidebar) {
                window.sidebar.addPanel(title, url, "");
            } else if (window.external) {
                window.external.AddFavorite(url, title);
            } else if (window.opera) {
                return false;
            } else {
                alert('Unfortunately, this browser does not support the requested action,' + ' please bookmark this page manually.');
            }
        });

    }
};
// Animated Refining Orthopedics Ad
var animatedad = {
    init: function () {
        jQuery('#animate').click(function () {
            window.location.href = "http://www.weisshospital.com/medical-services/orthopedics.aspx";
        });

        jQuery('#animate .cco-banner-button').css({ 'opacity': '0', 'left' : '-300px' });
        jQuery('#animate .active-button').animate({ 'opacity': '1', 'left': '23px' }, 550).css({ 'z-index': '100' });
        var int = setInterval(changeText, 10000);

        function changeText() {
            var $activeText = jQuery('#animate .active-button');
            var $nextText = $activeText.next();

            if ($activeText.next().length === 0) $nextText = jQuery('#animate .cco-banner-button:first');
            $activeText.animate({ 'opacity': '0', 'left': '300px' }, 550).css({ 'z-index': '0' });

            $nextText.css({ 'opacity': '0', 'left': '-300px' }).css({ 'z-index': '100' }).addClass('active-button').animate({ 'opacity': '1', 'left': '23px' }, 550, function () {
                $activeText.removeClass('active-button');
            });
        }
    }
};
var scrollTop = {
    init: function () {
        var url = window.location.href;
        if (url.indexOf('orthopedics') != -1) {
            window.scrollTo(0, 158);
        }
    }
};
var calendarDateHack = {
    init: function () {
        jQuery('ol.sf_eventsList li').each(function () {
            try {
                var ahtml = jQuery(this).find("dl dt a").html();
                var dhtml = jQuery(this).find("div strong").html();
                var cleanDate = dhtml.substring(dhtml.indexOf(",") + 2, dhtml.lastIndexOf(","));

                var returnLink = cleanDate + " - " + ahtml;
                jQuery(this).find("dl dt a").html(returnLink);
            } catch (err) { 
            
            }
        });
    }
};
var pressrelease = {
    init: function () {
        jQuery('.homeblog .sf_postListing').next('a').addClass('press-title');
    }
};
function initialize() {
    anythingbanner.init();
    bookmark.init();
    animatedad.init();
    calendarDateHack.init();
    pressrelease.init()
}
jQuery(function () {
    initialize();
});
