/*
	use the validate-function if your submit-Button is an image or an href
	and not the standard-button. you don't need an 'onSubmit' in the form-tag then.
*/
function validate() {
	var checked = checkformular();

	if (checked) {
		document.ecf.submit();
		return true;
	}
}




function checkformular() {

	if (document.ecf.Name.value == "") {
		alert("Bitte einen Namen eingeben!");
		document.ecf.Name.focus();
		document.ecf.Name.select();
		return false;
	}

	if (document.ecf.Email.value == "") {
		alert("Bitte eine E-Mail angeben.");
		document.ecf.Email.focus();
		document.ecf.Email.select();
		return false;
	}
	if (document.ecf.Email.value != "") {
		var emailfalse = false;

		// if the default value isn't an correct address we check if the default value is entered somewhere first
		// if (document.ecf.mail.value.indexOf('deine@email.hier') >= 0) emailfalse = true;

		//let's filter the value - for an explanation of 'the filter array' read the javascript-documentation :o)
		//in case you'll allow the '%'-letter in the first block (rem.: the german gmx-mail-provider uses the '%'
		//for private mailing lists - and yes: this is non-standard! anyway...) try this one:
		//var filter=/^([\w-%]+(?:\.[\w-%]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

		//the filter has one (last?) problem: the first char could be - _ (or %) which is possibly wrong - i don't
		//know - read the rfc's yourself :o)
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if (!filter.test(document.ecf.Email.value)) emailfalse = true;

		if (emailfalse) {
			alert("Das ist keine gültige E-Mail-Adresse!");
			document.ecf.Email.focus();
			document.ecf.Email.select();
			return false;
		}
	}


	if (document.ecf.Adresse.value == "") {
		alert("Anschrift fehlt!");
		document.ecf.Adresse.focus();
		document.ecf.Adresse.select();
		return false;
	}

	if (document.ecf.Telefon.value == "") {
		alert("Bitte eine Telefonnummer angeben.");
		document.ecf.Telefon.focus();
		document.ecf.Telefon.select();
		return false;
	}

	if (document.ecf.Bank.value == "") {
		alert("Bitte den Namen des Bankinstituts angeben.");
		document.ecf.Bank.focus();
		document.ecf.Bank.select();
		return false;
	}

	if (document.ecf.BLZ.value == "") {
		alert("Bitte eine Bankleitzahl angeben.");
		document.ecf.BLZ.focus();
		document.ecf.BLT.select();
		return false;
	}

	if (document.ecf.Kontonummer.value == "") {
		alert("Bitte eine Kontonummer angeben.");
		document.ecf.Kontonummer.focus();
		document.ecf.Kontonummer.select();
		return false;
	}

	if (document.ecf.Veranstaltung.value == "") {
		alert("Bitte eine Veranstaltung angeben.");
		document.ecf.Veranstaltung.focus();
		document.ecf.Veranstaltung.select();
		return false;
	}

	if (document.ecf.Ticketanzahl.value == "") {
		alert("Bitte die Anzahl der Tickets angeben.");
		document.ecf.Ticketanzahl.focus();
		document.ecf.Ticketanzahl.select();
		return false;
	}

	return true;
}

