﻿$(document).ready(function () {

    //Seperate Purchase Tabs
    $(".products:eq(0)").show();
    $(".productTabs li").click(function (e) {
        e.preventDefault();
        $(".productTabs li").removeClass("selected"); //Remove any "active" class
        $(this).addClass("selected"); //Add "active" class to selected tab
        $(".products").hide().eq($(this).index()).show();

    });


    //Store Information Tabs
    $(".info:eq(0)").show();
    $(".infoTabs li").click(function (e) {
        e.preventDefault();
        $(".infoTabs li").removeClass("selected"); //Remove any "active" class
        $(this).addClass("selected"); //Add "active" class to selected tab
        $(".info").hide().eq($(this).index()).show();

        if ($(".info:eq(2)").is(":visible")) {
            $('.formSectionBottom').show();
            document.title = 'PsychiatryOnline | Institution Subscription and Information Request';
        }
        else {
            $(".formSectionBottom").hide();
            document.title = 'PsychiatryOnline | Institutions and Librarians';
        }
    });

    if ($(".info:eq(2)").is(":visible")) {
        $('.formSectionBottom').show();
    }
    else {
        $(".formSectionBottom").hide();
    }

    $(".moreAccess:eq(0)").show();
    $(".moreTabs li").click(function (e) {
        e.preventDefault();
        $(".moreTabs li").removeClass("selected"); //Remove any "active" class
        $(this).addClass("selected"); //Add "active" class to selected tab
        $(".moreAccess").hide().eq($(this).index()).show();

    });


    //Selects correct tab from URL
    var urlParts = String(window.location).split("?");
    switch (urlParts[1]) {
        case '0':           $(".infoTabs li:eq(0)").trigger('click'); break;
        case '1':           $(".infoTabs li:eq(1)").trigger('click'); break;
        case 'instRequest': $(".infoTabs li:eq(2)").trigger('click'); break;
    }

});
