
function spendenlinkAktualisieren(id_area) {
	new Ajax.Request('_getobjectcount.php?id_area='+id_area, {
	  method: 'get',
	  onSuccess: function(transport) {
			var feld = $('spendenlink');
			feld.show();
	    feld.update(transport.responseText);
	  }
	});
}

function objectReserve(id_feld, id_area, id_object) {
	new Ajax.Request('_getobject.php?action=reserve&id_feld='+id_feld+'&id_area='+id_area+'&id_object='+id_object, {
	  method: 'get',
	  onSuccess: function(transport) {
			var feld = $(id_feld);
	    feld.update(transport.responseText);
	    spendenlinkAktualisieren(id_area);
	  }
	});
}
function objectFree(id_feld, id_area, id_object) {
	new Ajax.Request('_getobject.php?action=free&id_feld='+id_feld+'&id_area='+id_area+'&id_object='+id_object, {
	  method: 'get',
	  onSuccess: function(transport) {
			var feld = $(id_feld);
	    feld.update(transport.responseText);
	    spendenlinkAktualisieren(id_area);
	  }
	});
}

function FensterOeffnen (Adresse) {
  MeinFenster = window.open(Adresse, "Zweitfenster", "width=1050, height=780, status=no, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, resizable=no");
  MeinFenster.focus();
}

function editText(idText, idLanguage, notags) {
	adresse = "_edit.php?idText=" + idText + "&idLanguage=" + idLanguage + "&notags=" + notags;
  MeinFenster = window.open(adresse, "Editorfenster", "width=1050, height=700, status=no, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, resizable=no");
  MeinFenster.focus();
}

function isEMailValid(s) {
  var a = false;
  var res = false;
  if (typeof(RegExp) == 'function') {
    var b = new RegExp('abc');
    if (b.test('abc') == true) {
      a = true;
    }
  }
  
  if (a == true) {
    reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$');
    res = (reg.test(s));
  } else {
    res = (s.search('@') >= 1 && s.lastIndexOf('.') > s.search('@') && s.lastIndexOf('.') >= s.length-5)
  }
  return(res);
} 

function _chkSpendenFormular() {
	return true;
}

function chkSpendenFormular() {
  var retCode = true;
	if (document.SpendenFormular.telefon.value == "") {
  	document.SpendenFormular.telefon.style.backgroundColor="#ffff99";
    document.SpendenFormular.telefon.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.telefon.style.backgroundColor="#ffffff";
  }
	if (isEMailValid(document.SpendenFormular.email.value) == false ) {
  	document.SpendenFormular.email.style.backgroundColor="#ffff99";
    document.SpendenFormular.email.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.email.style.backgroundColor="#ffffff";
  }
  if (document.SpendenFormular.ort.value == "") {
  	document.SpendenFormular.ort.style.backgroundColor="#ffff99";
    document.SpendenFormular.ort.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.ort.style.backgroundColor="#ffffff";
  }
  if (document.SpendenFormular.plz.value == "") {
  	document.SpendenFormular.plz.style.backgroundColor="#ffff99";
    document.SpendenFormular.plz.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.plz.style.backgroundColor="#ffffff";
  }
  if (document.SpendenFormular.strasse.value == "") {
  	document.SpendenFormular.strasse.style.backgroundColor="#ffff99";
    document.SpendenFormular.strasse.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.strasse.style.backgroundColor="#ffffff";
  }
  if (document.SpendenFormular.nachname.value == "") {
  	document.SpendenFormular.nachname.style.backgroundColor="#ffff99";
    document.SpendenFormular.nachname.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.nachname.style.backgroundColor="#ffffff";
  }
  if (document.SpendenFormular.nachname.value == "") {
  	document.SpendenFormular.nachname.style.backgroundColor="#ffff99";
    document.SpendenFormular.nachname.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.nachname.style.backgroundColor="#ffffff";
  }
  if (document.SpendenFormular.vorname.value == "") {
  	document.SpendenFormular.vorname.style.backgroundColor="#ffff99";
    document.SpendenFormular.vorname.focus();
	  retCode = false;
  } else {
  	document.SpendenFormular.vorname.style.backgroundColor="#ffffff";
  }
  return retCode;
}

