/* JavaScript-Datei für Possehl Spezialbau */

function mailto(prefix, postfix) {
	if(!postfix) {
		postfix = 'possehl-spezialbau.de';
	}
	location.href= 'mailto:' + prefix + '@' + postfix;
}
function settext(text,field) {
	if (field.value == '') {
		field.value = text;
	}
}
function cleartext(text,field) {
	if (field.value == text) {
		field.value=''
	}
}
// die Funktion tauscht die Bilder und die Linkfarbe
normal1 = new Image();
normal1.src = "/images/button2.jpg";
highlight1 = new Image();
highlight1.src = "/images/hover2.jpg";
active1 = new Image();
active1.src = "/images/active2.jpg";

normal2 = new Image();
normal2.src = "/images/button3.jpg";
highlight2 = new Image();
highlight2.src = "/images/hover3.jpg";
active2 = new Image();
active2.src = "/images/active3.jpg";

normal3 = new Image();
normal3.src = "/images/button4.jpg";
highlight3 = new Image();
highlight3.src = "/images/hover4.jpg";
active3 = new Image();
active3.src = "/images/active4.jpg";

normal4 = new Image();
normal4.src = "/images/button5.jpg";
highlight4 = new Image();
highlight4.src = "/images/hover5.jpg";
active4 = new Image();
active4.src = "/images/active5.jpg";

var maximages = 4;

function exchange (picnr, flag) {
	var picture;
	var linkcolor =  (flag == 1) ? "#000000" : "#006ab4";
	for(var i=1; i<=maximages; i++) {
		if (i==picnr) {
			picture = (flag == 1) ? "active" : "normal";
		} else {
			picture = (flag == 1) ? "highlight" : "normal";
		}
		var newimage = picture + i;
		window.document.images["images" + i].src = eval(newimage + ".src");
	}
	document.getElementById("link" + picnr).style.color = linkcolor;
}
// Funktion, um E-Mail zu verbergen
function openmailurl(prefix, postfix) {
	location.href= 'mailto:' + prefix + '@' + postfix;
}

/* Formulareeingaben pruefen */
function checkForm(formname, werte) {
	var fields = new Array();
	var check = 0;
	var regex=/^[\w,_,\-,.]*$/;
	
	for (var i=0; i<werte.length; i++) {
		fields[i] = document[formname][werte[i]].value;
	}
	
	for (var i=0; i<fields.length; i++) {
		if (fields[i] == "") {
			alert('Sie müssen alle mit * gekennzeichneten Felder ausfüllen!');
			return false;
		} else {
			check++;
		}
	}
	if (check == werte.length) {
		return true;
	} else {
		return false;
	}
}

// Funktion zum Unterbinden von Mehrfachausfuehrungen
var only_once_list = new Array();
function only_once(obj) {
	if(only_once_list[obj.name] == 1) {
		return true;
	}
	if(obj.href) {
		obj.disabled;
		if(obj.style) {
			obj.style.color = "#999999";
			obj.style.textDecoration = "none";
			obj.style.cursor = 'wait';
		}
		return true;
	}
	for(var i = 0; ; i++) {
		if(!obj[i]) { break; }
		if(obj[i].type != 'button' && obj[i].type != 'submit') { continue; }
		if(obj[i].name == 'execonce') {
			obj[i].disabled;
			if(obj[i].style) {
				obj[i].style.backgroundColor = "#CCCCCC";
				obj[i].style.color = "#999999";
				obj[i].style.border = "solid #999999 1px";
			}
		}
	}
	only_once_list[obj.name] = 1;
	return true;
}

// Ein-/Ausklappen der aktiven Navigation
function togglesubmenu(submenu) {
	document.getElementById(submenu).style.display = (document.getElementById(submenu).style.display == "none") ? "block" : "none";
	return false;
}
