﻿/// <reference path="~/Default.aspx" />

$(document).ready(function() {

    //Initialize
    //Set the selector in the first tab
    $(".container .TabMenu li:first").addClass("selector");


    //Add click action to tab menu
    $(".container .TabMenu li").mouseover(function() {
        //Remove the exist selector
        $(".selector").removeClass("selector");
        //Add the selector class to the sender
        $(this).addClass("selector");

        //Find the width of a tab
        var TabWidth = $(".TabContent:first").width();
        if (parseInt($(".TabContent:first").css("margin-left")) > 0)
            TabWidth += parseInt($(".TabContent:first").css("margin-left"));
        if (parseInt($(".TabContent:first").css("margin-right")) > 0)
            TabWidth += parseInt($(".TabContent:first").css("margin-right"));
        //But wait, how far we slide to? Let find out
        var newLeft = -1 * $(".container .TabMenu li").index(this) * TabWidth;
        //Ok, now slide
        $(".AllTabs").animate(
                    { left: +newLeft + "px" },
                    { queue: false, duration: 1000 }
                );
    });
});

function loadCaseStudy(id) {
    jQuery.facebox(function() {
        jQuery.get('/CaseStudyLoader.aspx?id=' + id, function(data) {
            jQuery.facebox(data)
        })
    });
    return false;
}