function chkNewsletterFormular() {
  var retCode = true;
	if (isEMailValid(document.Newsletter.email.value) == false ) {
  	document.Newsletter.email.style.backgroundColor="#ffff99";
    document.Newsletter.email.focus();
	  retCode = false;
  } else {
  	document.Newsletter.email.style.backgroundColor="#ffffff";
  }
  return retCode;
}

function chkKontaktFormular() {
  var retCode = true;
  if (document.Kontakt.nachricht.value == "") {
  	document.Kontakt.nachricht.style.backgroundColor="#ffff99";
    document.Kontakt.nachricht.focus();
	  retCode = false;
  } else {
  	document.Kontakt.nachricht.style.backgroundColor="#ffffff";
  }
	if (isEMailValid(document.Kontakt.email.value) == false ) {
  	document.Kontakt.email.style.backgroundColor="#ffff99";
    document.Kontakt.email.focus();
	  retCode = false;
  } else {
  	document.Kontakt.email.style.backgroundColor="#ffffff";
  }
  if (document.Kontakt.nachname.value == "") {
  	document.Kontakt.nachname.style.backgroundColor="#ffff99";
    document.Kontakt.nachname.focus();
	  retCode = false;
  } else {
  	document.Kontakt.nachname.style.backgroundColor="#ffffff";
  }
  if (document.Kontakt.vorname.value == "") {
  	document.Kontakt.vorname.style.backgroundColor="#ffff99";
    document.Kontakt.vorname.focus();
	  retCode = false;
  } else {
  	document.Kontakt.vorname.style.backgroundColor="#ffffff";
  }
  return retCode;
}

function chkEmailSpendeFormular() {
  var retCode = true;
	if (isEMailValid(document.EmailSpende.email.value) == false ) {
  	document.EmailSpende.email.style.backgroundColor="#ffff99";
    document.EmailSpende.email.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.email.style.backgroundColor="#ffffff";
  }
	if (document.EmailSpende.telefon.value == "" ) {
  	document.EmailSpende.telefon.style.backgroundColor="#ffff99";
    document.EmailSpende.telefon.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.telefon.style.backgroundColor="#ffffff";
  }
	if (document.EmailSpende.ort.value == "" ) {
  	document.EmailSpende.ort.style.backgroundColor="#ffff99";
    document.EmailSpende.ort.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.ort.style.backgroundColor="#ffffff";
  }
	if (document.EmailSpende.plz.value == "" ) {
  	document.EmailSpende.plz.style.backgroundColor="#ffff99";
    document.EmailSpende.plz.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.plz.style.backgroundColor="#ffffff";
  }
	if (document.EmailSpende.strasse.value == "" ) {
  	document.EmailSpende.strasse.style.backgroundColor="#ffff99";
    document.EmailSpende.strasse.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.strasse.style.backgroundColor="#ffffff";
  }
  if (document.EmailSpende.nachname.value == "") {
  	document.EmailSpende.nachname.style.backgroundColor="#ffff99";
    document.EmailSpende.nachname.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.nachname.style.backgroundColor="#ffffff";
  }
  if (document.EmailSpende.vorname.value == "") {
  	document.EmailSpende.vorname.style.backgroundColor="#ffff99";
    document.EmailSpende.vorname.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.vorname.style.backgroundColor="#ffffff";
  }

  if (document.EmailSpende.geldinstitut.value == "") {
  	document.EmailSpende.geldinstitut.style.backgroundColor="#ffff99";
    document.EmailSpende.geldinstitut.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.geldinstitut.style.backgroundColor="#ffffff";
  }
  if (document.EmailSpende.bankleitzahl.value == "") {
  	document.EmailSpende.bankleitzahl.style.backgroundColor="#ffff99";
    document.EmailSpende.bankleitzahl.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.bankleitzahl.style.backgroundColor="#ffffff";
  }
  if (document.EmailSpende.kontonummer.value == "") {
  	document.EmailSpende.kontonummer.style.backgroundColor="#ffff99";
    document.EmailSpende.kontonummer.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.kontonummer.style.backgroundColor="#ffffff";
  }
  if (document.EmailSpende.kontoinhaber.value == "") {
  	document.EmailSpende.kontoinhaber.style.backgroundColor="#ffff99";
    document.EmailSpende.kontoinhaber.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.kontoinhaber.style.backgroundColor="#ffffff";
  }

  if (document.EmailSpende.ausstelldatum.value == "") {
  	document.EmailSpende.ausstelldatum.style.backgroundColor="#ffff99";
    document.EmailSpende.ausstelldatum.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.ausstelldatum.style.backgroundColor="#ffffff";
  }
  if (document.EmailSpende.name_vorname.value == "") {
  	document.EmailSpende.name_vorname.style.backgroundColor="#ffff99";
    document.EmailSpende.name_vorname.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.name_vorname.style.backgroundColor="#ffffff";
  }

  if (document.EmailSpende.anzahl.value == "") {
  	document.EmailSpende.anzahl.style.backgroundColor="#ffff99";
    document.EmailSpende.anzahl.focus();
	  retCode = false;
  } else {
  	document.EmailSpende.anzahl.style.backgroundColor="#ffffff";
  }


  return retCode;
}

