
function showLeftGray(id, container) {
	if (container) {
		document.getElementById(container).innerHTML = document.getElementById('LeftGray_'+id).innerHTML;
		document.getElementById(container).style.visibility = 'visible';
		document.getElementById(container+'_bottom').style.visibility = 'visible';
	}
}

function hideLeftGray(container) {
	if (container) {
		document.getElementById(container).style.visibility = 'hidden';
		document.getElementById(container+'_bottom').style.visibility = 'hidden';
		document.getElementById(container).innerHTML = '';
	}
}

var tmp_img_src = '';

function swapImg(img1, img2) {
	if (typeof img2 == "undefined") {
		if (tmp_img_src != '') {
			document.getElementById(img1).src = tmp_img_src;
			tmp_img_src = '';
		}
	} else {
		if (tmp_img_src == '') {
			tmp_img_src = document.getElementById(img1).src;
			document.getElementById(img1).src = document.getElementById(img2).src;
		}
	}
}

function Trim(s) {
	var tmp = new String(s);
	while (tmp.substr(0, 1) == ' ') tmp = tmp.substr(1);
	while (tmp.substr(tmp.length-1) == ' ') tmp = tmp.substr(0, tmp.length-1);
	return tmp;
}

function CheckEmailAddress(a){
	a = Trim(a);
	var re = /^[A-Za-z0-9_\-\.]+@[A-Za-z0-9\-\.]+\.[A-Za-z]+$/;
	if (re.exec(a)) return true;
	else return false;
}

function resetForm(f) {
	for (var e = 0; e < document.forms[f].length; e++) {
		if (document.forms[f].elements[e].type == 'checkbox' || document.forms[f].elements[e].type == 'radio') {
			document.forms[f].elements[e].checked = false;
		}
		else if (document.forms[f].elements[e].type == 'text' || document.forms[f].elements[e].type == 'textarea') {
			document.forms[f].elements[e].value = '';
		}
		else if (document.forms[f].elements[e].type == 'select-one') {
			document.forms[f].elements[e].selectedIndex = 0;
		}
//		else alert(document.forms[f].elements[e].type);
	}
}

function validateContactForm() {
	var bgC1 = '#FFFFFF';
	var bgC2 = '#FFCCCC';
	var formSubmit = 1;

	document.contactForm.contact_Name.value = Trim(document.contactForm.contact_Name.value);
	if (document.contactForm.contact_Name.value == '') {
		document.contactForm.contact_Name.style.backgroundColor = bgC2;
		formSubmit = 0;
	} else {
		document.contactForm.contact_Name.style.backgroundColor = bgC1;
	}

	document.contactForm.contact_Email.value = Trim(document.contactForm.contact_Email.value);
	if (document.contactForm.contact_Email.value == '') {
		document.contactForm.contact_Email.style.backgroundColor = bgC2;
		formSubmit = 0;
	} else {
		if (!CheckEmailAddress(document.contactForm.contact_Email.value)) {
			document.contactForm.contact_Email.style.backgroundColor = bgC2;
			formSubmit = 0;
		} else {
			document.contactForm.contact_Email.style.backgroundColor = bgC1;
		}
	}

	document.contactForm.contact_Nachricht.value = Trim(document.contactForm.contact_Nachricht.value);
	if (document.contactForm.contact_Nachricht.value == '') {
		document.contactForm.contact_Nachricht.style.backgroundColor = bgC2;
		formSubmit = 0;
	} else {
		document.contactForm.contact_Nachricht.style.backgroundColor = bgC1;
	}

	if (formSubmit) {
		document.contactForm.commit.value=1;
		document.contactForm.submit();
	}
}

function openWindow(url, w, h, win, x, y) {
	var win_name = win ? win : 'popup';
	if (! x) x = 0;
	if (! y) y = 0;
	if (! w) w = 600;
	if (! h) h = 600;
	var new_win = window.open(url, win_name, 'left='+x+',top='+y+',width='+w+',height='+h+',menubar=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,status=yes');
	if (new_win) {
		new_win.moveTo(x, y);
		new_win.resizeTo(w, h);
		new_win.focus();
	}
}
