
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Created by: Lee Hinder, lee.hinder@ntlworld.com -->

<!-- Begin
//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape

//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
  var DaysInMonth = "";
  var DaysInMonth = 31;
  if (WhichMonth == "April" || WhichMonth == "Juni" || WhichMonth == "September" || WhichMonth == "November") DaysInMonth = 30;
  if (WhichMonth == "Februari" && (WhichYear/4) != Math.floor(WhichYear/4))	DaysInMonth = 28;
  if (WhichMonth == "Februari" && (WhichYear/4) == Math.floor(WhichYear/4))	DaysInMonth = 29;
  return DaysInMonth;
}

//function to change the available days in a months
function ChangeOptionDays(Which)
{

  var dan=Which+"Day";
  var mjesec=Which+"Month";
  var godina=Which+"Year";

  DaysObject = document.forms['formulier'].elements[dan];
  MonthObject = document.forms['formulier'].elements[mjesec];
  YearObject = document.forms['formulier'].elements[godina];

  Month = MonthObject[MonthObject.selectedIndex].text;
  Year = YearObject[YearObject.selectedIndex].text;

  DaysForThisSelection = DaysInMonth(Month, Year);
  CurrentDaysInSelection = DaysObject.length;
  if (CurrentDaysInSelection > DaysForThisSelection)
  {
    for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
    {
      DaysObject.options[DaysObject.options.length - 1] = null
    }
  }
  if (DaysForThisSelection > CurrentDaysInSelection)
  {
    for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
    {
      NewOption = new Option(DaysObject.options.length + 1);
      DaysObject.add(NewOption);
    }
  }
    if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
}

//function to set options to today
function SetToToday(Which)
{
  var dan=Which+"Day";
  var mjesec=Which+"Month";
  var godina=Which+"Year";

  DaysObject = document.forms['formulier'].elements[dan];
  MonthObject = document.forms['formulier'].elements[mjesec];
  YearObject = document.forms['formulier'].elements[godina];

  YearObject[0].selected = true;
  MonthObject[NowMonth].selected = true;

  ChangeOptionDays(Which);

  DaysObject[NowDay-1].selected = true;
}

//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
  return ;
}

function checkTelefoonnummer(sText)
{
	var finalNummer = new String();
	var ValidChars = "0123456789";
	var ValidCharsExtra = "()/ -";
	var IsNumber = true;
	var localLenght = sText.length;

	for (i = 0; i < localLenght; i++)
		{
			var checkObject = "";
			checkObject = sText.charAt(i);

			if (ValidChars.indexOf(checkObject) == -1)
			{
				if (ValidCharsExtra.indexOf(checkObject) == -1)
				{
					return false;
				}
				else
				{

				}
			}
			else
			{
				finalNummer = finalNummer.concat(checkObject);
			}

		}

 	if(finalNummer.length == 10)

 	{
	   for (i = 0; i < finalNummer.length && IsNumber == true; i++)
	      {
	      var Char = finalNummer.charAt(i);
	      if (ValidChars.indexOf(Char) == -1)
	         {
	         	IsNumber = false;
	         }
	      }

	  	return true;

	 }

	else
	{
		return false;
	}

}


function checkform ( form )
{
  // ** START **

  if (document.getElementById('naam').value == "") {
    alert( "U heeft geen naam ingevuld." );
    document.getElementById('naam').focus();
    return false ;
  }
  if (document.getElementById('telefoon').value == "") {
    alert( "U heeft geen telefoonnummer ingevuld." );
    document.getElementById('telefoon').focus();
    return false ;
  }
	var telefoonValue = '';
	telefoonValue = document.getElementById('telefoon').value;

	if (!(checkTelefoonnummer(telefoonValue))){
	    alert( "Geldig telefoonnummer invullen aub!" );
    	document.getElementById('telefoon').focus();
		return false;
	}
  if (document.getElementById('email').value == "") {
    alert( "U heeft geen email ingevuld." );
    document.getElementById('email').focus();
    return false ;
  }
  if (document.getElementById('tijd').value == "") {
    alert( "U heeft geen tijd ingevuld." );
    document.getElementById('tijd').focus();
    return false ;
  }
  if (document.getElementById('aantal').value == "") {
    alert( "U heeft geen aantal mensen ingevuld." );
    document.getElementById('aantal').focus();
    return false ;
  }
  if (document.getElementById('bericht').value == "") {
    alert( "U heeft geen bericht ingevuld." );
    document.getElementById('bericht').focus();
    return false ;
  }
  if (!checkEmail(document.getElementById('email').value))
  {
  	alert("U heeft geen goed E-mail adres ingevuld.");
	document.getElementById('email').focus();
	return false ;
  }
  // ** END **
  return true ;
}
// Begin
function checkEmail(email)
 {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
	return (true)
	}
    else{
	return (false)
	}
}

//  End -->
