﻿(function () {

    //    function ModifyService() {
    //        location.href = "AccountModification.aspx";
    //        return false;
    //    }

    //    function updateMenu(id) {
    //        $("ul.menu>li>ul>li.filter").removeClass("side_menu_selected");
    //        $("#filter_" + id).addClass("side_menu_selected");
    //    }

    //    function displayPanel(id) {
    //        $("div#AccountInfo").hide();
    //        $("div#ReportSettings").hide();
    //        $("div#Preferences").hide();

    //        if (id === "0") {
    //            $("div#AccountInfo").show();
    //        }
    //        else if (id === "1") {
    //            $("div#ReportSettings").show();
    //        }
    //        else if (id === "2") {
    //            $("div#Preferences").show();
    //        }
    //    }

    //    function hashListener(newLocation, historyData) {
    //        if (newLocation.length > 0) {
    //            var hashlets = [];
    //            if (newLocation.length > 0) {
    //                var temp = newLocation.split(":");
    //                hashlets[temp[0]] = parseInt(temp[1]) - 1;

    //                $("div#side_menu_options li#filter_" + hashlets["section"] + ">a").trigger("click", [true]);
    //            }
    //        } else {
    //            $("div#side_menu_options li#filter_0>a").trigger("click", [true]);
    //        }
    //    }
    //    function BindToolTipPersistent(id, txtId) {
    //        //this one shows up on left
    //        $(id).hover(function (e) {
    //            $(id).append("<div id='tooltip2'>" + $(txtId).html() + "</div>");
    //            $("#tooltip2").css("left", ($(id).position().left - $("#tooltip2").width() - 5) + "px").fadeIn("fast");
    //        },
    //        function () { $("#tooltip2").remove(); });
    //    };

    $(document).ready(function () {
        //check for page and set selected
        var url = window.location.href.toLowerCase();
        var selectedPage = '';

        if (url.indexOf("default.aspx") > -1) {
            $(".home_hv").css("display", "block");
            selectedPage = 'home';
        }
        else if (url.indexOf("doctor.aspx") > -1) {
            $(".doctor_hv").css("display", "block");
            selectedPage = 'doctor';
        }
        else if (url.indexOf("office.aspx") > -1) {
            $(".office_hv").css("display", "block");
            selectedPage = 'office';
        }
        else if (url.indexOf("services.aspx") > -1) {
            $(".services_hv").css("display", "block");
            selectedPage = 'services';
        }
        else if (url.indexOf("newpatient.aspx") > -1) {
            $(".patient_hv").css("display", "block");
            selectedPage = 'patient';
        }
        else if (url.indexOf("contact.aspx") > -1) {
            $(".contact_hv").css("display", "block");
            selectedPage = 'contact';
        }


        //various event handlers
//        $(".home").hover(
//            function () { $(".home_hv").css("display", "block"); },
//            function () { if (selectedPage == 'home') return; $(".home_hv").hide(); }
//        );
        $(".home").click(function () {
            location.href = "Default.aspx";
        });

//        $(".doctor").hover(
//            function () { $(".doctor_hv").css("display", "block"); },
//            function () { if (selectedPage == 'doctor') return; $(".doctor_hv").hide(); }
//        );
        $(".doctor").click(function () {
            location.href = "Doctor.aspx";
        });

//        $(".office").hover(
//            function () { $(".office_hv").css("display", "block"); },
//            function () { if (selectedPage == 'office') return; $(".office_hv").hide(); }
//        );
        $(".office").click(function () {
            location.href = "Office.aspx";
        });

//        $(".services").hover(
//            function () { $(".services_hv").css("display", "block"); },
//            function () { if (selectedPage == 'services') return; $(".services_hv").hide(); }
//        );
        $(".services").click(function () {
            location.href = "Services.aspx";
        });

//        $(".patient").hover(
//            function () { $(".patient_hv").css("display", "block"); },
//            function () { if (selectedPage == 'patient') return; $(".patient_hv").hide(); }
//        );
        $(".patient").click(function () {
            location.href = "NewPatient.aspx";
        });

//        $(".contact").hover(
//            function () { $(".contact_hv").css("display", "block"); },
//            function () { if (selectedPage == 'contact') return; $(".contact_hv").hide(); }
//        );
        $(".contact").click(function () {
            location.href = "Contact.aspx";
        });

        //        //display default
        //        var id = $.query.get('fid'); //filterid
        //        id += ""; //converts to string

        //        firstid = $("ul.menu>li>ul>li:first").attr("id").replace("filter_", "");

        //        if (id === null || typeof id === 'undefined' || id === '') id = firstid;
        //        updateMenu(id)
        //        displayPanel(id);

        //        $("ul.menu>li>ul>li.filter>a").click(function (e, trigger) {
        //            var id = $(this).parent().attr("id").replace("filter_", "");
        //            updateMenu(id)
        //            displayPanel(id);

        //            if (!trigger) {

        //                //history, when active
        //                id = parseInt(id) + 1;
        //                SAAS.Components.History.add("section:" + id + "", { message: "hello" });
        //            }

        //            return false;
        //        });

        //        BindToolTipPersistent('.time_remaining', "#hep_time_remaining");
        //        SAAS.Components.History.init(hashListener);
    });

})();

