// JavaScript Document
// Common functions

function externalLinks() { 
if (!document.getElementsByTagName) return; 
var anchors = document.getElementsByTagName("a"); 
for (var i=0; i<anchors.length; i++) { 
	var anchor = anchors[i]; 
	if (anchor.getAttribute("href") && 
		anchor.getAttribute("rel") == "_blank") 
		anchor.target = "_blank"; 
	} 
} 
window.onload = externalLinks;

function Form_Validator(BookingForm)
{

  if (BookingForm.F01.value == "")
  {
    alert("You do not appear to have entered your Name");
    BookingForm.F01.focus();
    return (false);
  }
  
  if (BookingForm.F01.value.length < 3)
  {
    alert("This seems to be a little short for a name. Please check your entry.");
    BookingForm.F01.focus();
    return (false);
  }

  if (BookingForm.F03.value == "")
  {
    alert("Please enter your email address");
    BookingForm.F03.focus();
    return (false);
  }
  
  var first, last, x;
  y = BookingForm.F03.value;
  if (y.indexOf(" ") != -1) { x = "X"; }
  if (y.indexOf(".@") != -1) { x = "X"; }
  if (y.indexOf("@.") != -1) { x = "X"; }
  if (y.indexOf(".") == y.length-1) { x = "X"; }
  first = y.indexOf("@");
  if (first == -1 || first == 0) { x = "X"; }
  if (first != y.lastIndexOf("@")) { x = "X"; }
  if (y.lastIndexOf(".") != -1 && (y.length - y.lastIndexOf(".")) < 6) { x = ""; } else { x = "X"; }
  if (x == "X")
  {
   	alert("You appear to have entered an invalid email address");
    BookingForm.F03.focus();
    return (false);
  }
    
  if (BookingForm.F04.value == "")
  {
    alert("Please enter a Telephone Number on which we can contact you");
    BookingForm.F04.focus();
    return (false);
  }

  if (BookingForm.F06.value == "")
  {
    alert("Please enter the date your require our services");
    BookingForm.F06.focus();
    return (false);
  }
	
  if (BookingForm.F07.value == "")
  {
    alert("Please enter the time of collection");
    BookingForm.F07.focus();
    return (false);
  }

  if (BookingForm.F10.value == "")
  {
    alert("Please enter the address we should collect from");
    BookingForm.F10.focus();
    return (false);
  }

  if (BookingForm.F11.value == "")
  {
    alert("Please enter the town/city we shall be collecting from");
    BookingForm.F11.focus();
    return (false);
  }

  if (BookingForm.F20.value == "")
  {
    alert("Please enter the name of the passengers");
    BookingForm.F20.focus();
    return (false);
  }

  if (BookingForm.F22.value == "")
  {
    alert("Please tell us where you are going");
    BookingForm.F22.focus();
    return (false);
  }

  if (BookingForm.F23.value == "")
  {
    alert("Please enter the town/city of the destination");
    BookingForm.F23.focus();
    return (false);
  }

  return (true);
}