
if (!window['$hnj'] || !$hnj.registry.included('/scripts/components/relationshipdetailcontainer.js')) { 
$hni.components.relationshipDetailContainer = function (elementId, containerId, callbackUrl, idOfElementToBlock, useOverlay) {
	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 useOverlay = false;

	var isActive = function (instance) {
		return ($hni.components.relationshipDetailContainer._active == instance);
	};

	var loadAndShowContent = function (html) {
		$hnj('#' + contentElementId).html(html);
		contentLoaded = true;
		$hnj('#' + idOfElementToBlock).unblock();
		showContent();
	};

	var showContent = function () {
		if (useOverlay) {
			$hnj('#' + contentElementId).clone().overlayWindow({ fixHeightToContent: true });
			$hni.components.relationshipDetailContainer._active = null;
		}
		else {
			$hnj('#' + containerId).show();
			$hnj('#' + elementId).slideDown(
				speed,
				function () {
					if (typeof (window['Hni']) != 'undefined') {
						Hni.Consumer.Web.UI.LayoutManager.updateLayout(false, true);
					}
					$hnj('#' + closerElementId).fadeIn(250);
				});
		}
	};

	return $hnj.extend(
		base,
		{
			show: function () {
				if (isActive(this)) {
					return;
				}
				if ($hni.components.relationshipDetailContainer._active != null) {
					$hni.components.relationshipDetailContainer._active.hide();
				}
				$hni.components.relationshipDetailContainer._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.relationshipDetailContainer._active = null;
				var me = this;
				$hnj('#' + closerElementId).hide();
				$hnj('#' + elementId).slideUp(
					speed,
					function () {
						if ($hni.components.relationshipDetailContainer._active != me) {
							$hnj('#' + containerId).hide();
							if (typeof (window['Hni']) != 'undefined') {
								Hni.Consumer.Web.UI.LayoutManager.updateLayout(false, true);
							}
						}
					});
			},
			toggle: function () {
				if (!isActive(this)) {
					this.show();
				}
				else {
					this.hide();
				}
			},
			toggleOverlay: function () {
				useOverlay = true;
				this.toggle();
			}
		});
};
$hni.components.relationshipDetailContainer._active;
}
if (window['$hnj']) { $hnj.registry.register('/scripts/components/relationshipdetailcontainer.js', false); };


