// ++++++++++++++
// + check form +
// ++++++++++++++

function getDomStyle(name)
// Objektname wird beim Aufruf der funktion uebergeben
{
  if (document.getElementById)// Netscape>=6, IE>=5, Opera>=4
  {
  	return (document.getElementById(name).style);
  }
  else if (document.all) //IE >=4
  {
	return (document.all[name].style);
  }
  else if (document.layers) // Netscape 4.xx
  {
    return (document.layers[name]);
  }
}
function getDom(name)
{
  if (document.getElementById)// Netscape>=6, IE>=5, Opera>=4
  {
  	return (document.getElementById(name));
  }
  else if (document.all) // IE>=4
  {
	return (document.all[name]);
  }
  else if (document.layers) // Netscape 4.xx
  {
    return (document.layers[name]);
  }
}

// SetWarningVisible
function SWV(elementName, setVisible) {
	domStyle = getDomStyle(elementName);
	if(domStyle) {
		if(setVisible) {
			domStyle.display = "inline";
		} else {
			domStyle.display = "none";
		}
	}
}
// SetRadioChecked
function SRC(radioName, radioNumber) {
	document.forms['Kundenbefragung'].elements[radioName][radioNumber].checked=true;
}
// CheckRadioButton
function CRB(radioName, radioNumberLower, radioNumberUpper, errorMsg) {
	isChecked = false;
	for(i=radioNumberLower;i<=radioNumberUpper;i++) {
		if(document.forms['Kundenbefragung'].elements[radioName][i].checked) {
			isChecked = true;
			break;
		}
	}
	if(isChecked) {
		SWV(radioName, false);
	} else {
		SWV(radioName, true);
	}
	return isChecked;
}

// +++++++++++++++++++++
// + E-Mail-form-check +
// +++++++++++++++++++++

function chkFieldValue(formObject, fieldName, errorMsg) {
	formField = formObject.elements["EF"+fieldName];
	if(formField) {
		if(!chkFieldValueSilent(formObject, fieldName)) {
			alert(errorMsg);
			formField.focus();
			return false;
		}
	}
	return true;
}

function chkFieldValueSilent(formObject, fieldName) {
	formField = formObject.elements["EF"+fieldName];
	if(formField) {
		fieldValue = formField.value;
		if(fieldValue == "") {
			return false;
		}
		for(i=0; i < 10; i++) {
			if(i == 0) {
				fieldNumber = "";
			} else fieldNumber = "" + i;
			ignoreField = formObject.elements["EFIGNORE"+fieldName+fieldNumber];
			if(ignoreField) {
				if(fieldValue == ignoreField.value) {
					return false;
				}
			}
		}
	}
	return true;
}

function chkPostalCode(formObject, codeFieldName, countryFieldName, canBeEmpty, errorMsg) {
	codeField = formObject.elements["EF"+codeFieldName];
	if(codeField) {
		if(!chkPostalCodeSilent(formObject, codeFieldName, countryFieldName, canBeEmpty)) {
			alert(errorMsg);
			codeField.focus();
			return false;
		}
	}
	return true;
}

function chkPostalCodeSilent(formObject, codeFieldName, countryFieldName, canBeEmpty) {
	codeField = formObject.elements["EF"+codeFieldName];
	countryField = formObject.elements["EF"+countryFieldName];
	if(codeField && countryField) {
		if(canBeEmpty && codeField.value == "") return true;
		if(countryField.value == "DE") {
			if(codeField.value.length < 5 || isNaN(codeField.value)) {
				return false;
			}
		}
	}
	return true;
}

// +++++++++
// + Popup +
// +++++++++

function infoPopUp(URL, Width, Height) {
	infoWin = window.open(URL, "infoPopUp", "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=" + Width + ",height=" + Height);
}
function picPopUp(URL, Width, Height) {
	pictureWin = window.open(URL, "pictureWin", "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+Width+",height="+Height);
}