﻿/*******************************************
 JavaScript www.ComputerService-Fiedler.de
 
 © 2007  Bernhard Schmidt
   http://www.schmidt-sachsen.de
  
  
 Interactive Form Check by Bernhard Schmidt
 *********************************************/
///////////////////////////////////////////////////////////////////////////////////////////////////////////

function FormCheck(Platz) {
 if (Platz=="Kontakt") {
  if (document.Kontakt.Name.value=="") {
   AlertInnerText="Bitte geben Sie Ihren Namen an.";
  
  
  //AlertTop="78px"; AlertLeft="250px"; AlertTyp="Rechts";
  AlertTop="78px"; AlertLeft="250px"; AlertTyp="Rechts";
  document.Kontakt.Name.focus();
  Formfehler();
  return false;
 }
 
 if (document.Kontakt.Strasse.value=="") {
  AlertInnerText="Bitte geben Sie Ihren Straßennamen an.";
  AlertTop="104px"; AlertLeft="250px"; AlertTyp="Links";
  document.Kontakt.Strasse.focus();
  Formfehler();
  return false;
 }

 if (document.Kontakt.Hausnummer.value=="") {
  AlertInnerText="Bitte geben Sie Ihre Hausnummer an.";
  AlertTop="104px"; AlertLeft="250px"; AlertTyp="Rechts";
  document.Kontakt.Hausnummer.focus();
  Formfehler();
  return false;
 }

 if (document.Kontakt.PLZ.value=="" || NumCheck(document.Kontakt.PLZ)==false) {
  AlertInnerText="Bitte geben Sie eine 5-stellige Postleitzahl an.";
  AlertTop="130px"; AlertLeft="250px"; AlertTyp="Links";
  document.Kontakt.PLZ.focus();
  Formfehler();
  return false;
 }
 
 if (document.Kontakt.Ort.value=="") {
  AlertInnerText="Bitte geben Sie Ihren Wohnort an.";
  AlertTop="130px"; AlertLeft="250px"; AlertTyp="Rechts";
  document.Kontakt.Ort.focus();
  Formfehler();
  return false;
 }
 
  if (document.Kontakt.Telefonnummer.value!="") {
  AlertInnerText="Bitte geben Sie eine gültige Telefonnummer an.";
  AlertTop="155px"; AlertLeft="250px"; AlertTyp="Links";
  document.Kontakt.Telefonnummer.focus();
  Formfehler();
  return false;
 }

 if (EmailCheck(document.Kontakt.Email)==false) {
  AlertInnerText="Bitte geben Sie eine gültige Emailadresse an.";
  AlertTop="181px"; AlertLeft="250px"; AlertTyp="Links";
  document.Kontakt.Email.focus();
  Formfehler();
  return false;
 }
 
 if (document.Kontakt.Nachricht.value=="") {
  AlertInnerText="Bitte schreiben Sie den Inhalt Ihrer Nachricht.";
  AlertTop="240px"; AlertLeft="250px"; AlertTyp="Links";
  document.Kontakt.Nachricht.focus();
  Formfehler();
  return false;
 }
  
 else {  AlertMove("AlertContainer","-50000px",""); }
}


if (Platz=="2") {
alert("JA");

}
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////
function NumCheck(InputElement) {
 var numericExpression = /^[0-9]+$/;
 if (InputElement.value.match(numericExpression)) {	return true; }
 else {
  return false;
 }
}

function EmailCheck(InputElement) {
 var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/
 if (InputElement.value.match(emailExp)) {	return true; }
 else {
  return false;
 }
}





///////////////////////////////////////////////////////////////////////////////////////////////////////////
function Formfehler() {
 if (document.getElementById) { document.getElementById("AlertText").firstChild.nodeValue=AlertInnerText; }

 AlertMove("AlertContainer",AlertTop,AlertLeft);
 if (AlertTyp=="Rechts") {
  AlertMove("Alert-Switched","0px","");
  AlertMove("Alert","-50000px","");
 }
 else { 
  AlertMove("Alert-Switched","-50000px","");
  AlertMove("Alert","0px","");
 } 
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
function HideAlert() {
 AlertMove("AlertContainer","-50000px","");
}




///////////////////////////////////////////////////////////////////////////////////////////////////////////

function WriteForm() {

 WriteForm=new Array("<div id=AlertContainer>",
  "<div id=Alert></div><div id=Alert-Switched></div>",
  "<div id=AlertText>",
  "Bitte überprüfen Sie Ihre Eingabe.</div>",
  "<div style='position: absolute; left: 0px; top: 0px; padding: 3px 0px 0px 5px;' id=AlertLink>",
  "<a onclick='JavaScript: HideAlert()' style='cursor:help;'>",
  "<img width=292 height=35 border=0 src='img/leer.gif'></a></div>",
  "</div>");
  
  document.write(WriteForm.join(""));
}
