// JavaScript Document

	function IsNumeric(sText)
	{
	   var ValidChars = "0123456789.";
	   var IsNumber=true;
	   var Char;
	
	 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
		  { 
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1) 
			 {
			 IsNumber = false;
			 }
		  }
	   return IsNumber;
   
   }


  function CheckFields()
  {   
  

  	// set var radio_choice to false
	var radio_choice = false;
	

	

	  /////////////////////////////////////////////////
	  // validations for first name
	  if(document.bookingForm.name.value == '')
      {
        alert('Please enter your Name');
        document.bookingForm.name.focus();
        return false;
      }

	  /////////////////////////////////////////////////
	  // validations for Email address
	   if(document.bookingForm.email.value == '')
      {
        alert('Please enter your Email');
        document.bookingForm.email.focus();
        return false;
      }

      if(! checkMail(document.bookingForm.email.value))
      {
        alert('Incorrect Email. Please re-enter your Email');
        document.bookingForm.email.focus();
        return false;
      }
	  
	   /////////////////////////////////////////////////////////
	if(!IsNumeric(document.bookingForm.turkey.value)){
		alert('Invalid amount for Turkey Sandwiches');
        document.bookingForm.turkey.focus();
        return false;
	}

	if(!IsNumeric(document.bookingForm.roastbeef.value)){
		alert('Invalid amount for Roastbeef Sandwiches');
        document.bookingForm.roastbeef.focus();
        return false;
	}
	
	if(!IsNumeric(document.bookingForm.ham.value)){
		alert('Invalid amount for Ham Sandwiches');
        document.bookingForm.ham.focus();
        return false;
	}
	
	if(!IsNumeric(document.bookingForm.veggie.value)){
		alert('Invalid amount for Vegatarian Sandwiches');
        document.bookingForm.veggie.focus();
        return false;
	}
	
	///////////////////////////////////////////////////
	if(document.bookingForm.day.value == 'noDay'){
		alert('Please enter Tour day');
        document.bookingForm.day.focus();
        return false;
	}
	
	if(document.bookingForm.month.value == 'noMonth'){
		alert('Please enter Tour month');
        document.bookingForm.month.focus();
        return false;
	}
	  
	  ////////////////////////////////////////////////
	  // validations for Phone Numbers
	  
	  if(document.bookingForm.cardName.value == '')
      {
        alert('Please enter your Credit Card Name');
       document.bookingForm.cardName.focus();
        return false;
      } 

	  
	  if(document.bookingForm.ccNumber.value == '')
      {
        alert('Please enter your Credit Card Number');
       document.bookingForm.ccNumber.focus();
        return false;
      }  
	  	  ////////////////////////////////////////////////

		if(document.bookingForm.expiryDateDay.value == ''){
			alert('Please enter your Credit Card Expiry Day');
			document.bookingForm.expiryDateDay.focus();
			 return false;
		}
		else if (document.bookingForm.expiryDateDay.value < 1 || document.bookingForm.expiryDateDay.value > 30){
			alert('Invalid Credit Card Expiry Day');
			document.bookingForm.expiryDateDay.focus();
			 return false;
		}
		
		else if(!IsNumeric(document.bookingForm.expiryDateDay.value)){
			alert('Invalid Credit Card Expiry Day');
			document.bookingForm.expiryDateDay.focus();
			return false;
		}
		
			  ////////////////////////////////////////////////

		if(document.bookingForm.expiryDateMonth.value == ''){
			alert('Please enter your Credit Card Expiry Month');
			document.bookingForm.expiryDateMonth.focus();
			 return false;
		}
		else if (document.bookingForm.expiryDateMonth.value < 1 || document.bookingForm.expiryDateMonth.value > 12){
			alert('Invalid Credit Card Expiry Month');
			document.bookingForm.expiryDateMonth.focus();
			 return false;
		}
		
		else if(!IsNumeric(document.bookingForm.expiryDateMonth.value)){
			alert('Invalid Credit Card Expiry Month');
			document.bookingForm.expiryDateMonth.focus();
			return false;
		}
		
			  ////////////////////////////////////////////////
			  
		if(document.bookingForm.expiryDateYear.value == ''){
			alert('Please enter your Credit Card Expiry Year');
			document.bookingForm.expiryDateMonth.focus();
			 return false;
		}
		else if (document.bookingForm.expiryDateYear.value <= 2000){
			alert('Invalid Credit Card Expiry Year');
			document.bookingForm.expiryDateYear.focus();
			 return false;
		}
		
		else if(!IsNumeric(document.bookingForm.expiryDateYear.value)){
			alert('Invalid Credit Card Expiry Year');
			document.bookingForm.expiryDateYear.focus();
			return false;
		}

	 /*
	  var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
	  //strip out acceptable non-numeric characters
	  if (isNaN(parseInt(stripped))) {
		  alert('The phone number contains illegal characters.');
	  }
	 
	  if (!(stripped.length == 10)) {
		alert('The phone number is the wrong length. Make sure you included an area code.\n');
	 }
	  
	*/
	
		  
	  
   return true;
 
  }
  
 
 function checkMail(email)
 {
  var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (! filter.test(email))
   return false;
  return true;
 }
