﻿$(document).ready(function()
{
    setBackgroundColor();
    disableLinkToHome();
    addEllipsisToShortAnswer();
    registerEvents();

    function setBackgroundColor()
    {
        $(document.body).css("background", "white"); // Need to override shared styles.
    }

    function disableLinkToHome()
    {
        $("#GoToHomeLink")[0].removeAttribute("title");
        $("#GoToHomeLink")[0].removeAttribute("href");
        $("#GoToHomeLink").click(function(e)
        {
            e.preventDefault();
        });
    }

    function addEllipsisToShortAnswer()
    {
        $("#Faq dd div.shortAnswer").ellipsis(); // Workaround for FF.
    }

    function registerEvents()
    {
        registerQuestionClickEvent();
        registerExpandAllClickEvent();
        registerHideAllClickEvent();
        registerContactUsClickEvent();

        function registerQuestionClickEvent()
        {
            $("dt a").click(function(e)
            {
                e.preventDefault();

                $(this).toggleClass("arrowExpand");
                $(this).parent().next().children(".fullAnswer").toggle();
                $(this).parent().next().children(".shortAnswer").toggle();
            });
        }

        function registerExpandAllClickEvent()
        {
            $("#ExpandAll").click(function(e)
            {
                $("dt a").addClass("arrowExpand");
                $(".shortAnswer").hide();
                $(".fullAnswer").show();
            });
        }

        function registerHideAllClickEvent()
        {
            $("#HideAll").click(function(e)
            {
                $("dt a").removeClass("arrowExpand");
                $(".fullAnswer").hide();
                $(".shortAnswer").show();
            });
        }

        function registerContactUsClickEvent()
        {
            ContactUsModal.RegisterLink(".contactUs");
        }
    }
});