$(document).ready(function() {
    // hides all the tabs if js is enabled
    $("#tabcontainer").addClass("dyn");
    var loc = window.location.hash.replace('#', '');
    var current = null;
    var currentLink = null;
    var toclinks = $("#infotoc a");
    for (var i = 0; i < toclinks.length; i++) {
        if ($(toclinks[i]).attr("href").replace(/.*#/, '') == loc) {
            currentLink = toclinks[i];
        }
        $(toclinks[i]).bind("click", getsection);
    }

    if ((loc == "contactus") || (loc == "privacy") || (loc == "general")) {
        currentLink = toclinks[3];
        displaysection(currentLink);
        window.location = "#" + loc;
    } else {
        if (!currentLink) {
            currentLink = toclinks[0];
        }
        displaysection(currentLink);
    }

    function getsection(event) {
        var t = event.target;
        displaysection(t);
        event.preventDefault();
    }

    function displaysection(o) {
        var targetname = $(o).attr("href").replace(/.*#/, '');
        var section = $("#" + targetname.toString());
        if (current != null) {
            $(current).removeClass("displaytab");
            $(currentLink).parent().parent().removeClass("selected");
        }
        $(section).addClass("displaytab");
        $(o).parent().parent().addClass("selected");
        current = section;
        currentLink = o;
    }
});

