﻿function ShowMessageToUser(message, messageKind) {
	var messageCss = "MessageToUser";
	if (arguments.length > 1) {
		switch (messageKind) {
			case "Information":
				messageCss = "MessageToUserInformation";
				break;			
		}
	}

	var errorElement = jQuery('<div class="' + messageCss + '"></div>').appendTo(jQuery("body"));
	errorElement.html(message);
	errorElement.bind('click', function () { jQuery(this).stop(true, true).slideUp(400, function () { jQuery(this).remove(); }); });
	errorElement.delay(400).slideDown(400).delay(3000).slideUp(400, function () { jQuery(this).remove(); });
}

var ModalWindowFunctionDelegate = "";

var ModalDialogBackground = null;
var ModalDialogContainer = null;

function OpenModalWindow(url, height, width, functionDelegate) {
	ModalWindowFunctionDelegate = functionDelegate;

	ModalDialogBackground = window.document.createElement("div");
	ModalDialogBackground.className = "DialogBackground";
	ModalDialogBackground.style.zIndex = 500;
	window.document.body.appendChild(ModalDialogBackground);

	ModalDialogContainer = window.document.createElement("div");

	ModalDialogContainer.className = "DialogContainer";
	ModalDialogContainer.style.zIndex = 501;

	var dialog = window.document.createElement("div");
	dialog.className = "Dialog";

	dialog.style.marginLeft = ((width / 2) * -1) + "px";
	dialog.style.marginTop = ((height / 2) * -1) + "px";

	var detailFrame = window.document.createElement("iframe");
	detailFrame.frameBorder = 0;
	detailFrame.scrolling = "no";
	detailFrame.src = url;
	detailFrame.className = "DialogFrame";
	detailFrame.style.height = height + "px";
	detailFrame.style.width = width + "px";

	dialog.appendChild(detailFrame);

	ModalDialogContainer.appendChild(dialog);

	window.document.body.appendChild(ModalDialogContainer);
}

function CloseModalWindow(returnValue) {

	if (ModalDialogBackground != null) {
		window.document.body.removeChild(ModalDialogBackground);

		ModalDialogBackground = null;
	}

	if (ModalDialogContainer != null) {
		window.document.body.removeChild(ModalDialogContainer);

		ModalDialogContainer = null;
	}

	if (ModalWindowFunctionDelegate != null && ModalWindowFunctionDelegate != undefined && ModalWindowFunctionDelegate != "") {
		var localModalWindowFunctionDelegate = ModalWindowFunctionDelegate;
		ModalWindowFunctionDelegate = "";

		if (returnValue == undefined) {
			returnValue = '';
		}

		eval(localModalWindowFunctionDelegate + "('" + returnValue.replace(/'/g, "\\'") + "');");

		/*	Aangepast door HN @ 2009-02-13 AKA Friday the 13e..
		Doen we dit op de oude manier, dan wordt de variabele modalWindowFunctionDelegate continue overschreven ... 
		// modalWindowFunctionDelegate = "";		*/
	}
}

function RegistrationCallback(returnValue) {	
	if (returnValue == "True") {
		ShowMessageToUser("Uw inschrijving is geregistreerd", "Information");
	}
}
