// Mobile
$(document).ready(function () {

    // For Mobile Template: if any div.cmspage is empty, let's remove it -- avoids padding on empty pages.			
    $('#Mobile div').each(function (i, el) {
        // Remove white space
        var html = $(el).html().replace(/\s+/, '');
        // Check if element is :empty or length of html is zero
        if ($(el).is(':empty') || html.length == 0)
            $(el).remove();
    });

});  //END DOC READY

function addPageTools() {
	var clientDomainName = 'jaxhealth.com',
		clientSiteName = 'St. Vincents Healthcare',
		currentPageUrl = document.location,
		currentPageTitle = $.trim($('title').text()),
		emailSubject = clientDomainName + ': ' + currentPageTitle,
		emailHref = 'mailto:?subject=' + escape(emailSubject) + '&body=I thought you would be interested in a page on the ' + escape(clientSiteName) + ' Web site: ' + escape(currentPageTitle) + ' - ' + escape(currentPageUrl);
    var urlToUse = (('https:' == document.location.protocol) ? 'https://s7.addthis.com/js/250/addthis_widget.js#pub=stvincent' : 'http://s7.addthis.com/js/250/addthis_widget.js#pub=stvincent');
    $('#PageToolsWrapper .Dec').append('<div id="PageTools" class="ClearFix">' +
		'<ul>' +
			'<li class="Email"><a href="' + emailHref + '">Email</a></li>' +
			'<li class="Print"><a href="javascript:;" onclick="print();">Print</a></li>' +
			'<li class="AddThis">' +
				'<!-- AddThis Button BEGIN -->' +
					'<a href="http://www.addthis.com/bookmark.php?v=250&amp;pub=stvincent">Add</a>' +
					'<script type="text/javascript" src="' + urlToUse + '"></script>' +
				'<!-- AddThis Button END -->' +
			'</li>' +
		'</ul>' +
	'</div>');
}
function addTextSizer() {
	$('#PageToolsWrapper .Dec').append('<div id="TextSizer" class="ClearFix"><h2>Text Size</h2><ul>' +
				'<li><a class="NormalFont" href="javascript:;" title="Small Font Size"></a></li>' +
				'<li><a class="LargeFont" href="javascript:;" title="Medium Font Size"></a></li>' +
				'<li><a class="X-LargeFont" href="javascript:;" title="Large Font Size"></a></li>' +
			'</ul></div>');	
	$('a.NormalFont').click(function() {$('#Content').removeClass('textLarge').removeClass('textXLarge');$.cookie('text_sizer', null, { path: '/' });});
	$('a.LargeFont').click(function() {$('#Content').addClass('textLarge').removeClass('textXLarge');$.cookie('text_sizer', 'large', { path: '/' });});
	$('a.X-LargeFont').click(function() {$('#Content').removeClass('textLarge').addClass('textXLarge');$.cookie('text_sizer', 'xlarge', { path: '/' });});
	$('#TextSizer a').click(function() {$('#TextSizer a').removeClass('active');$(this).addClass('active');});
}
function text_size_checker() {
	var text_sizer_cookie = $.cookie('text_sizer');
	if (text_sizer_cookie==null){$('a.NormalFont').addClass('active')};
	if (text_sizer_cookie=='large'){ $('#Content').addClass('textLarge');$('a.LargeFont').addClass('active') };
	if (text_sizer_cookie=='xlarge'){ $('#Content').addClass('textXLarge');$('a.X-LargeFont').addClass('active') };
}


