﻿function CallModal(target) {
	var initialized = $(target).is(':data(dialog)');
	if (initialized) {
		$(target).dialog('open');
	}
	else {
		InitializeModal(target);
	}
};

function InitializeModal(target) {
	var d = $(target).dialog({
		modal: true,
		draggable: true,
		resizable: false,
		closeOnOverlayClick: true,
		width: '650',
		dragStart: function () { DragStart(target); },
		dragStop: function () { DragStop(target); }
	});
};

function DragStart(target) {
	$(target + " iframe").each(function () {
		$container = $(this).parent();
		$('<div class="DraggableIFrameFix"></div>')
		.css({
			opacity: "0.001", zIndex: 100000
		})
		.appendTo($container);
	});
};

function DragStop(target) {
	$("div.DraggableIFrameFix").each(function () { this.parentNode.removeChild(this); });
};
