
if (!window['$hnj'] || !$hnj.registry.included('/scripts/components/inlinereferencescontainer.js')) { 
$hni.components.inlineReferencesContainer = function(elementId, containerId, callbackUrl, idOfElementToBlock) {
    var base = new $hni.components.manager(elementId);
    var contentElementId = elementId + 'Content';
    var closerElementId = elementId + 'Closer';
    var contentLoaded = (!callbackUrl); // if no callback URL, content was preloaded
    var speed = 500;

    var isActive = function(instance) {
        return ($hni.components.inlineReferencesContainer._active == instance);
    };

    var loadAndShowContent = function(html) {
        $hnj('#' + contentElementId).html(html);
        contentLoaded = true;
        $hnj('#' + idOfElementToBlock).unblock();
        showContent();
    };

    var showContent = function() {
        $hnj('#' + containerId).show();
        $hnj('#' + elementId).slideDown(
			speed,
			function() {
			    $hnj('#' + closerElementId).fadeIn(250);
			});
    };

    return $hnj.extend(
		base,
		{
		    show: function() {
		        if (isActive(this)) {
		            return;
		        }
		        if ($hni.components.inlineReferencesContainer._active != null) {
		            $hni.components.inlineReferencesContainer._active.hide();
		        }
		        $hni.components.inlineReferencesContainer._active = this;
		        $hnj('#' + containerId + ',#' + elementId + ',#' + closerElementId).hide();
		        if (contentLoaded) {
		            showContent();
		        }
		        else {
		            $hnj('#' + idOfElementToBlock).block();
		            $hnj.ajax2.getJSONP(
						callbackUrl,
						loadAndShowContent);
		        }
		    },
		    hide: function() {
		        if (!isActive(this)) {
		            return;
		        }
		        $hni.components.inlineReferencesContainer._active = null;
		        var me = this;
		        $hnj('#' + closerElementId).hide();
		        $hnj('#' + elementId).slideUp(
					speed,
					function() {
					    if ($hni.components.inlineReferencesContainer._active != me) {
					        $hnj('#' + containerId).hide();
					    }
					});
		    },
		    toggle: function() {
		        if (!isActive(this)) {
		            this.show();
		        }
		        else {
		            this.hide();
		        }
		    }
		});
};
$hni.components.inlineReferencesContainer._active;

}
if (window['$hnj']) { $hnj.registry.register('/scripts/components/inlinereferencescontainer.js', false); };