$(document).ready(function () {
    addTextSizer();
    text_size_checker();
    addPageTools();

    // ----------- TEMPLATE EXTRAS ------------------//

    //A-Z Tabs on microsite (Procedures & Conditions pages)
    $("#two").hide();
    $("#three").hide();
    $("#four").hide();
    $("#five").hide();
    $("#six").hide();
    $("#seven").hide();
    $("#eight").hide();
    $("#nine").hide();
    $("#ten").hide();
    $("#eleven").hide();
    $("#twelve").hide();
    $("#thirteen").hide();
    $("#fourteen").hide();
    $("#fifteen").hide();
    $("#sixteen").hide();
    $("#seventeen").hide();
    $("#eighteen").hide();
    $("#nineteen").hide();
    $("#twenty").hide();
    $("#twentyone").hide();
    $("#twentytwo").hide();
    $("#twentythree").hide();
    $("#twentyfour").hide();
    $("#twentfive").hide();
    $("#twentysix").hide();

    $(".tabs a").click(function () {
        // Figure out current list via CSS class
        var curList = $(".tabs a.active").attr("rel");

        //alert(curList);
        // List moving to
        var $newList = $(this);

        //alert($newList);
        // Set outer wrapper height to height of current inner list
        var curListHeight = $("#all-list-wrap").height();
        $("#all-list-wrap").height(curListHeight);

        // Remove highlighting - Add to just-clicked tab
        $(".tabs a").removeClass("active");
        $newList.addClass("active");

        // Figure out ID of new list
        var listID = $newList.attr("rel");

        if (listID != curList) {

            // Fade out current list
            $("#" + curList).fadeOut(300, function () {

                //$("#"+listID+"_test").addClass('accordion_content');
                // Fade in new list on callback
                $("#" + listID).fadeIn();

                // Adjust outer wrapper to fit new list snuggly
                var newHeight = $("#" + listID).height();
                $("#all-list-wrap").animate({
                    height: newHeight
                });
            });
        }

        // Don't behave like a regular link
        return false;
    });

    // FadeMe option for the Tab container (used on Bariatric site)
    $('.TabContainerlive.FadeMe ul.Tabnav li').live('click', function () {
        var $t = $(this),
                       $p = $t.closest('.TabContainerlive'),
                       $i = $t.parent().children().index($t);

        $p.find('.Tab').eq($i).hide().fadeIn().css('display', '');
    });

    //adding styles for contact form on Spine and Brain site
    $('.ContactLeft').parents('.cmspage').addClass('ContactUs');
    $('.ContactUs').parents('#Content').addClass('ContactUsContent ClearFix');
    $('.ContactUsContent .cmspanel').appendTo('.ContactUs');
    $('.ContactUs .Column').removeClass('Column');

    //adding span for the ArrowHeader in the Spine and Brain site 
    $('body.SpineandBrain .ArrowHeader').append('<span></span>');

    // Removing Col3 header in microsite interior if no panels exist.
    $('body.LandingInterior #Col3Panels:empty').prev().hide();

    // Adding a class of First to the first tab on home page
    $('body.Home ul.Tabnav li:first a').addClass('First');

    // Ading first and last class to home filmstrip table tds
    $('table.HomeFilmstrip td:nth-child(1)').addClass('First');
    $('table.HomeFilmstrip td:nth-child(2)').addClass('Second');
    $('table.HomeFilmstrip td:nth-child(3)').addClass('Third');
    $('table.HomeFilmstrip td:nth-child(4)').addClass('Fourth');

    // Removing QuickLinks div if no cmspanel resides there.
    $('body.Interior #QuickLinks:empty').parent().addClass('NoQuickLinks');
    $('body.Interior #QuickLinks:empty').remove();

    // Removing SlideShowPanel, ColorPreFooterWrapper2 & BelowCol panels if no cmspanel resides there.
    $('#SlideShowPanel .Dec:empty').parent().remove();
    $('#ColorPreFooter:empty').parent().parent().remove();
    $('#BelowCol1:empty').remove();
    $('#BelowCol2:empty').remove();
    $('#Content2Col:empty').remove();

    // Hiding containers if empty
    $('div.cmspage:empty').addClass('Hide');
    $('#ContentCol1:empty').addClass('Hide');
    $('#ContentCol2:empty').addClass('Hide');

    //adding Active class to top level when drop down is still active (landing/landing interior)
    $('#MainNav ul li').hover(
		function () { $(this).addClass('ActiveParent'); },
		function () { $(this).removeClass('ActiveParent'); }
	);

    // Main Nav addition of home icon
    $('#MainNav ul').not('body.Microsite #MainNav ul').not('#Mobile #MainNav ul').prepend('<li class="Home"><a href="/">Home</a></li>');
    $('body.Bariatric #MainNav ul').prepend('<li class="Home"><a href="/services/bariatrics/">Home</a></li>');
    $('body.Afib #MainNav ul').prepend('<li class="Home"><a href="/services/afib/">Home</a></li>');

    $('body.Home #MainNav li.Home').not('body.Microsite #MainNav li.Home').remove();

    $('body.Home #MainNav ul li.Home').addClass('Active');

    $('body.Landing #MainNav li.Home').remove();
    $('body.LandingInterior #MainNav li.Home').remove();

    //Mobile Main Nav - Adding phone number
    $('#Mobile #MainNav ul').append('<li class="Phone"><a href="tel:9043087300" target="_self"><span>904-308-7300</span></a></li>');


    //removing color bar div from bariatric microsite
    $('body.Bariatric #ColorBar').remove();

    // Moving panel for Proximity Nav after the H2 prox nav header
    $('#ProximityNav h2').after('<div class="NavPanel"></div>');
    $('#ProxNavPanel').appendTo('.NavPanel');
    $('#ProxNavPanel:empty').hide();

    // Making external service link open in a new window
    $('#Services a[href^="http://"]')
        .attr({
            target: '_blank',
            title: 'Opens in a new window'
        });

    // Add class name to Status dropdown in Find a Doctor form
    $('.DrSearch fieldset div:nth-child(5)').addClass('Status');

    // Microsite scroll to Top   
    $('a[href=#Top]').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 'slow');
        return false;
    });

    //Microsite (Spine and Brain)
    $('#PreFooter2:empty').parent().remove();

    //alternate colors on ul.ColorRows, .AltSecions and ul.Afib-ColorArrows
    $('ul.ColorRows li:nth-child(even)').addClass('Alt');
    $('.AltSections div:nth-child(odd)').addClass('Alt');
    $('ul.Afib-ColorArrows li:nth-child(even)').addClass('Alt');
    $('ul.Afib-ColorArrows li:last').addClass('Last');

    //Microsite hide/show full story (used on afib testimonials)
    $('div.FullStory').hide();
    $('.ShowHide').click(function () {
        $(this).prev('div.FullStory').slideToggle('500').siblings('div.FullStory').slideUp('slow');
        $(this).toggleClass('Less').siblings('.ShowHide').removeClass('Less');
    });

    
    // ----------- HACK LIST START ------------------//
   
    // Hiding top border from first cmspanel in right col (landing interior)
    $('#RightPanel .cmspanel:first').addClass('FirstPanel');

    // Adding class to first cmspanel in column so all panels don't get bkgd color.
    $('#ContentCol1 .cmspanel:first').addClass('FirstPanel');
    $('#ContentCol2 .cmspanel:first').addClass('FirstPanel');
    $('#ContentCol3 .cmspanel:first').addClass('FirstPanel');

    // Adding spans to main nav dropdown
    $('#MainNav ul ul li a').wrapInner('<span></span>');
    $('#MainNav ul ul li strong').wrapInner('<span></span>');

    // Removing padding from empty table cells from calendar event detail header
    $('.CalendarEventDetailHeader td:empty').addClass('Empty');

    // Adding styles to mobile template
    $('#Mobile #MainNav li:nth-child(2)').addClass('Second');
    $('#Mobile #MainNav li:nth-child(3)').addClass('Third');


    // ----------- HACK LIST END ------------------//

});      // End Document Ready


