﻿//---------------------------------------------------------------------------------------------------------------------------------
//-- Jazzy drop-downs
//---------------------------------------------------------------------------------------------------------------------------------

$(document).ready(function () {
    $('dl.dropdown dt a').click(function () {
        $("dl.dropdown dt a").removeClass("selected");

        var toggleMenu = $(this).parent().parent().find('dd ul');

        $(toggleMenu).toggle();

        $('dl.dropdown dd ul').not(toggleMenu).hide();

        if (toggleMenu.css("display") == "none") {
            $(this).removeClass("selected");
        }
        else {
            $(this).addClass("selected");
        }
    });
    $("dl.dropdown dd ul li a").click(function () {
        $("dl.dropdown dd ul").hide();
        $("dl.dropdown dt a").removeClass("selected");
    });
    $(document).bind('click', function (e) {
        var $clicked = $(e.target);
        if (!$clicked.parents().hasClass("dropdown")) {
            $("dl.dropdown dd ul").hide();
            $("dl.dropdown dt a").removeClass("selected");
        }
    });
});

//---------------------------------------------------------------------------------------------------------------------------------
//-- Required to make the MiddleColumn fluid
//---------------------------------------------------------------------------------------------------------------------------------

function resizeElements() {
    // find out the width of the page
    var pageWidth = $('div.MainContentHolder').width();
    // minus the sidebar and margin width
    var middleWidth = pageWidth - '220';
    // apply the new width to the middle column

    // hack to deal with the Countec padding
    if ($('body').hasClass('countec'))
    {
       middleWidth = middleWidth - '10';
    }

    $('div.MiddleColumn').css('width', middleWidth);
}

$(document).ready(function () {
    resizeElements();
    $(window).resize(resizeElements);
});


