﻿//Utility methods for any page which wants to show case studies with small intros that expand to full versions
//Relies on page elements being named in a certain way.
//For example usage, see /personal/life/financialwellbeing/casestudy.aspx

function showFullCaseStudyByIndex(index) {
    $('#casestudy' + index + '_full').fadeIn(1000);
    OmnitureTrackingCode.TabChange('casestudy' + index);
}

function switchCaseStudies(hideIndex, showIndex) {
    $('#casestudy' + hideIndex + '_full').slideUp(1000);
    $('#casestudy' + showIndex + '_full').slideDown(1000, function() {
        $(this).scrollTo(1000);
    });
}

function hideFullCaseStudy(index) {
    if (index) {
        $('#casestudy' + index + '_full').fadeOut(1000);
    }
    else {
        $("#case-study-full-versions").children("div").fadeOut(1000);
    }
}

function showSmallCaseStudies() {
    $("#case-study-intros").show(1000);
}

function hideSmallCaseStudies() {
    $("#case-study-intros").hide(1000);
}

$(document).ready(function() {
    //Show/hide the appropriate full case study
    $("#case-study-intros a.arrowbutton").click(
        function() {
            var casestudyid = $(this).attr("casestudyid");
            hideSmallCaseStudies();
            showFullCaseStudyByIndex(casestudyid);
        });

    $("#case-study-full-versions a.tabclose").click(
        function() {
            hideFullCaseStudy(null);
            showSmallCaseStudies();
            return false;
        });
});