// Quick links toggle slide
$(document).ready(function(){
	$('#QuickLinksHome :header').click(function(){
		$('#QuickLinksHome ul').slideToggle(function(){
		  if ($(this).is(':hidden')) {
		   $('#QuickLinksHome h3').css({"background":"url(../../imgs/quicklinks-arrow-closed.gif) no-repeat left center"});
		  } else {
		   $('#QuickLinksHome h3').css({"background":"url(../../imgs/quicklinks-arrow.gif) no-repeat left center"});
		  }
		});
		//$('#QuickLinksHome').toggleClass('Open');
		return false;
	});
});


// Auto Rotating Tabs
(function($) {
    $.fn.equalHeights = function() {
        tallest = 0;
        this.each(function() {
            if ($(this).height() > tallest) {
                tallest = $(this).height();
            }
        });
        return this.each(function() {
            $(this).height(tallest);
        });
    }
})(jQuery);

var rotateSpeed = 19600; // Milliseconds to wait until switching tabs.
var currentTab = 0; // Set to a different number to start on a different tab.
var numTabs; // These two variables are set on document ready.
var autoRotate;

function openTab(clickedTab) {
	var thisTab = $('.tabbed-box .tabs a').index(clickedTab);
	$('.tabbed-box .tabs li a').removeClass('active');
	$('.tabbed-box .tabs li a:eq('+thisTab+')').addClass('active');
	$('.tabbed-box .tabbed-content').hide();
	$('.tabbed-box .tabbed-content:eq('+thisTab+')').show();
	currentTab = thisTab;
}

