function DDXLen(control,minLen,maxLen,errmsg)
{
	var s = control.value;
	if ( s.length < minLen || s.length > maxLen ) 
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}
	return true;
}
	
function DDXInt(control,min,max,errmsg)
{
	var s = control.value;
	
	if ( isNaN (s,10)  )
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}
	
	if ( s.valueOf() < min || s.valueOf() > max )
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}
	return true;
}

function DDXEMail(control, errmsg)
{
	var s = control.value;
	var rE = /^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/;
	var mArr = s.match(rE);
	if (mArr == null) 
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}	

	return true;		
}

function DDXRExp(control, rE, errmsg)
{
	var s = control.value;
	var mArr = s.match(rE);
	if (mArr == null) 
	{
		self.status=errmsg;
		control.focus();
		control.select();
		alert(errmsg);
		return false;
	}	

	return true;		
}

function valid_form(f,s)
{
	if (!DDXLen(f.vorname,1,100,"Bitte geben Sie Ihren Vornamen ein!")) {
		f.vorname.focus();
		return false;
	}
	
	if (!DDXLen(f.nachname,1,100,"Bitte geben Sie Ihren Nachnamen ein!")) {
		f.nachname.focus();
		return false;
	}
	
	if (!DDXLen(f.strasse,1,100,"Bitte geben Sie Ihre Strasse ein!")) {
		f.strasse.focus();
		return false;
	}
	
	if (!DDXLen(f.hausnummer,1,100,"Bitte geben Sie Ihre Hausnummer ein!")) {
		f.hausnummer.focus();
		return false;
	}
	
	if (!DDXLen(f.plz,1,100,"Bitte geben Sie Ihre PLZ ein!")) {
		f.plz.focus();
		return false;
	}
	
	if (!DDXLen(f.ort,1,100,"Bitte geben Sie Ihren Ort ein!")) {
		f.ort.focus();
		return false;
	}
	
	if (f.land.value == "keine Angabe") {
		alert("Bitte geben Sie Ihr Land ein!");
		f.land.focus();
		return false;
	}
	
	if (!DDXEMail(f.mail,"Bitte geben Sie eine vollständige e-mail-Adresse mit @ und . ein!")) {
		f.mail.focus();
		return false;
	}
	if (!DDXLen(f.nachricht,1,1000,"Bitte geben Sie eine Nachricht ein!")) {
		f.nachricht.focus();
		return false;
	}
	
	if (!DDXLen(f.sicherheitscode,1,100,"Bitte geben Sie den Sicherheitscode ein!")) {
		f.sicherheitscode.focus();
		return false;
	}
	
	s.disabled = "true";
	return true;
}
