﻿$(document).ready(
    function () {


        var menuId = $.cookie("userGroup");
		var menus = new Array();
        menus[1] = "patients";
        menus[2] = "gp";
        var menuSelected = menus[menuId];
        var menu = $("#menu li");
		
        if (menuId == null) {
            // Set first menu item as default menu to show.
            menuId = 1;
        }

        if (menuId == 2) {
			$("#gp").addClass("selected");
            $("div#leftBar span ul li ul li:nth-child(9) a").css("background-image", "url('./images/tabOrg.png')");
            $("div#leftBar span ul li ul li:nth-child(9) a").css("border-radius", "5px");
        }
		else{
			$("#patients").addClass("selected");
		}
   
       

        // Set current selected menu font to bold.
        $("#" + menuSelected).css("font-weight", "bold");

        // Adjust siteBody height w.r.t. leftBar.
        var leftBar = $("#leftBar");
        var siteBody = $("#siteBody");

        if (leftBar.outerHeight() > (siteBody.outerHeight() - 60)) {
            siteBody.height((leftBar.outerHeight() + 60));
        }

        // Mouse click event.
        menu.click(
            function () {
                menuId = menus.indexOf($(this).attr("id"));
                $.cookie("userGroup", menuId, { path: '/' });

                // Set previous selected menu font to normal.
                $("#" + menuSelected).css("font-weight", "normal");
				$("#" + menuSelected).find("a").css("color", "inherit");

                menuSelected = $(this).attr("id");

                // Set current selected menu font to bold.
                $(this).css("font-weight", "bold");

            }

	    );
    }
);
