// JavaScript Document

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		nav_home_over = newImage("images/nav_home-over.jpg");
		nav_airportService_over = newImage("images/nav_airportService-over.jpg");
		nav_reservations_over = newImage("images/nav_reservations-over.jpg");
		nav_corporateAccounts_over = newImage("images/nav_corporateAccounts-over.jpg");
		nav_wedding_over = newImage("images/nav_wedding-over.jpg");
		nav_fleet_over = newImage("images/nav_fleet-over.jpg");
		nav_about_over = newImage("images/nav_about-over.jpg");
		default_i2_over = newImage("images/default_i2-over.jpg");
		default_i3_over = newImage("images/default_i3-over.jpg");
		preloadFlag = true;
	}
}
	function validate()
	{
		//validates reservation form
		if(document.theForm.pi_customername.value == "")
		{
			alert("Please enter the customer name");
			document.theForm.pi_customername.focus();
			return false;
		}
		
		if(document.theForm.pi_address.value == "")
		{
			alert("Please enter the address");
			document.theForm.pi_address.focus();
			return false;
		}
		
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.theForm.pi_email.value)){
  		 }
		else
		{
			alert("Invalid E-mail Address! Please re-enter. for eg:sam@yahoo.com")
			document.theForm.pi_email.focus();
			document.theForm.pi_email.select();
			return (false);
		}
		
		if(document.theForm.pi_phnumber.value == "")
		{
			alert("Please enter the phone number");
			document.theForm.pi_phnumber.focus();
			return false;
		}
		
		if(isNaN(document.theForm.pi_phnumber.value))
		{
			alert("Please enter the phone number in numbers only");
			document.theForm.pi_phnumber.focus();
			document.theForm.pi_phnumber.select();
			return false;
		}
		if(document.theForm.pi_cellPhone.value == "")
		{
			alert("Please enter Cell phone number");
			document.theForm.pi_cellPhone.focus();
			return false;
		}
		
		if(isNaN(document.theForm.pi_cellPhone.value))
		{
			alert("Please enter Cell phone number in numbers only");
			document.theForm.pi_cellPhone.focus();
			document.theForm.pi_cellPhone.select();
			return false;
		}
		if(document.theForm.pi_dateoftravel.value == "")
		{
			alert("Please enter the date of travel");
			document.theForm.pi_dateoftravel.focus();
			return false;
		}
		if(document.theForm.pi_time.value == "-1")
		{
			alert("Please specify Pick up time");
			document.theForm.pi_time.focus();
			return false;
		}
		if(document.theForm.pi_ampm.value == "-1")
		{
			alert("Please specify Pick up time AM or PM");
			document.theForm.pi_ampm.focus();
			return false;
		}
		if(document.theForm.pi_airlines.value == "Others")
		{
			if(document.theForm.pi_others.value == "")
			{
				alert("Please specify the airlines");
				document.theForm.pi_others.focus();
				return false;

			}
		}
		
		if(document.theForm.pi_vehicletyp.value == "Others")
		{
			if(document.theForm.pi_othertyp.value == "")
			{
				alert("Please specify the vehicle type");
				document.theForm.pi_othertyp.focus();
				return false;

			}
		}
		if(document.theForm.pi_airlines.value != "-1")
		{
			if(document.theForm.pi_flightnum.value == "")
			{
				alert("Please specify Flight Number");
				document.theForm.pi_flightnum.focus();
				return false;

			}
		}
	if(document.theForm.pi_event.value == "Others")
		{
			if(document.theForm.pi_otherevent.value == "")
			{
				alert("Please specify the event");
				document.theForm.pi_otherevent.focus();
				return false;

			}
		}

	if(isNaN(document.theForm.pi_numpass.value))
		{
			alert("Please enter the number of passengers in numbers only");
			document.theForm.pi_numpass.focus();
			document.theForm.pi_numpass.select();
			return false;
		}
	}