function chkProjektSpendeFormular() {
  var retCode = true;
	if (isEMailValid(document.ProjektSpende.email.value) == false ) {
  	document.ProjektSpende.email.style.backgroundColor="#ffff99";
    document.ProjektSpende.email.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.email.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.telefon.value == "" ) {
  	document.ProjektSpende.telefon.style.backgroundColor="#ffff99";
    document.ProjektSpende.telefon.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.telefon.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.ort.value == "" ) {
  	document.ProjektSpende.ort.style.backgroundColor="#ffff99";
    document.ProjektSpende.ort.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.ort.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.plz.value == "" ) {
  	document.ProjektSpende.plz.style.backgroundColor="#ffff99";
    document.ProjektSpende.plz.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.plz.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.strasse.value == "" ) {
  	document.ProjektSpende.strasse.style.backgroundColor="#ffff99";
    document.ProjektSpende.strasse.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.strasse.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.nachname.value == "") {
  	document.ProjektSpende.nachname.style.backgroundColor="#ffff99";
    document.ProjektSpende.nachname.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.nachname.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.vorname.value == "") {
  	document.ProjektSpende.vorname.style.backgroundColor="#ffff99";
    document.ProjektSpende.vorname.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.vorname.style.backgroundColor="#ffffff";
  }

  if (document.ProjektSpende.geldinstitut.value == "") {
  	document.ProjektSpende.geldinstitut.style.backgroundColor="#ffff99";
    document.ProjektSpende.geldinstitut.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.geldinstitut.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.bankleitzahl.value == "") {
  	document.ProjektSpende.bankleitzahl.style.backgroundColor="#ffff99";
    document.ProjektSpende.bankleitzahl.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.bankleitzahl.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.kontonummer.value == "") {
  	document.ProjektSpende.kontonummer.style.backgroundColor="#ffff99";
    document.ProjektSpende.kontonummer.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.kontonummer.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.kontoinhaber.value == "") {
  	document.ProjektSpende.kontoinhaber.style.backgroundColor="#ffff99";
    document.ProjektSpende.kontoinhaber.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.kontoinhaber.style.backgroundColor="#ffffff";
  }

  if (document.ProjektSpende.betrag.value == "") {
  	document.ProjektSpende.betrag.style.backgroundColor="#ffff99";
    document.ProjektSpende.betrag.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.betrag.style.backgroundColor="#ffffff";
  }


  return retCode;
}

