
function ReInput(){
  var flag=true;
	if(document.bestellen.ArtNr.value=="" || document.bestellen.ArtNr.value.length!=7 || !intCheck()){
	   alert("Bitte Art-Nr. richtig ausfuellen!");
	   document.bestellen.ArtNr.focus();
	   return false;
	}
	if(document.bestellen.Vorname.value==""){
	   alert("Bitte Vorname nicht leer ausfuellen!");
	   document.bestellen.Vorname.focus();
	   return false;
	}
	if(document.bestellen.Nachname.value==""){
	   alert("Bitte Nachname nicht leer ausfuellen!");
	   document.bestellen.Nachname.focus();
	   return false;
	}
	if(document.bestellen.Strasse.value==""){
	   alert("Bitte Strasse nicht leer ausfuellen!");
	   document.bestellen.Strasse.focus();
	   return false;
	}
	if(document.bestellen.PLZ.value==""){
	   alert("Bitte PLZ richtig ausfuellen!");
	   document.bestellen.PLZ.focus();
	   return false;
	}
	if(document.bestellen.Ort.value==""){
	   alert("Bitte Ort nicht leer ausfuellen!");
	   document.bestellen.Ort.focus();
	   return false;
	}
	if(document.bestellen.email.value=="" || !e_mail()){
	   alert("Bitte E-Mail richtig ausfuellen!");
	   document.bestellen.email.focus();
	   return false;
	}
	if(document.bestellen.birthdate.value=="" || !isdate(document.bestellen.birthdate.value)){
	   alert("Bitte Geburtsdatum richtig ausfuellen!");
	   document.bestellen.birthdate.focus();
	   return false;
	}
	if(document.bestellen.phonenumber.value==""){
	   alert("Bitte Telefonnummer nicht leer ausfuellen!");
	   document.bestellen.phonenumber.focus();
	   return false;
	}

}

// checking the Artikelnummer
function intCheck()
{
	if(document.bestellen.ArtNr.value >= 2007008 && document.bestellen.ArtNr.value <= 2012999) return true;
	else return false;
}

// checking the PLZ
function plzCheck()
{
	if(document.bestellen.PLZ.value >= 00001 && document.bestellen.PLZ.value <= 99999) return true;
	else return false;
}

// checking the date
function isbetween(val,lo,hi){
  if((val<lo)||(val>hi)) {return(false);}
  else {return(true);}
  }
function isdate(thestr){
var the1st=thestr.indexOf('.');  
var the2nd=thestr.lastIndexOf('.');
if(the1st==the2nd){return(false);}
else{
  var d=thestr.substring(0,the1st);
  var m=thestr.substring(the1st+1,the2nd);
  var y=thestr.substring(the2nd+1,thestr.length);
  var maxdays=31;
  if(isint(m)==false||isint(d)==false||isint(y)==false){
  return(false);}
  else if(y.length<4){return(false);}
  else if(y<1900 || y > 2007){return(false);}
  else if(!isbetween(m,1,12)){return(false);}
  else if(m==4||m==6||m==9||m==11) maxdays=30;
  else if(m==2) {
     if(y%4>0)maxdays=28;
     else if(y%100==0&&y%400>0) maxdays=28;
	 else maxdays=29;
	}
  if(isbetween(d,1,maxdays)==false) {return(false);}	 
  else {return(true);}
  }
 }
 function isdigit(thenum) {
   var themask='0123456789';
   if(isempty(thenum)) return(false);
   else if(themask.indexOf(thenum)==-1) return(false);
   return(true);
  }
function isempty(str){
  if((str==null)||(str.length==0)) return true;
  else return(false);
  }
function isint(thestr){
var flag=true;
if(isempty(thestr)) {flag=false;}
else 
{
 for(var i=0;i<thestr.length;i++){
   if(isdigit(thestr.substring(i,i+1))==false){
	 flag=false;break;
	 }
 }	 
}
 return(flag);
}

// checking E-Mail
function e_mail(){
var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
if(!reg.exec(document.bestellen.email.value)){
 return false;
 }
 else return true;
}