
function germanNames(text)
{
	var repl = text;
	repl = repl.replace("Sunday", "Sonntag");
	repl = repl.replace("Monday", "Montag");
	repl = repl.replace("Tuesday", "Dienstag");
	repl = repl.replace("Wednesday", "Mittwoch");
	repl = repl.replace("Thursday", "Donnerstag");
	repl = repl.replace("Friday", "Freitag");
	repl = repl.replace("Saturday", "Samstag");
	return repl;
}
function createHtml(text)
{
	if(text == null)
		return;
		
	var repl = text;
	
	repl = repl.replace(/#-/g, "<");
	repl = repl.replace(/-#/g, ">");
		
	return repl;
}
function createCoded(text)
{
	if(text == null)
		return;
		
	var repl = text;
	
	repl = repl.replace(/</g, "#-");
	repl = repl.replace(/>/g, "-#");
		
	return repl;
}
function createContainer()
{
	var container = createDivElement("container");
	return container;
}
function createTextDiv()
{
	var div = createDivElement();
	setDivAttribute(div, "class", "text");
	return div;
}
function write(div, text)
{
	if(div == null)
		return;
	div.innerHTML = text;
}
function createDivElement(classname)
{
	var div = document.createElement("div");
	setDivAttribute(div, "class", classname);
	return div;
}
function setDivAttribute(div, attribute, attributeValue)
{
	if(div == null)
		return;
	div.setAttribute(attribute, attributeValue);
}
function clearDiv(div)
{
	if(div == null)
		return;
	var children = div.childNodes;
	if(children == null)
		return;
	if(children.length == 0)
		return;
	while(children.length > 0)
		div.removeChild(children[children.length-1]);
}
function getElementById(id)
{
	return document.getElementById(id);
}
function getInnerTextFromTag(parent, tag)
{
	var tagNode = parent.getElementsByTagName(tag);
	
	if(tagNode == null || tagNode.length == 0)
		return "";		
	
	var node = tagNode[0];
	if(node.firstChild == null)
		return "";
	if(node.firstChild.nodeValue==null)
		return "";
		
	return node.firstChild.nodeValue;	
}

var nbrOfOpenDivWnd = 0;
function OpenDivWindow(innerHTML, widthPrc)
{
	//EnvelopBody();
	var left = (100-widthPrc)/2;
	var top = 10;
	var id = "div"+nbrOfOpenDivWnd;
	var div = document.createElement("div");
	div.setAttribute("id", id);
	div.setAttribute("style", "position:absolute; left:" + (left+nbrOfOpenDivWnd) + "%; top:" + (top+nbrOfOpenDivWnd) + "%; width:" + widthPrc + "%; height:60%; border:solid 2px gray; font:normal 10pt sans-serif; background-color:white;opacity:1.0; padding:10px; overflow:auto; ");
	div.innerHTML = "<div style='position:absolute; left:94%; top:1%; width:5%; text-align:right; cursor:pointer;' onclick='onDivWindowCloseClick(\"" + id + "\");'>x</div>" + innerHTML;
	document.body.appendChild(div);
	
	nbrOfOpenDivWnd++;
	return id;
}
function onDivWindowCloseClick(id)
{
	var div = document.getElementById(id);
	if(div != null)
	{
		document.body.removeChild(div);
		nbrOfOpenDivWnd--;
	}
	/*if(nbrOfOpenDivWnd == 0)
	{
		document.body.removeChild(document.getElementById("envelopdiv"));
	}*/	
}
function CloseAllWindows()
{
	while(nbrOfOpenDivWnd > 0)
	{
		onDivWindowCloseClick("div" + (nbrOfOpenDivWnd-1));
	}
}
