
/***********************************************
* Disable "Enter" key in Form script
***********************************************/

function disableEnterKey (field, event) {
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode == 13) {
    var i;
    for (i = 0; i < field.form.elements.length; i++) {
      if (field == field.form.elements[i])
        break;
    }
    i = (i + 1) % field.form.elements.length;
    field.form.elements[i].focus();
    return false;
  }
  else {
    return true;
  }
}

/***********************************************
* The simplest way to require visitors to fill out 
* certain fields is to us this function - just add 
* the word "REQUIRE_" to each required field's name
***********************************************/

function checkRequired(which) {
  var pass=true;
  if (document.images) {
    for (i=0; i<which.length; i++) {
      var tempobj = which.elements[i];
      if (tempobj.name.indexOf("REQUIRE_") != -1) {
        if (((tempobj.type == "text" || tempobj.type == "textarea") && tempobj.value == '')
              || (tempobj.type.toString().charAt(0) == "s" && tempobj.selectedIndex == 0)) {
          pass=false;
          break;
         }
      }
    }
  }
  if (!pass) {
    messageBox("Bitte stellen Sie sicher, dass alle Felder korrekt ausgef&uuml;llt sind.", (screen.width / 4), (screen.height / 6));
    return false;
  }
  else {
    return true;
  }
}

/***********************************************
* Custom message box that support UTF-8 charset.
***********************************************/

function messageBox(text,w,h) {
  var pleft = (screen.width - w) / 2;
  var ptop = (screen.height - h) / 2;
  var settings ='width=' + w + ',';
      settings +='height=' + h + ',';
      settings +='top=' + ptop + ',';
      settings +='left=' + pleft + ',';
      settings +='toolbar=no,';
      settings +='menubar=no,';
      settings +='scrollbars=yes,';
      settings +='resizable=yes,';
      settings +='location=no,';
      settings +='directories=no,';
      settings +='status=no';
  var box=window.open('','name',settings);
  box.document.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
  box.document.writeln('<html>');
  box.document.writeln('  <head>');
  box.document.writeln('    <title>Kontaktformular</title>');
  box.document.writeln('    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
  box.document.writeln('    <link rel="stylesheet" type="text/css" href="/style.css">');
  box.document.writeln('  </head>');
  box.document.writeln('  <body class="kontaktpopup">');
  box.document.writeln('  <div class="kontakt">');
  box.document.writeln('    <center><p>');
  box.document.writeln(text);
  box.document.writeln('      </p><input type="button" value="Schliessen" class="button" onclick="javascript:self.close()">');
  box.document.writeln('    </center>');
  box.document.writeln('  </div>');
  box.document.writeln('  </body>');
  box.document.writeln('</html>');
  box.focus();
  box.document.close();
}
