﻿var total_width = 0;
var tab_width = 0;
$(document).ready(function () {
    $(".tabs_wrapper span").each(function () {
        tab_width = $(this).outerWidth();
        if ($(this).hasClass('inactive')) {
            $(this).remove();
        }
        else {
            total_width = parseInt(total_width) + parseInt(tab_width);
            //alert(total_width);
            $(".tabs_wrapper").css("width", total_width);
        }
        gethashcode();

        $('.office_add_in').click(function () {
            tab_img_id = '/education/en-us/PublishingImages/en-us/' + '3' + '.png';
            $(".tabs_wrapper").css('background-image', 'url(' + tab_img_id + ')');
            $('#tab_filter_content3').show();
            $('#tab_filter_content3').siblings().hide();
        });



    });

    var span_length = $(".tabs_wrapper span").length;
    switch (span_length) {
        case 2:
            total_width = '452px';
            $(".tabs_wrapper").css("width", total_width);
            break;
        case 3:
            total_width = '671px';
            $(".tabs_wrapper").css("width", total_width);
            break;

        default:
            break;
    }

    $(".tabs_wrapper span").click(function () {
        //alert(this);
        var tabid = $(this).index();
        tabid++;
        tab_img_id = '/education/en-us/PublishingImages/en-us/' + tabid + '.png';
        $(".tabs_wrapper").css('background-image', 'url(' + tab_img_id + ')');
        tab_content_div = 'tab_filter_content' + tabid;
        $('#' + tab_content_div).css('display', 'block');
        $('#' + tab_content_div).siblings().hide();
        window.location.hash = tabid;
    });
});



function gethashcode() {
    var url = window.location;
    //alert(url);
    //var newurl = $(url).slice(-1);
    var newurl = url.href.slice(-1);
    // alert(newurl);
    var tabid = newurl;

    if (window.location.hash) {
        tab_img_id = '/education/en-us/PublishingImages/en-us/' + tabid + '.png';
        $(".tabs_wrapper").css('background-image', 'url(' + tab_img_id + ')');
        tab_content_div = 'tab_filter_content' + tabid;
        $('#' + tab_content_div).css('display', 'block');
        $('#' + tab_content_div).siblings().hide();
    }
    else {

    }
}
