window.onload = initialize; 
function initialize () {
	if (self.init) self.init();
}

function init()
{
	setMaxLength();
}

function setMaxLength()
{
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('maxlength'))
		{
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength()
{
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'toomuch';
	else
		this.relatedElement.className = '';	
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}





function show(id) {
var d = document.getElementById(id);
for (var i = 1; i<=10; i++) {
if (document.getElementById('info'+i)) {document.getElementById('info'+i).style.display='none';}
}
if (d) {d.style.display='block';}
}



function popup(url,hght,wdth){
var attri="height="+hght+","+"width="+wdth+","+"status=no";

fenster=window.open("","",attri);
fenster.moveTo(100,20);
fenster.focus();
fenster.document.open();
with (fenster) {
  document.write("<html><head>");
  document.write("<script type='text/javascript' language='JavaScript'>");
  document.write("function click() { window.close(); } ");
  document.write("document.onmousedown=click ");
  document.write("</script>");
  document.write("<title>click to close</title></head>");
  document.write("<" + "body onblur='window.close()' style='background:url("+ url +")'");
  document.write("marginwidth='0' marginheight='0' leftmargin='0' topmargin='0'>");
  document.write("</body></html>");
  fenster.document.close();
  }
}

function popup1(url) {
 fenster = window.open(url, "fenster1", "width=650,height=600,status=yes,scrollbars=yes,resizable=yes");
 fenster.focus();
}

function galerie_popup(url) {
 fenster = window.open(url, "Hotel", "width=500,height=426,status=yes,scrollbars=yes,resizable=yes");
 fenster.focus();
}
