
 function FormCheck()
 {
  var result   = true;
  var message  = 'Die Anfrage kann nicht versandt werden, da folgende Fehler aufgetreten sind:' + "\n\n";
  var weekdays = new Array ("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag");
  //weekdays[-1] = "Sonntag";
  var today    = new Date();
  today_stamp  = (today.getFullYear() * 10000) + (today.getMonth() * 100) + today.getDate();

  // check start date
  if ( (document.request.date1) && (document.request.month1) && (document.request.year1) ){
    day   = document.request.date1.options[document.request.date1.selectedIndex].value *1;
    month = document.request.month1.options[document.request.month1.selectedIndex].value *1;
    year  = document.request.year1.options[document.request.year1.selectedIndex].value *1;
    if ((day != '') && (month != '') && (year != '')) {
      var checkDate    = new Date(year, month - 1, day);
      var check_stamp  = (checkDate.getFullYear() * 10000) + (checkDate.getMonth() * 100) + checkDate.getDate();
      var weekday      = checkDate.getDay();

      if (weekday == 0) weekday = 7;

      // check if selected date is equal to week_start, if exists
      if (week_start > -1) {
      	//alert(weekday + " " + week_start);
        if (weekday != week_start) {
          message += '- Der Reisebeginn ist ein ' + weekdays[weekday] + ', eine Anreise ist jedoch nur ' + weekdays[week_start] + 's möglich.' + "\n";
          result = false;
        }
      }
      // there are locked days, so check the distance to today
      if (locked_days > -1) {
      	if ((check_stamp - locked_days) < (today_stamp - 1)) {
      	  message += '- Der Reisebeginn kann frühstens in ' + locked_days + ' Tagen sein.' + "\n";
      	  result = false;
        }
      }
    }
  }

  // check alternativ start date
  if ( (document.request.date2) && (document.request.month2) && (document.request.year2) ){
    day   = document.request.date2.options[document.request.date2.selectedIndex].value *1;
    month = document.request.month2.options[document.request.month2.selectedIndex].value *1;
    year  = document.request.year2.options[document.request.year2.selectedIndex].value *1;
    if ((day != '') && (month != '') && (year != '')) {
      var checkDate    = new Date(year, month - 1, day);
      var check_stamp  = (checkDate.getFullYear() * 10000) + (checkDate.getMonth() * 100) + checkDate.getDate();
      var weekday      = checkDate.getDay();
	  if (weekday == 0) weekday = 7;
      // check if selected date is equal to week_start, if exists
      if (week_start > -1) {
        if (weekday != week_start) {
           message += '- Der alternative Reisebeginn ist ein ' + weekdays[weekday] + ', eine Anreise ist jedoch nur ' + weekdays[week_start] + 's möglich.' + "\n";
           result = false;
         }
      }
      // there are locked days, so check the distance to today
      if (locked_days > -1) {
      	if ((check_stamp - locked_days) < (today_stamp - 1)) {
      	  message += '- Der alternative Reisebeginn kann frühstens in ' + locked_days + ' Tagen sein.' + "\n";
      	  result = false;
        }
      }

    }
  }

  //check if email or fax or telephon is given
  if ((document.request.fax) && (document.request.mail) && (document.request.phone)) {
  	if ((document.request.fax.value == "") && (document.request.mail.value == "") &&  (document.request.phone.value =="")) {
		message += '- Sie haben weder Email noch Faxnummer noch Telefonnummer angegeben.' + "\n";
      	result = false;
    }
  }

  if (result == false) alert(message);
  else write_cookie();
  return result;
 }

