// Initialisierung von allen Elementen auf der Seite
function init()
{
	if (!document.getElementsByTagName){ return; }
	var inputs = document.getElementsByTagName("input");

	// loop through all input tags
	for (var i=0; i<inputs.length; i++){

		var input = inputs[i];
		

		if (input.getAttribute("rel") == 'clearField'){
			input.onfocus = function () {if(this.value==this.defaultValue) this.value=''; return false;}
			input.onblur = function () { if(this.value=='') this.value = this.defaultValue; return false;}			
		}
	}
	
	// loop through all anchor tags	
	var anchors = document.getElementsByTagName("a");	
	for (var i=0; i<anchors.length; i++){

		var anchor = anchors[i];		

		if (anchor.getAttribute("rel") == 'closeWindow'){
			anchor.onclick = function () { self.close();}		
			anchor.onmouseover = window.status = '';
		}
		if (anchor.getAttribute("rel") == 'printWindow'){
			anchor.onclick = function () {self.print();}
		}
		if (anchor.getAttribute("rel") == 'addFavorite'){
			anchor.onclick = function () 
			{
				bookmarksite(parent.document.title,parent.location.href);
			}
		}
		if(anchor.getAttribute("rel") == 'popup'){
			anchor.onclick = function()
			{
					window.open(this.href, '' , 'width='+anchor.width+',height='+anchor.height+'toolbar=0,resizable=0');
					return false;
			}
		}
	}	
	
	//loop through all tables and set the row-classes accordingly
	var tables = document.getElementsByTagName("table");
	for (var i=0; i<tables.length; i++){
		
		var table = tables[i];
		if(table.className.search(/imgtext/)==-1)
		{
			var tbody = getChildsByTagName(table, 'tbody')[0];
			if(tbody)
			{
				var trs = getChildsByTagName(tbody, 'tr');
				for(var j=0; j<trs.length; j++)
				{
					tr = trs[j];
					if(!tr.className)
					{
						tr.className = j % 2 == 0 ? 'odd' : 'even';
					}
				}
			}
		}
	}
}
function getChildsByTagName(element, tagName)
{
	var childs = [];
	
	for(var j = 0; j < element.childNodes.length; j++)
	{
		if(element.childNodes[j].nodeName.toLowerCase() == tagName.toLowerCase())
		{
			childs.push(element.childNodes[j]);
		}
	}
	
	return childs;
}
function debugElement(element)
{
	var text = 'Element-Debug:';
	if(element == null)
	{
		text += 'NULL';
	}
	else
	{
		text += '\n '+textElement(element);
		text += '\n----------------------------\nChildren:'
		
		for(i=0; i<element.childNodes.length; i++)
		{
			text += '\n'+i+': '+ textElement(element.childNodes[i]);
		}
	}
	alert(text);
}
function textElement(element)
{
 	return element+': '+element.nodeName+' class:'+element.className;
}
window.onload = init;

//Custom UNITY AG JS-Functions ----------------------------------------------------------------------------------------------
function downloadfile()
{	
	if(document.forms.dl.datei.value!='')
	{	window.open("http://download.unity.de/download/" + document.forms.dl.datei.value);	}
	else
	{	alert('Bitte tragen Sie den Dateinamen ein, der Ihnen mitgeteilt wurde.');	}
	return false;
}

