// JavaScript Document

function getQueryString() {
    var result = {}, queryString = location.search.substring(1), re = /([^&=]+)=([^&]*)/g, m;
    while (m = re.exec(queryString)) {
        result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
    }
    return result;
}

$(document).ready(function () {
    //Default Action
    $(".tab_content").hide(); //Hide all content
    var tabid = getQueryString()["tab"];

    if (tabid == undefined) { //No tab specified in url, so activate first tab
        $("ul.tabs li:first").addClass("active");
        $(".tab_content:first").show(); //Show first panel
    }
    else { // if there is a specific tab specified in URL, then show that instead
        $("li#tabmenu" + tabid).addClass('active');
        $("div#tab" + tabid).show(); //Show appropriate tab's panel
    }

    //On Click Event
    $("ul.tabs li").click(function () {
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

});

