setContainerMargin = function() {
	var container = document.getElementById("alert");
	
	if (container != null) {
		var containerWidth = container.offsetWidth;
		var viewportWidth = document.body.offsetWidth;
		var viewportHeight = document.body.offsetHeight;

		if (containerWidth > viewportWidth) {
			container.style.width = viewportWidth + "px";
			container.style.marginLeft = "0";
		} else {
			container.style.marginLeft = ((viewportWidth - containerWidth) / 10) + "px";
		}
	
		container.style.marginTop = (viewportHeight * 0.3) + "px";
	}

	return;
}

window.onload = setContainerMargin;   // nach Laden der Seite
window.onresize = setContainerMargin; // bei Veränderung des Viewports


/*
 * alert.js - javascript alert replacement v2.0
 *
 * (c) 2009-2010 Naden Badalgogtapeh - http://www.naden.de/blog/javascript-alert
 *
 */
window.alert = function() {
	var D = 2;
	var F = {button_title:"ok",left:-1,top:-1,width:-1,height:-1};
	
	if (arguments.length == 2 && typeof arguments[1] == "object") {
		F = E(arguments[1], F)
	} else {
		if(arguments.length == 3) {
			F = E(arguments[2],F)
		}
	}

	var H = document.getElementById("alert");

	if (H) {
		document.body.removeChild(H)
	}

	H = document.createElement("DIV");
	H.id = H.className = "alert";
	document.body.appendChild(H);
	if (arguments.length == 1 || (arguments.length == 2 && typeof arguments[1] != "string")) {
		arguments = ["",arguments[0]];
	}

	H.innerHTML = (arguments[0] == "" ? "" : '<div class="title">' + arguments[0] + "</div>") + '<div class="body">' + arguments[1] + '</div><div class="button"><a href="" onclick="document.body.removeChild(document.getElementById(\'alert\'));return false;">' + F.button_title + "</a></div>";
	
	var G = A(), C = Math.max(B(arguments[0]), B(arguments[1])) * 6;

	if (F.width == -1) {
		F.width = C;
	}

	if (F.left == -1) {
		F.left = parseInt((G[0] + G[2] - C) / 2);
	}

	if (F.top == -1) {
		F.top = parseInt((G[1] + G[3] - (H.offsetHeight || H.pixelHeight)) / 2);
	}

	H.style.width = F.width + "px";

	if (F.height > 0) {
		H.style.height = F.height + "px";
	}

	H.style.left = F.left + "px";
	H.style.top = F.top + "px";
	H.style.display = "block";

	function E(J,I) {
		for (var K in I) {
			if (K in J) {
				continue;
			}

			J[K] = I[K];
		}

		return J;
	}

	function B(L) {
		var M = L.split("<br />");
		
		if (M.length <= 1) {
			M = L.split("<br>");
		}

		if (M.length <= 1) {
			return L.replace(/<(?:.|\s)*?>/g,"").length;
		}

		var I = 0;
		
		for (var K=0; K < M.length; K++) {
			var J = M[K].replace(/<(?:.|\s)*?>/g,"");

			if (J.length > I) {
				I = J.length;
			}
		}

		return I;
	}

	function A() {
		var J = 0, K = 0, I = 0, L = 0;

		if (typeof window.innerWidth == "number") {
			J = window.innerWidth;
			K = window.innerHeight;
		} else {
			if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)){
				J = document.documentElement.clientWidth;
				K = document.documentElement.clientHeight;
			} else {
				if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
					J = document.body.clientWidth;
					K = document.body.clientHeight;
				}
			}
		}

		if (typeof window.pageYOffset == "number") {
			L = window.pageYOffset;
			I = window.pageXOffset;
		} else {
			if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
				L = document.body.scrollTop;
				I = document.body.scrollLeft;
			} else {
				if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){
					L = document.documentElement.scrollTop;
					I = document.documentElement.scrollLeft;
				}
			}
		}

		return	[I,L,J,K];
	}
};

