function $(id){
	return document.getElementById(id);
}

function init(){
	setTopNavigation();
	zebra();
	try{
		onLoad();
	}catch(e){ 
		//ignore it 
	}
}

function setTopNavigation(){
	var legends = document.getElementsByTagName("legend");
	for (i = 0; i < legends.length; i++) {
		var legend = legends[i];
		if (legend.parentNode.getAttributeNode("class").value == "section") {
			
			var name = document.createAttribute("id");
			name.nodeValue = "section_"+i;
			legend.setAttributeNode(name)
		
			var navi = document.getElementById("navi-top");
			
			var newA = document.createElement("a");
			var newAText = document.createTextNode(legend.firstChild.data);
			newA.appendChild(newAText);
			
			var href = document.createAttribute("href");
			href.nodeValue = "#section_"+i;
			newA.setAttributeNode(href);
			navi.appendChild(newA);
		}
	}
}

function getXmlhttp(){
	var xmlHttp = false;
	// Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof(XMLHttpRequest) != 'undefined') {
	    xmlHttp = new XMLHttpRequest();
	}
	if (!xmlHttp) {
	    // Internet Explorer 6 und ?lter
	    try {
	        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch(e) {
	        try {
	            xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch(e) {
	            xmlHttp  = false;
	        }
	    }
	}
	return xmlHttp;
}

var soapResult = false;
function executeUrl(src, func){
	var xmlHttp = getXmlhttp();
	
	if (xmlHttp) {
	    xmlHttp.open('HEAD', src);
	    xmlHttp.onreadystatechange = function () {
	        if (xmlHttp.readyState == 4) {
	            func(xmlHttp.getResponseHeader('result'));
	        }
	    };
	    xmlHttp.send(null);
	}
}

function popup(src, name) {
	frame = $("popupFrame");
	window.frames["popupFrame"].location.href = src;
	window.frames["popupFrame"].name = name;
	$("popup").style.visibility = "visible";
}

function popupForm(obj, src, name) {
	$("popup").style.visibility = "visible";
	$("popup").getElementsByTagName("iframe")[0].name = name;
	form(obj).target="popupFrame";
	form(obj).action = src;
	form(obj).submit();
	return false;
}

function closePopup() {
	$("popup").style.visibility = "hidden";
}

function zebra() {
	var tables = document.getElementsByTagName("table");
	for (i = 0; i < tables.length; i++) {
		var table = tables[i];
		if (table.getAttribute("zebra")) {
			if(table.getElementsByTagName("tbody")){
				body=table.getElementsByTagName("tbody")[0];
			}else{
				body=table;
			}
			rows = body.getElementsByTagName("tr");
			for (u = 1; u < rows.length; u = u+2) {
				rows[u].style.backgroundColor = "#DCDCDC";
			}
		}
	}
}

function getNestingObject(obj, nestedTag){
	nObj = obj.parentNode;

	while (nObj.nodeName != nestedTag) {
		nObj = nObj.parentNode;
	}
	return nObj;
}

function doOp(obj, op) {
	form(obj).op.value = op;
	form(obj).submit();
}

function form(obj){
	return getNestingObject(obj, 'FORM');
}


function setPopupDimension(){
	top.document.getElementById('popup').getElementsByTagName('IFRAME')[0].style.width = f_width;
	top.document.getElementById('popup').style.width=f_width;
}

function initPopup(){
	setPopupDimension();
	zebra();
}

