

tusind1.formArea = function(id, expand, className) {

    //Hide instantly
    if( !expand ) {
        document.getElementById(id).style.display = "none";
    }

    className = className || "";

    $(function() {

        if( className.indexOf("no-shortcut") != -1 ) {
            return;
        }

        var $area = $("#" + id), $form = $area.parents("form");
        var $linkHolder = $(".area-links", $form);
        if( !$linkHolder.length ) {
            $linkHolder = $("<div class='area-links'></div>")
            .prependTo($form);
        }

        var title = $area.children("legend").html();
        //$area.children("legend").hide();
        
        var $a = $("<a href='#'></a>").html("<span>" + title + "</span>")
            .appendTo($linkHolder);

        if( expand ) {
            $a.addClass('active');
        }

        $a.click(function(event) {          

            var toggle;
            if( !$a.is(".active") ) {                
                $a.addClass("active");
                toggle = "show";
            } else {                
                $a.removeClass("active");
                toggle = "hide";
            }
            $("#cboxLoadedContent").css("overflow", "hidden");

            $area.animate({height: toggle, paddingTop: toggle, paddingBottom: toggle, marginTop: toggle, marginBottom: toggle},
                {duration: 300, step: function() {
                        $.fn.colorbox.resize();
                }});

           event.preventDefault();
        });
    });
    
}
