function checkFields(names) {
	var ok = true;
	for(var i = 0; i < names.length; i++) {
		fields = document.getElementsByName(names[i]);
		for(var j = 0; j < fields.length; j++) {
			field = fields[j];
			value = field.value;
			if(!value || value == '') {
				field.style.borderColor = 'red';
				ok = false;
			}
		}
	}
	if(ok) {
		return true;
	} else {
		alert('Eingaben unvollständig!');
		return false;
	}
}

function openCenteredWindow(url, name, style, wndwidth, wndheight) {
	window.name = 'parentWindow';
	wndleft = Math.floor((screen.width - wndwidth) / 2);
	wndtop = Math.floor((screen.height - wndheight) / 2);
	window.open(url, name, 'left=' + wndleft + ',top=' + wndtop + ',width=' + wndwidth + ',height=' + wndheight + ',' + style);
}

function urlencode(str) {
	var encoded = "";
	for (i = 0; i < str.length; i++) {
		if (str.charAt(i) == " ") {
			encoded += "+";
		} else {
			encoded += str.charAt(i);
		}
	}
	return escape(encoded);
}

function addScrollBehaviour(element, direction) {
	alert(crossGetElementHeight(element));
}

function crossGetElementHeight(element) {
	if(crossClientIsIE()) {
		return element.style.pixelHeight;
	} else {
		return element.offsetHeight;
	}
}

function crossClientIsIE() {
	return document.all && true;
}

function ieAnalyseElement(element) {
	output = window.open("", element.tagName, "width=680,height=600,resizable,scrollbars=yes");
	output.document.write('<html><body>');

	output.document.write('<table border="1">');
	output.document.write('<tr><th>Name</th><th>Value</th></tr>');
	attrs = element.attributes;
	for(i = 0; i < attrs.length; i++) {
		output.document.write('<tr><td>' + attrs[i].name + '</td><td>' + attrs[i].value + '</td></tr>');
	}
	output.document.write('</table>');

	output.document.close('</body></html>');
}