function rotateTabs() {
	var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
	openTab($('.tabbed-box .tabs li a:eq('+nextTab+')'));
}

$(document).ready(function() {
	$('.tabbed-content').equalHeights();
	numTabs = $('.tabbed-box .tabs li a').length;
	$('.tabbed-box .tabs li a').click(function() { 
		openTab($(this)); return false; 
	});
	$('.tabbed-box').mouseover(function(){clearInterval(autoRotate)})
	.mouseout(function(){autoRotate = setInterval('rotateTabs()', rotateSpeed)});
	$('.tabbed-box .tabs li a:eq('+currentTab+')').click()
	$('.tabbed-box').mouseout();
});


// New PhotoSlider to be removed after 5.2.9
addLoadEvent(initializePhotoSliders); function initializePhotoSliders() { var c = [], f = []; $(".PhotoSliderVS").each(function (n) { var o = $(this); o.wrapInner('<div class="Border ClearFix"><div class="Overflow"></div></div>').find(".Border").append('<div class="Buttons ClearFix"></div>').find(".Overflow").children("ul").addClass("Container").children("li").addClass("Slide").eq(0).addClass("Active"); o.find("li.Slide:first").addClass("First"); o.find("li.Slide:last").addClass("Last"); if (o.attr("class").match(/^.*SlideW(\d+).*/) !== null) { var m = o.attr("class").match(/^.*SlideW(\d+).*/)[1]; o.find("li.Slide").width(parseInt(m)) } if (!o.hasClass("HideCaptions")) { o.find(".Buttons").before('<p class="PhotoCaption"></p>') } if (!o.hasClass("HideArrows")) { o.find(".Buttons").append('<a class="Prev" href="javascript:;"></a><a class="Next" href="javascript:;"></a>') } if (o.hasClass("ShowNav") || o.hasClass("Vertical")) { var v = o.find("li.Slide").size(), h = '<div class="SlideNav ClearFix"><ul>', y = 1; for (y = 1; y <= v; y++) { h += '<li><a href="javascript:;"><span>' + y + "</span></a></li>" } h += "</ul></div>"; o.find(".Buttons").append(h); o.find(".SlideNav li:first").addClass("First"); o.find(".SlideNav li:last").addClass("Last") } else { if (!o.hasClass("HideNumbers")) { o.find(".Buttons").append('<em class="Count"><span></span>&nbsp;of&nbsp;<span></span></em>') } } if (o.hasClass("HideNumbers") && o.hasClass("HideCaptions")) { o.find(".Buttons").prepend("<em>&nbsp;</em>") } if (o.hasClass("Vertical")) { o.find(".Border").addClass("Vertical") } var k = 0, l = 0, q = 0, z = parseInt(o.find(".Border").css("borderBottomWidth")) * 2, w = parseInt(o.css("padding-left")), u = parseInt(o.css("padding-right")); o.find(".Slide").each(function () { if ($(this).outerWidth(true) > l) { l = $(this).outerWidth(true) } }); var j = o.attr("class").match(/^.*Width(\d+).*/), r; if (j !== null || o.hasClass("FullWidth")) { if (o.hasClass("FullWidth")) { o.hide(); r = o.parent().width() - w - u; o.show() } else { r = parseInt(j[1]) } o.width(r).addClass("manualWidth"); o.find(".Overflow").width(r - z); var x = o.width() - o.css("padding-left").replace("px", "") - o.css("padding-right").replace("px", ""); o.find(".Slide").width(x).addClass("SlideContent") } else { if (o.attr("class").match(/^.*Show(\d+).*/) !== null) { o.addClass("manualWidth").addClass("MultiSlide"); var p = o.attr("class").match(/^.*Show(\d+).*/)[1], m = o.find("li.Slide.Active").outerWidth(), t = o.find("li.Slide").size() - p; o.width(p * m + z); o.find(".Overflow").width(p * m); o.find("li.Slide").eq(t).addClass("LastSlideToShow") } else { o.width(l + z) } } o.find("li.Slide").each(function () { k += $(this).outerWidth(true) }); o.find(".Container").width(k + 100); if (o.attr("class").match(/^.*AutoSlide.*/) !== null) { o.addClass("Continuous"); var s = 4000; if (o.attr("class").match(/^.*AutoSlide(\d+).*/)) { s = o.attr("class").match(/^.*AutoSlide(\d+).*/)[1]; f[e(o)] = s } c[e(o)] = setInterval(function () { d(e(o)) }, s) } d(e(this), 0, true) }); $('.PhotoSliderVS[class*="AutoSlide"]').hover(function () { var h = e($(this)); $(this).addClass("Paused"); clearInterval(c[h]) }, function () { var h = e($(this)); $(this).removeClass("Paused"); c[h] = setInterval(function () { d(h) }, f[h]) }); $(".PhotoSliderVS .Buttons .Prev:not(.Inactive)").live("click", function (h) { var i = $(this).closest(".PhotoSliderVS"); if (i.hasClass("Continuous") && i.hasClass("MultiSlide") && i.find("li.Slide.Active").hasClass("First")) { prevSlide = i.find("li.Slide").index(i.find("li.Slide.LastSlideToShow")) } else { if (i.hasClass("Continuous") && i.find("li.Slide.Active").hasClass("First")) { prevSlide = i.find("li.Slide").size() - 1 } else { prevSlide = a(this) - 1 } } d(e(this), prevSlide) }); $(".PhotoSliderVS .Buttons .Next:not(.Inactive)").live("click", function (h) { var i = $(this).closest(".PhotoSliderVS"); if (i.hasClass("Continuous") && i.hasClass("MultiSlide") && i.find("li.Slide.Active").hasClass("LastSlideToShow")) { nextSlide = 0 } else { if (i.hasClass("Continuous") && i.find("li.Slide.Active").hasClass("Last")) { nextSlide = 0 } else { nextSlide = a(this) + 1 } } d(e(this), nextSlide) }); $(".PhotoSliderVS .Buttons .SlideNav li").live("click", function () { var h = $(this).parent("ul").find("li").index($(this)); d(e(this), h) }); $(".PhotoSliderVS .Buttons .SlideNav ul.ImageThumbs li").hover(function () { $(this).not(".Active").animate({ opacity: 1 }, 200) }, function () { $(this).not(".Active").animate({ opacity: 0.4 }, 200) }).live("click", function () { $(this).css({ opacity: 1 }) }); function b(i) { var h = i.width() + parseInt(i.css("padding-left")) + parseInt(i.css("padding-right")) + parseInt(i.css("margin-right")) + parseInt(i.css("margin-left")) + parseInt(i.css("borderRightWidth")) + parseInt(i.css("borderLeftWidth")); return h } function g(j) { var i = j.height() + parseInt(j.css("padding-top")) + parseInt(j.css("padding-bottom")) + parseInt(j.css("margin-top")) + parseInt(j.css("margin-bottom")) + parseInt(j.css("borderTopWidth")) + parseInt(j.css("borderBottomWidth")); return i } function e(i) { var j = $(i).closest(".PhotoSliderVS"), h = $(".PhotoSliderVS").index(j); return h } function a(i) { var j = $(i).closest(".PhotoSliderVS"), h = j.find("li.Slide").index(j.find("li.Slide.Active")); return h } function d(h, j, i) { $(".PhotoSliderVS").eq(h).each(function () { var Q = $(this), N = Q.find(".Overflow"), H = Q.find(".Container"), G = Q.find("li.Slide").size(), U = "slide"; if (j == null) { j = a(this) + 1; if (Q.find("li.Slide.Active").hasClass("Last")) { j = 0 } } Q.find("li.Slide.Active").removeClass("Active"); Q.find("li.Slide").eq(j).addClass("Active"); Q.find(".Buttons .Count span:first").html(a(Q) + 1); Q.find(".Buttons .Count span:last").html(G); caption = Q.find("li.Slide.Active .Caption").html(); if (caption == null) { caption = Q.find("li.Slide.Active img").attr("alt") } Q.find(".PhotoCaption").html(caption); if (!Q.hasClass("Continuous")) { if (a(Q) == "0") { Q.find(".Buttons .Prev").addClass("Inactive") } else { Q.find(".Buttons .Prev").removeClass("Inactive") } if (a(Q) + 1 == G || Q.find("li.Slide.Active").hasClass("LastSlideToShow")) { Q.find(".Buttons .Next").addClass("Inactive") } else { Q.find(".Buttons .Next").removeClass("Inactive") } } Q.find(".SlideNav li.Active").removeClass("Active"); Q.find(".SlideNav li").eq(a(Q)).addClass("Active"); if (Q.hasClass("FadeMe")) { U = "fade"; Q.find("li.Slide").css("position", "absolute"); Q.find("li.Slide").eq(a(Q)).addClass("Active").stop().css({ opacity: "0", "z-index": "92" }); if (i == true) { Q.find("li.Slide").eq(a(Q)).css({ opacity: "1" }, function () { Q.find("li.Slide").not(".Active").css({ "z-index": "90" }); Q.find("li.Slide.Active").css("z-index", "91") }) } else { Q.find("li.Slide").eq(a(Q)).animate({ opacity: 1 }, function () { Q.find("li.Slide").not(".Active").css({ "z-index": "90" }); Q.find("li.Slide.Active").css("z-index", "91") }) } } var K = Q.find("li.Slide.Active").outerWidth(), V = Q.find("li.Slide.Active").outerHeight(), X = 0, E = 0; Q.find("li.Slide").each(function () { if (E < $(this).outerHeight()) { E = $(this).outerHeight() } }); if (!Q.hasClass("manualWidth")) { if (i == true) { N.width(K).height(E) } else { N.animate({ width: K }) } } if (Q.hasClass("ShowNav") || Q.hasClass("Vertical")) { var I, r, z = false, m = 0, s = 0, D = 0, W = 0, P = 0, y = 0, p = "", l = 0.1, S = Q.find(".SlideNav"), C = 0, L = 0, v = 0, M = Q.find(".Buttons .Prev").outerHeight(), o = Q.find(".Buttons .Next").outerHeight(), F = Q.find(".Buttons .Prev").outerWidth(), Y = Q.find(".Buttons .Next").outerWidth(), R, k; if (M > 0 && o > 0 && F > 0 && Y > 0) { if (M > o) { k = M } else { k = o } if (F > Y) { R = F } else { R = Y } } else { M = 0; F = 0; o = 0; Y = 0 } if (Q.hasClass("Vertical")) { z = true; I = Q.find(".Buttons").parent().height() - parseInt(Q.find(".Buttons").css("padding-top")) - parseInt(Q.find(".Buttons").css("padding-bottom")); r = I - (M + o); Q.find(".Buttons").height(I) } else { r = Q.find(".Buttons").width() - parseInt(Q.find(".Buttons").css("padding-left")) - parseInt(Q.find(".Buttons").css("padding-right")) - (F + Y) } if (Q.attr("class").match(/^.*ImageThumbs.*/) !== null) { Q.find(".SlideNav ul").addClass("ImageThumbs"); if (Q.attr("class").match(/^.*ImageThumbs(\d+).*/)) { l = Q.attr("class").match(/^.*ImageThumbs(\d+).*/)[1] * 0.01 } S.find("li").each(function (n) { p = Q.find("li img").eq(n); $(this).html('<img src="' + p.attr("src") + '" width="' + p.width() * l + '" height="' + p.height() * l + '"/>').not(".Active").css("opacity", "0.4") }) } S.find("li").each(function () { if (z) { y = g($(this)); $(this).height($(this).height()) } else { y = b($(this)) } D += y; if (y > W) { W = y } if ($(this).outerWidth(true) > C) { C = $(this).outerWidth(true); L = C } if (R > C) { C = R } }); P = (parseInt(r / W)); var O = 0; if ($.browser.msie && $.browser.version.substr(0, 1) < 7) { O = parseInt(S.find("li").css("margin-right")) } if (r < D) { if (!(P % 2)) { P = P - 1 } var T = S.find("li.Active"), x = S.find("li").index(T), A = 0, t = (P * 0.5) - 0.5, B = x - t, u = B + P, q = 0; if (B < 0) { B = 0; u = B + P } if (u > G) { u = G; B = u - P } S.find("li.ShowNav").removeClass("ShowNav"); S.find("li").slice(B, u).addClass("ShowNav"); var J = S.find("li").index(S.find(".ShowNav:first")); if (z) { S.find("li").slice(0, J).each(function () { A += g($(this)) }); S.find("li.ShowNav").each(function () { m += g($(this)) }); S.find("ul").height(D + O).stop().animate({ top: -A }) } else { S.find("li").slice(0, J).each(function () { A += b($(this)) }); S.find("li.ShowNav").each(function () { m += b($(this)) }); S.find("ul").width(D + O).stop().animate({ left: -A }) } } else { if (z) { S.find("ul").height(D + O) } else { S.find("ul").width(D + O) } m = D + O } if (z) { S.height(m).css("top", ((r - m) * 0.5) + Q.find(".Buttons .Prev").outerHeight()); if (i) { S.find("li").width(L - parseInt(S.find("li").css("padding-right")) - parseInt(S.find("li").css("padding-left")) - parseInt(S.find("li").css("borderRightWidth")) - parseInt(S.find("li").css("borderLeftWidth"))); I = +C + parseInt(Q.find(".Buttons").css("padding-left")) + parseInt(Q.find(".Buttons").css("padding-right")); Q.width($(this).width() + I); Q.find(".Buttons").width(C); if (Q.hasClass("NavRight")) { Q.find(".Overflow,.PhotoCaption").css("margin-right", I); Q.find(".Border").addClass("NavRight"); Q.find(".Buttons").css("margin-left", Q.find(".Overflow").width()) } else { Q.find(".Overflow,.PhotoCaption").css("margin-left", I) } if (R > L) { v = parseInt((C - L) * 0.5); S.css("margin-left", v + "px").css("margin-right", v + "px") } else { v = parseInt((C - R) * 0.5); S.siblings(".Prev,.Next").css("margin-left", v + "px").css("margin-right", v + "px") } } } else { S.width(m) } } Q.find("li.Slide:lt(" + a(Q) + ")").each(function () { X += $(this).outerWidth(true) }); if (U == "slide") { H.stop().animate({ left: -X }) } }) } };


