function switch_display() {
	var elements = switch_display.arguments;
	for (i=0; i<elements.length; i++) {
		if (document.getElementById(elements[i]).style.display=='none') {
			document.getElementById(elements[i]).style.display='inline';
		} else {
			document.getElementById(elements[i]).style.display='none';
		}
	}
}

var txt_anrede 		='Anrede';
var msg_anrede 		='- Bitte wählen Sie eine Anrede aus.\n';
var txt_pflicht 	='... bitte ausfüllen';
var txt_pflicht_nr 	='...Nr';
var txt_pflicht_plz ='...PLZ';
var msg_vorname		='- Bitte geben Sie Ihren Vorname an.\n';
var msg_nachname	='- Bitte geben Sie Ihren Nachnamen an.\n';
var msg_strasse		='- Bitte geben Sie Ihre Straße an.\n';
var msg_nummer		='- Bitte geben Sie Ihre Hausnummer an.\n';
var msg_plz			='- Bitte geben Sie Ihre Postleitzahl an.\n';
var msg_ort			='- Bitte geben Sie Ihren Wohnort an.\n';
var msg_land		='- Bitte geben Sie Ihr Land an.\n';
var msg_email		='- Bitte geben Sie Ihre Email Adresse an.\n';
var msg_mustemail	=' muss eine E-Mail-Adresse enthalten.\n';
var msg_mustzahl	=' muss eine Zahl enthalten.\n';
var msg_zahl		=' muss eine Zahl zwischen ';
var msg_und			=' und ';
var msg_enthalten	='enthalten';
var msg_benoetigt	=' wird benötigt.\n';
var msg_error		='Die folgenden Fehler sind aufgetreten:\n';
var msg_produkt		='- Bitte wählen Sie einen Newsletter aus.\n';

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function remove_whitespace(item) {
 if (item.value.charAt((item.value.length-1)) == ' ') {
  item.value = item.value.substring(0, (item.value.length - 1));
 }
}

function onFocusClearDefault( thisValue, defaultValue )
{
	if ( thisValue == defaultValue )
	{
		return '';
	}
	return thisValue;
}

function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() 
{ //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	// insert:begin - added to check field "anrede" for presence
	if (document.anmeldung.anrede.value == txt_anrede) {
				errors+=msg_anrede;
	}
	if (document.anmeldung.vorname.value == txt_pflicht) {
				errors+=msg_vorname;
	}
	if (document.anmeldung.nachname.value == txt_pflicht) {
				errors+=msg_nachname;
	}
	if (document.anmeldung.land.value == txt_pflicht) {
				errors+=msg_land;
	}
	if (document.anmeldung.email.value == txt_pflicht) {
				errors+=msg_email;
	}
	// insert:end
	for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+msg_mustemail;
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+msg_mustzahl;
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+msg_zahl+min+msg_und+max+msg_enthalten;
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+msg_benoetigt; }
	}
	// insert:begin - added to check if any newsletter is selected
	for(var i = 1; i < 7; i++) {
		var product_id = "p" + i;
		alert(product_id);
		if(document.getElementById(product_id).checked == true) {
			sel = true;
			break;
		}
	}
	if (!sel) errors+=msg_produkt;
	// insert:end
  if (errors) alert(msg_error+errors);
  document.MM_returnValue = (errors == '');
}
