$(document).ready(function () {

    $(".toolbarPanel").hide();
    $(".toolbarPanel.open").show();
    $(".toolbarActions .arrow a").click(function () { displayToolbar($(this)); return false; });

    $("#SearchForAProperty .Third input").click(function () {

        if ($(this).attr("id") == "ctl00_CblAreas_0") {

            if ($(this).is(":checked")) {
                $("#SearchForAProperty .Third input").attr("checked", false);
                $(this).attr("checked", true);
            }
        }
        else {
            $("#ctl00_CblAreas_0").attr("checked", false);
        }

    });

});

function displayToolbar(anchor) {

    var slideSpeed = 200;

    // link is current open panel
    if (anchor.hasClass("active")) {
        $("#" + anchor.attr("rel")).slideUp(slideSpeed, function() { anchor.removeClass("active"); });
    }
    // link is no open but there is an open panel
    else if ($(".toolbarActions").find(".active").length != 0) {
        $("#" + $(".toolbarActions").find(".active").attr("rel")).slideUp(slideSpeed, function() {
            $(".toolbarActions .arrow a").removeClass("active");
            anchor.addClass("active");
            $("#" + anchor.attr("rel")).slideDown(slideSpeed);
        });
    }
    // there are no open panels
    else {
        $(".toolbarActions .arrow a").removeClass("active");
        anchor.addClass("active");

        // display the appropriate panel
        $(".toolbarPanel").slideUp(slideSpeed);
        $("#" + anchor.attr("rel")).slideDown(slideSpeed);
    }

    return false;
}