function chkProjektSpendeFormularSpezial() {
  var retCode = true;
	if (isEMailValid(document.ProjektSpende.email.value) == false ) {
  	document.ProjektSpende.email.style.backgroundColor="#ffff99";
    document.ProjektSpende.email.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.email.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.ort.value == "" || document.ProjektSpende.ort.value == "Ort" ) {
  	document.ProjektSpende.ort.style.backgroundColor="#ffff99";
    document.ProjektSpende.ort.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.ort.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.plz.value == "" || document.ProjektSpende.plz.value == "PLZ") {
  	document.ProjektSpende.plz.style.backgroundColor="#ffff99";
    document.ProjektSpende.plz.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.plz.style.backgroundColor="#ffffff";
  }
	if (document.ProjektSpende.strasse.value == "" || document.ProjektSpende.strasse.value == "Strasse") {
  	document.ProjektSpende.strasse.style.backgroundColor="#ffff99";
    document.ProjektSpende.strasse.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.strasse.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.nachname.value == "" || document.ProjektSpende.nachname.value == "Nachname") {
  	document.ProjektSpende.nachname.style.backgroundColor="#ffff99";
    document.ProjektSpende.nachname.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.nachname.style.backgroundColor="#ffffff";
  }
  if (document.ProjektSpende.vorname.value == "" || document.ProjektSpende.vorname.value == "Vorname") {
  	document.ProjektSpende.vorname.style.backgroundColor="#ffff99";
    document.ProjektSpende.vorname.focus();
	  retCode = false;
  } else {
  	document.ProjektSpende.vorname.style.backgroundColor="#ffffff";
  }

  if (document.ProjektSpende.betrag.value != "" || document.ProjektSpende.betrag_20.checked == true || document.ProjektSpende.betrag_50.checked == true || document.ProjektSpende.betrag_90.checked == true) {
  	document.ProjektSpende.betrag.style.backgroundColor="#ffffff";
  } else {
  	document.ProjektSpende.betrag.style.backgroundColor="#ffff99";
    document.ProjektSpende.betrag.focus();
	  retCode = false;
  }

  return retCode;
}

function Bildwechsel (id) {
  if (id == 1) {
    $('ECardImage').src = ecard1.src;
    $('ECardId').value = "1";
    }
  if (id == 2) {
    $('ECardImage').src = ecard2.src;
    $('ECardId').value = "2";
  }
  if (id == 3) {
    $('ECardImage').src = ecard3.src;
    $('ECardId').value = "3";
  }
}

function chkECardFormular() {
	var retCode = true;
	if (document.ECard.stringCaptcha.value == "") {
		document.ECard.stringCaptcha.style.backgroundColor="#ffff99";
		document.ECard.stringCaptcha.focus();
		retCode = false;
	} else {
		document.ECard.stringCaptcha.style.backgroundColor="#ffffff";
	}
	if (isEMailValid(document.ECard.emailto0.value) == false ) {
		document.ECard.emailto0.style.backgroundColor="#ffff99";
		document.ECard.emailto0.focus();
		retCode = false;
	} else {
		document.ECard.emailto0.style.backgroundColor="#ffffff";
	}
	if (document.ECard.nameto0.value == "") {
		document.ECard.nameto0.style.backgroundColor="#ffff99";
		document.ECard.nameto0.focus();
		retCode = false;
	} else {
		document.ECard.nameto0.style.backgroundColor="#ffffff";
	}
	if (isEMailValid(document.ECard.email.value) == false ) {
		document.ECard.email.style.backgroundColor="#ffff99";
		document.ECard.email.focus();
		retCode = false;
	} else {
		document.ECard.email.style.backgroundColor="#ffffff";
	}
	if (document.ECard.name.value == "") {
		document.ECard.name.style.backgroundColor="#ffff99";
		document.ECard.name.focus();
		retCode = false;
	} else {
		document.ECard.name.style.backgroundColor="#ffffff";
	}
	return retCode;
}


function openReceiver() {
	$('receiver').show();
}


function closeReceiver() {
  var count = 0;
  if (document.ECard.nameto1.value != "" && document.ECard.emailto1.value != "") count++; 
  if (document.ECard.nameto2.value != "" && document.ECard.emailto2.value != "") count++; 
  if (document.ECard.nameto3.value != "" && document.ECard.emailto3.value != "") count++; 
  if (document.ECard.nameto4.value != "" && document.ECard.emailto4.value != "") count++; 
  if (document.ECard.nameto5.value != "" && document.ECard.emailto5.value != "") count++; 
  if (document.ECard.nameto6.value != "" && document.ECard.emailto6.value != "") count++; 
  if (document.ECard.nameto7.value != "" && document.ECard.emailto7.value != "") count++; 
  if (document.ECard.nameto8.value != "" && document.ECard.emailto8.value != "") count++; 
  if (document.ECard.nameto9.value != "" && document.ECard.emailto9.value != "") count++; 
  $('receivercount').innerHTML=count;
	$('receiver').hide();
}