// Microsite PhotosliderVS additions (on spine and brain testimonials banner)
window.onload =(function() {
    $('body.SpineandBrain .PhotoSlider .Buttons .Next').before('<span>|</span>');
    $('body.SpineandBrain .PhotoSlider .Buttons .Next').html('Next');
    $('body.SpineandBrain .PhotoSlider .Buttons .Prev').html('Previous');
}); // END Window Load



// Microsite FAQ (on spine and brain site) - swapping page contents w/out page refresh.
$(document).ready(function () {

    var hash = window.location.hash.substr(1);
    var href = $('.tab  a').each(function () {
        var href = $(this).attr('href');
        if (hash == href.substr(0, href.length - 5)) {
            var toLoad = hash + '.html #change';
            $('#change').load(toLoad)
        }
    });

    $('.tab  a').click(function () {

        var toLoad = $(this).attr('href') + ' #change';
        $('#change').hide('fast', loadContent);
        $('#load').remove();
        $('.cmspage').append('<span id="load">LOADING...</span>');
        $('#load').fadeIn('normal');
        window.location.hash = $(this).attr('href').substr(0, $(this).attr('href').length - 5);
        function loadContent() {
            $('#change').load(toLoad, '', showNewContent())
        }
        function showNewContent() {
            $('#change').show('normal', hideLoader());
        }
        function hideLoader() {
            $('#load').fadeOut('normal');
        }
        return false;

    });

    /* Fancybox 
    =========================================*/
    $(".FancyVideo").fancybox({
        'padding': '10',
        'autoScale': true,
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'overlayColor': '#000',
        'titleShow': true,
        'titlePosition': 'outside',
        'type': 'iframe'
    });
    $(".FancyBox").fancybox({
        'padding': '10',
        'autoScale': true,
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'overlayColor': '#000',
        'titleShow': true,
        'titlePosition': 'outside'
    });
    $("a[rel=gallery]").fancybox({
        'transitionIn': 'none',
        'transitionOut': 'none',
        'titlePosition': 'over',
        'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });
    $(".FancyYouTube").fancybox({
        'autoScale': true,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'overlayColor': '#000',
        'titleShow': true,
        'titlePosition': 'outside',
        'type': 'iframe'
    });
});
