	/**
	 * Popup zum Debuggen
	 */
	var ID_POPUP = 'messageBox';
	var ID_POPUP_CONTENT = 'popup_content';
	var ID_POPUP_BACKGROUND = 'popup_bg';
	var ID_HTML_POPUP = ID_POPUP+"_error";
	
	var contentBackground = "images/popup/bg_convex_02.png";
	var contentBackgroundError = "images/popup/bg_convex_01.png";
	var contentBgColorError = "";
	var closeIcon = "images/popup/close01.png";
	

	var begin = 
		"<div id=\""+ID_HTML_POPUP+"\" style=\"display:none;z-index:112;position:fixed;\">"+
			"<div style=\"z-index:113;position:absolute;top:3px;right:3px;\">"+
				"<a href=\"javascript:history.back();\"><img src=\""+closeIcon+"\" border=\"0\" title=\"Fenster schlie&szlig;en\" /></a>"+
			"</div>"+
			'<table id="frame" width="*" height="*" border="0" bordercolor="black" cellspacing="0" cellpadding="0">'+
				"<tr>"+
					"<td background=\"images/popup/corner01_top_left_2x2.png\" width=\"2\" height=\"2\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
					"<td background=\"images/popup/corner01_top_1x2.png\" height=\"2\" width=\"*\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
					"<td background=\"images/popup/corner01_top_right_2x2.png\" width=\"2\" height=\"2\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
				"</tr>"+
				"<tr>"+
					"<td background=\"images/popup/corner01_left_2x1.png\" width=\"2\" height=\"*\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
					"<td align=\"center\" color=\"blue\" bgcolor=\""+contentBgColorError+"\" background=\""+contentBackgroundError+"\">"+
						"<table border=\"0\">"+
							"<tr>"+
								"<td style=\"color:blue;\">";
	var end = 		"</td>"+
							"</tr>"+
						"</table>"+
					"</td>"+
					"<td background=\"images/popup/corner01_right_2x1.png\" width=\"2\" height=\"*\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
				"</tr>"+
				"<tr>"+
					"<td background=\"images/popup/corner01_bottom_left_2x2.png\" width=\"2\" height=\"2\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
					"<td background=\"images/popup/corner01_bottom_1x2.png\" height=\"2\" width=\"*\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
					"<td background=\"images/popup/corner01_bottom_right_2x2.png\" width=\"2\" height=\"2\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
				"</tr>"+
			"</table>"+
		"</div>";
	
	var div = 
		"<div id=\""+ID_POPUP+"\" style=\"display:none;z-index:110;position:absolute;max-width:600px;max-height:600px;overflow:auto;\">"+
			"<div style=\"z-index:111;position:absolute;top:3px;right:3px;margin:0;padding:0;\">"+
				"<a href=\"javascript:closePopup();\"><img src=\""+closeIcon+"\" border=\"0\" title=\"Fenster schlie&szlig;en\" /></a>"+
			"</div>"+
			'<table id="frame" width="*" height="*" border="0" cellspacing="0" cellpadding="0">'+
				"<tr>"+
					'<td style="font-size:0px;padding:0;margin:0;width:2px;height:2px;background: transparent url(images/popup/corner01_top_left_2x2.png) no-repeat;"><img src="images/popup/spacer.png" border="0" /></td>'+
					'<td style="font-size:0px;padding:0;margin:0;height:2px;background: transparent url(images/popup/corner01_top_1x2.png) repeat-x;" width="*"><img src="images/popup/spacer.png" border="0" /></td>'+
					'<td style="font-size:0px;padding:0;margin:0;width:2px;height:2px;background: transparent url(images/popup/corner01_top_right_2x2.png) no-repeat;"><img src="images/popup/spacer.png" border="0" /></td>'+
				"</tr>"+
				'<tr>'+
					"<td background=\"images/popup/corner01_left_2x1.png\" width=\"2\" height=\"*\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
					'<td  id="'+ID_POPUP_BACKGROUND+'" align="center" background="'+contentBackground+'">'+
						"<table border=\"0\">"+
							"<tr>"+
								"<td style=\"color:blue;\">"+
									"<pre id=\""+ID_POPUP_CONTENT+"\">default</pre>"+
								"</td>"+
							"</tr>"+
						"</table>"+
					"</td>"+
					"<td background=\"images/popup/corner01_right_2x1.png\" width=\"2\" height=\"*\"><img src=\"images/popup/spacer.png\" border=\"0\" /></td>"+
				"</tr>"+
				"<tr>"+
					'<td style="font-size:0px;padding:0;margin:0;width:2px;height:2px;background: transparent url(images/popup/corner01_bottom_left_2x2.png) no-repeat;"><img src="images/popup/spacer.png" border="0" /></td>'+
					'<td style="font-size:0px;padding:0;margin:0;height:2px;background: transparent url(images/popup/corner01_bottom_1x2.png) repeat-x;" width="*"><img src="images/popup/spacer.png" border="0" /></td>'+
					'<td style="font-size:0px;padding:0;margin:0;width:2px;height:2px;background: transparent url(images/popup/corner01_bottom_right_2x2.png) no-repeat;"><img src="images/popup/spacer.png" border="0" /></td>'+
				"</tr>"+
			"</table>"+
		"</div>";
		
	document.write(div);

	var xPos = 400;
	var yPos = 30;
	
	function myPopup(v, content) {
		myPopup(v, content, xPos+30, yPos);
	}
	
	var interval = null;
	function myPopupInterval(message, x, y, timeInMs) {
		myPopup(true, message, x, y);
		
		interval = window.setInterval('closePopup()', timeInMs);
	}
	
	function myPopup(v, message, x, y) {
		if(v) {
			var popup = document.getElementById(ID_POPUP);
			var content = document.getElementById(ID_POPUP_CONTENT);
			content.firstChild.data = message;
			popup.style.left = x+'px';
			popup.style.top = y+'px';
			popup.style.display = "block";
		} else
			document.getElementById("messageBox").style.display = "none";
	}

	
	function myPopupHTML(v, message) {
		removePopup(ID_HTML_POPUP);
		if(v) {
			//alert(cutPageFrame(message));
			document.write(begin+cutPageFrame(message)+end);
			var popup = document.getElementById(ID_HTML_POPUP);
			popup.style.left = '50px';
			popup.style.top = '50px';
			popup.style.display = "block";
		}
	}
	
	function cutPageFrame(message) {
		var iB = message.indexOf("<body");
		if(iB<0) iB = message.indexOf("<BODY");
		if(iB<0) return message;
		iB = message.indexOf(">",iB+5);
		message = message.substring(iB+1, message.length);
		var iE = message.indexOf("</body");
		if(iE<0) iE = message.indexOf("</BODY");
		if(iE<0) return message;
		return message.substring(0, iE);
	}
	
	function removePopup(id) {
		var popup = document.getElementById(id);
		if(popup) {
			popup.style.display = "none";
			popup.parentNode.removeChild(popup);
		}
	}
	
	function closePopup() {
		window.clearInterval(interval);
		myPopup(false, "");
	}
	
	
	/**
	 * Gibt den Inhalt der Variablen v (Object|Array|einfacher Typ) in einem Popup-'Fenster' aus.
	 */
	function displayVar(v, x, y) {
		myPopup(true, varToString(v), x, y);
	}
	
	function displayVarRestricted(v, x, y, attrToIgnore) {
		myPopup(true, varToStringRestricted(v, null, attrToIgnore), x, y);
	}
		
	function varToStringRestricted(v, prefix, ignore) {
		if(ignore == null) ignore = new Object();
		if(prefix == null) prefix = "";
		var res = "";
		t = typeof v;
		
		switch(t) {
			case 'object' : 
				if(v) {
					var prefixN = prefix+"  ";
					if(v.length) {
						res += "[\n";
						for(var i=0; i<v.length; ++i) {
							if(i > 0) res += ",\n";
							res += prefixN+i+" : "+varToStringRestricted(v[i], prefixN, ignore);
						}
						res += "\n"+prefix+"]";
					} else {
						res += "{\n";
						for(p in v) {
							if(ignore[p]) res += prefixN+p+" -> "+(typeof v[p])+"\n";
							else res += prefixN+p+" -> "+varToStringRestricted(v[p], prefixN, ignore)+"\n";
							//if(ignore.alert[p]) alert(p+" -> "+v[p]);
						}
						res += prefix+"}";
					}
					return res;
				}
				return t+"{empty}";
			case 'string' : return "'"+v+"'"; 
			case 'function' :
			case 'undefined' : return t;
			default : return+""+v;
		}
	}
		
	function varToString(v, prefix) {
		if(prefix == null) prefix = "";
		var res = "";
		t = typeof v;
		
		switch(t) {
			case 'object' : 
				if(v) {
					var prefixN = prefix+"  ";
					if(v.length) {
						res += "[\n";
						for(var i=0; i<v.length; ++i) {
							if(i > 0) res += ",\n";
							res += prefixN+i+" : "+varToString(v[i], prefixN);
						}
						res += "\n"+prefix+"]";
					} else {
						res += "{\n";
						for(p in v) {
							res += prefixN+p+" -> "+varToString(v[p], prefixN)+"\n";
						}
						res += prefix+"}";
					}
					return res;
				}
				return t+"{empty}";
			case 'string' : return "'"+v+"'"; 
			case 'function' :
			case 'undefined' : return t;
			default : return+""+v;
		}
	}


