function page_setup()
{
	$('#to_pickup_date_time_div').hide();
	$('#from_pickup_date_time_div').hide();
	$('#passenger_details').hide();
	
	if ($('#to_airport').val() == '')
	{
		$('#checkin_date_time_div').hide();
	}
	
	if ($('#from_airport').val() == '')
	{
		$('#land_date_time_div').hide();
		$('#from_flight_info').hide();
	}
	else
	{
		$('#from_flight_info').show();
	}
	
	$('.info_ico').each(function()
	{
		$(this).mouseover(function()
		{
			$(this).css('cursor', 'pointer');
		});
	});
	$('#phone_info').click(function()
	{
		$('#phone_blurb').toggle('slow');
	});
	$('#return_info').click(function()
	{
		$('#return_info_blurb').toggle('slow');
	});
	
	if ($('#phone_list').length)
	{
		var selected = $("#phone_list").val();
		if (selected == 'new')
		{
			$('#phone_other').show();
		}
		else
		{
			$('#phone_other').hide();
		}
	}
	else
	{
		$('#phone_other').show();
	}
	$('#phone_list').change(function()
	{
		if ($(this).val() == 'new')
		{
			$('#phone_other').show('slow');
		}
		else
		{
			$('#phone_other').hide('slow');
		}
	});
	
	$('#return_yes').click(function()
	{
		$('#return_check').val('yes');
		$('#return_check').change();
		step1_validator_rules();
		$("#airport_booking_form").validate().element('#return_check');
	});
	$('#return_no').click(function()
	{
		$('#return_check').val('no');
		$('#return_check').change();
		step1_validator_rules();
		$("#airport_booking_form").validate().element('#return_check');
	});
	
	if ($('#to_location_list').length)
	{
		var selected = $("#to_location_list").val();
		if (selected == 'other_location')
		{
			$('#to_pickup_address').show();
		}
		else
		{
			$('#to_pickup_address').hide();
		}
	}
	else
	{
		$('#to_pickup_address').show();
	}
	
	if ($('#from_location_list').length)
	{
		var selected = $("#from_location_list").val();
		if (selected == 'other_location')
		{
			$('#from_pickup_address').show();
		}
		else
		{
			$('#from_pickup_address').hide();
		}
	}
	else
	{
		$('#from_pickup_address').show();
	}
	$('#to_location_list').change(function()
	{
		if ($(this).val() == 'other_location')
		{
			$('#to_pickup_address').show('slow');
		}
		else
		{
			$('#to_pickup_address').hide('slow');
		}
	});
	$('#from_location_list').change(function()
	{
		if ($(this).val() == 'other_location')
		{
			$('#from_pickup_address').show('slow');
		}
		else
		{
			$('#from_pickup_address').hide('slow');
		}
	});
	
	$('#to_vehicle_info').click(function()
	{
		$('#to_multi_vehicle_blurb').toggle('slow');
	});
	$('#to_pricing_info').click(function()
	{
		$('#to_pricing_blurb').toggle('slow');
	});
	
	$('#from_vehicle_info').click(function()
	{
		$('#from_multi_vehicle_blurb').toggle('slow');
	});
	$('#from_pricing_info').click(function()
	{
		$('#from_pricing_blurb').toggle('slow');
	});
	
	$('#to_airport').change(function()
	{
		
		if ($(this).val() == '')
		{
			$('#to_terminal_p').remove();
			$('#checkin_date_time_div').hide('slow');
			$('#to_pickup_date_time_div').hide('slow');
			$('#to_pickup_hour').val('');
			$('#to_pickup_minute').val('');
			$('#to_pickup_day').val('');
			$('#to_pickup_month').val('');
			$('#to_pickup_year').val('');
			
			$('#to_pickup_hour').change();
			$('#to_pickup_year').change();
		}
		else
		{
			get_airport_terminal('to');
			$('#checkin_date_time_div').show('slow');
			check_display_pickup_date_time('checkin');
		}
	});
	
	$('#from_airport').change(function()
	{
		if ($(this).val() == '')
		{
			$('#from_terminal_p').remove();
			$('#from_flight_info').hide('slow');
			$('#land_date_time_div').hide('slow');
			$('#from_pickup_date_time_div').hide('slow');
			$('#from_pickup_hour').val('');
			$('#from_pickup_minute').val('');
			$('#from_pickup_day').val('');
			$('#from_pickup_month').val('');
			$('#from_pickup_year').val('');
			
			$('#from_pickup_hour').change();
			$('#from_pickup_year').change();
		}
		else
		{
			$('#from_flight_info').show('slow');
			get_airport_terminal('from');
			$('#land_date_time_div').show('slow');
			check_display_pickup_date_time('land');
		}
	});
	
	time_check_func('checkin');
	date_check_func('checkin');
	check_booking_date('checkin');
	check_booking_time('checkin');
	
	time_check_func('land');
	date_check_func('land');
	check_booking_date('land');
	check_booking_time('land');
	
	time_check_func('to_pickup');
	date_check_func('to_pickup');
	check_booking_date('to_pickup');
	check_booking_time('to_pickup');
	
	time_check_func('from_pickup');
	date_check_func('from_pickup');
	check_booking_date('from_pickup');
	check_booking_time('from_pickup');
	
	select_date_inint('checkin');
	select_date_inint('to_pickup');
	
	select_date_inint('land');
	select_date_inint('from_pickup');
	
	$('#checkin_date_pick').show();
	
	$('#land_date_pick').show();
	
	if ($('#checkin_time_check').val() == 'true' && $('#checkin_date_check').val() == 'true')
	{
		$('#to_pickup_date_time_div').show();
	}
	if ($('#land_time_check').val() == 'true' && $('#land_date_check').val() == 'true')
	{
		$('#from_pickup_date_time_div').show();
	}
	$('#checkin_time_check').change(function()
	{
		check_display_pickup_date_time('checkin');
	});
	$('#land_time_check').change(function()
	{
		check_display_pickup_date_time('land');
	});
	$('#checkin_date_check').change(function()
	{
		check_display_pickup_date_time('checkin');
	});
	$('#land_date_check').change(function()
	{
		check_display_pickup_date_time('land');
	});
	
	if ($('#to_luggage').val() == 'other')
	{
		$('#to_other_luggage_option').show();
	}
	else
	{
		$('#to_other_luggage_option').hide();
	}
	
	if ($('#from_luggage').val() == 'other')
	{
		$('#from_other_luggage_option').show();
	}
	else
	{
		$('#from_other_luggage_option').hide();
	}
	
	$('#to_luggage').change(function()
	{
		if ($(this).val() == 'other')
		{
			$('#to_other_luggage_option').show('slow');
		}
		else
		{
			$('#to_other_luggage_option').hide('slow');
			$('#to_luggage_other').val('');
		}
	});
	
	$('#from_luggage').change(function()
	{
		if ($(this).val() == 'other')
		{
			$('#from_other_luggage_option').show('slow');
		}
		else
		{
			$('#from_other_luggage_option').hide('slow');
			$('#from_luggage_other').val('');
		}
	});
	
	$('#to_heavy_luggage_info').click(function()
	{
		$('#to_heavy_luggage_info_blurb').toggle('slow');
	});
	
	$('#from_heavy_luggage_info').click(function()
	{
		$('#from_heavy_luggage_info_blurb').toggle('slow');
	});
	
	($('#acc_info_ico')).click(function()
	{
		$('#acc_info_blurb').toggle('slow');
	});
	
	$('#to_heavy_luggage_no').click(function()
	{
		$('#to_luggage_heavy_check').val('true');
		$('#to_luggage_heavy_check').change();
	});
	$('#to_heavy_luggage_yes').click(function()
	{
		$('#to_luggage_heavy_check').val('true');
		$('#to_luggage_heavy_check').change();
	});
	$('#from_heavy_luggage_yes').click(function()
	{
		$('#from_luggage_heavy_check').val('true');
		$('#from_luggage_heavy_check').change();
	});
	$('#from_heavy_luggage_no').click(function()
	{
		$('#from_luggage_heavy_check').val('true');
		$('#from_luggage_heavy_check').change();
	});
	
	$('#from_luggage_heavy_check').change(function()
	{
		$("#airport_booking_form").validate().element('#from_luggage_heavy_check');
	});
	
	if ($('#acc_info').length)
	{
		$('#acc_info').hide();
	}
	
	$('#acc_no').change(function()
	{
		if ($('#acc_info').length)
		{
			if ($(this).val() == '' || $(this).val() == '0' || $(this).val() == 'online')
			{
				$('#acc_info').hide('slow');
			}
			else
			{
				$('#acc_info').show('slow');
			}
		}
	});
}

function check_display_pickup_date_time(type)
{
	var time_check_element;
	var date_check_element;
	var pickup_div_element;
	
	if (type == 'checkin')
	{
		pickup_div_element = '#to_pickup_date_time_div';
		time_check_element = '#checkin_time_check';
		date_check_element = '#checkin_date_check';
	}
	else if (type == 'land')
	{
		pickup_div_element = '#from_pickup_date_time_div';
		time_check_element = '#land_time_check';
		date_check_element = '#land_date_check';
	}
	
	if ($(time_check_element).val() == 'true' && $(date_check_element).val() == 'true')
	{
		if (type == 'checkin')
		{
			if ($('#form_submitted').val() == '')
			{
				get_default_pickup_time();
			}
		}
		$(pickup_div_element).show('slow');
	}
	else
	{
		$(pickup_div_element).hide('slow');
	}
}

function date_time_standard(type)
{
	var day_element;
	var month_element;
	var year_element;
	var date_value_element;
	var date_section_element;
	
	if (type == 'standard')
	{
		day_element = '#day';
		month_element = '#month';
		year_element = '#year';
		date_value_element = '#date_value';
		date_section_element = '#date_section';
	}
	else if (type == 'checkin')
	{
		day_element = '#checkin_day';
		month_element = '#checkin_month';
		year_element = '#checkin_year';
		date_value_element = '#checkin_date_value';
		date_section_element = '#checkin_date_section';
	}
	else if (type == 'to_pickup')
	{
		day_element = '#to_pickup_day';
		month_element = '#to_pickup_month';
		year_element = '#to_pickup_year';
		date_value_element = '#to_pickup_date_value';
		date_section_element = '#to_pickup_date_section';
	}
	else if (type == 'land')
	{
		day_element = '#land_day';
		month_element = '#land_month';
		year_element = '#land_year';
		date_value_element = '#land_date_value';
		date_section_element = '#land_date_section';
	}
	else if (type == 'from_pickup')
	{
		day_element = '#from_pickup_day';
		month_element = '#from_pickup_month';
		year_element = '#from_pickup_year';
		date_value_element = '#from_pickup_date_value';
		date_section_element = '#from_pickup_date_section';
	}
	
	$(day_element).hide();
	$(month_element).hide();
	$(year_element).hide();
	
	$(date_value_element).css('padding-left', '10px');
	$(date_value_element).css('text-align', 'left');
	$(date_value_element).text('Choose Date');
	
	$(date_section_element + ' label').css('position', 'relative');
	$(date_section_element + ' span').css('position', 'relative');
	$(date_section_element + ' label').css('bottom', '15px');
	$(date_section_element + ' span').css('bottom', '15px');
}

function date_check_func(type)
{
	var form_element;
	var day_element;
	var month_element;
	var year_element;
	var date_check_element;
	var date_check_period_element;
	var date_check_past_element;
	
	if (type == 'checkin')
	{
		form_element = '#airport_booking_form';
		day_element = '#checkin_day';
		month_element = '#checkin_month';
		year_element = '#checkin_year';
		date_check_element = '#checkin_date_check';
		date_check_period_element = '#checkin_date_check_period';
		date_check_past_element = '#checkin_date_check_past';
	}
	else if (type == 'to_pickup')
	{
		form_element = '#airport_booking_form';
		day_element = '#to_pickup_day';
		month_element = '#to_pickup_month';
		year_element = '#to_pickup_year';
		date_check_element = '#to_pickup_date_check';
		date_check_period_element = '#to_pickup_date_check_period';
		date_check_past_element = '#to_pickup_date_check_past';
	}
	else if (type == 'land')
	{
		form_element = '#airport_booking_form';
		day_element = '#land_day';
		month_element = '#land_month';
		year_element = '#land_year';
		date_check_element = '#land_date_check';
		date_check_period_element = '#land_date_check_period';
		date_check_past_element = '#land_date_check_past';
	}
	else if (type == 'from_pickup')
	{
		form_element = '#airport_booking_form';
		day_element = '#from_pickup_day';
		month_element = '#from_pickup_month';
		year_element = '#from_pickup_year';
		date_check_element = '#from_pickup_date_check';
		date_check_period_element = '#from_pickup_date_check_period';
		date_check_past_element = '#from_pickup_date_check_past';
	}
	
	$(day_element).change(function()
	{
		check_booking_date(type);
		$(form_element).validate().element(date_check_element);
		$(form_element).validate().element(date_check_period_element);
		$(form_element).validate().element(date_check_past_element);
	});
	$(month_element).change(function()
	{
		check_booking_date(type);
		$(form_element).validate().element(date_check_element);
		$(form_element).validate().element(date_check_period_element);
		$(form_element).validate().element(date_check_past_element);
	});
	$(year_element).change(function()
	{
		check_booking_date(type);
		$(form_element).validate().element(date_check_element);
		$(form_element).validate().element(date_check_period_element);
		$(form_element).validate().element(date_check_past_element);
	});
}

function time_check_func(type)
{
	var hour_element;
	var min_element;
	
	if (type == 'checkin')
	{
		hour_element = '#checkin_hour';
		min_element = '#checkin_minute';
	}
	else if (type == 'to_pickup')
	{
		hour_element = '#to_pickup_hour';
		min_element = '#to_pickup_minute';
	}
	else if (type == 'land')
	{
		hour_element = '#land_hour';
		min_element = '#land_minute';
	}
	else if (type == 'from_pickup')
	{
		hour_element = '#from_pickup_hour';
		min_element = '#from_pickup_minute';
	}
	
	$(hour_element).change(function()
	{
		check_booking_time(type);	
	});
	$(min_element).change(function()
	{
		check_booking_time(type);	
	});
}

function check_booking_time(type)
{
	var hour = '';
	var min = '';
	var hour_check = false;
	var min_check = false;
	
	var hour_element;
	var min_element;
	var time_check_element;
	var time_value_element;
	var form_element;
	
	if (type == 'checkin')
	{
		form_element = '#airport_booking_form';
		hour_element = '#checkin_hour';
		min_element = '#checkin_minute';
		time_check_element = '#checkin_time_check'; 
		time_value_element = '#checkin_time_value';
	}
	else if (type == 'to_pickup')
	{
		form_element = '#airport_booking_form';
		hour_element = '#to_pickup_hour';
		min_element = '#to_pickup_minute';
		time_check_element = '#to_pickup_time_check'; 
		time_value_element = '#to_pickup_time_value';
	}
	else if (type == 'land')
	{
		form_element = '#airport_booking_form';
		hour_element = '#land_hour';
		min_element = '#land_minute';
		time_check_element = '#land_time_check'; 
		time_value_element = '#land_time_value';
	}
	else if (type == 'from_pickup')
	{
		form_element = '#airport_booking_form';
		hour_element = '#from_pickup_hour';
		min_element = '#from_pickup_minute';
		time_check_element = '#from_pickup_time_check'; 
		time_value_element = '#from_pickup_time_value';
	}
	
	$(hour_element + ' option:selected').each(function()
	{
		if ($(this).val() != '')
		{
			hour = $(this).val();
			hour_check = true;	
		}
	});
	$(min_element + ' option:selected').each(function()
	{
		if ($(this).val() != '')
		{
			min = $(this).val();
			min_check = true;	
		}
	});
	
	if (hour_check && min_check)
	{
		$(time_check_element).val('true');
		if ((hour * 1 ) == 0)
		{
			$(time_value_element).text('12:' + min + ' am');
		}
		else if ((hour * 1) < 13)
		{
			$(time_value_element).text((hour - 0) + ':' + min + ' am');
		}
		else if ((hour * 1) < 24)
		{
			$(time_value_element).text((hour - 12) + ':' + min + ' pm');
		}
		else
		{
			$(time_value_element).text((hour - 12) + ':' + min + ' am');
		}
		$(time_value_element).css('padding-left', '10px');
	}
	else
	{
		$(time_check_element).val('');
		$(time_value_element).text('');
	}
	$(form_element).validate().element(time_check_element);
	$(time_check_element).change();
}

function date_time_pretty_display(type)
{
	var days = new Array();
	var months = new Array();
		
	days[0] = 'Sun';
	days[1] = 'Mon';
	days[2] = 'Tue';
	days[3] = 'Wed';
	days[4] = 'Thu';
	days[5] = 'Fri';
	days[6] = 'Sat';
		
	months[0] = 'Jan';
	months[1] = 'Feb';
	months[2] = 'Mar';
	months[3] = 'Apr';
	months[4] = 'May';
	months[5] = 'Jun';
	months[6] = 'Jul';
	months[7] = 'Aug';
	months[8] = 'Sep';
	months[9] = 'Oct';
	months[10] = 'Nov';
	months[11] = 'Dec';
	
	var hour_element;
	var min_element;
	var day_element;
	var month_element;
	var year_element;
	var date_value_element;
	var time_value_element;
	
	if (type == 'checkin')
	{
		hour_element = '#checkin_hour';
		min_element = '#checkin_minute';
		day_element = '#checkin_day';
		month_element = '#checkin_month';
		year_element = '#checkin_year';
		date_value_element = '#checkin_date_value'; 
		time_value_element = '#checkin_time_value';
	}
	else if (type == 'to_pickup')
	{
		hour_element = '#to_pickup_hour';
		min_element = '#to_pickup_minute';
		day_element = '#to_pickup_day';
		month_element = '#to_pickup_month';
		year_element = '#to_pickup_year';
		date_value_element = '#to_pickup_date_value'; 
		time_value_element = '#to_pickup_time_value';
	}
	else if (type == 'land')
	{
		hour_element = '#land_hour';
		min_element = '#land_minute';
		day_element = '#land_day';
		month_element = '#land_month';
		year_element = '#land_year';
		date_value_element = '#land_date_value'; 
		time_value_element = '#land_time_value';
	}
	else if (type == 'from_pickup')
	{
		hour_element = '#from_pickup_hour';
		min_element = '#from_pickup_minute';
		day_element = '#from_pickup_day';
		month_element = '#from_pickup_month';
		year_element = '#from_pickup_year';
		date_value_element = '#from_pickup_date_value'; 
		time_value_element = '#from_pickup_time_value';
	}
	
	if ($(day_element).val() != '' && $(month_element).val() != '' && $(year_element).val() != '')
	{
		var d = $(day_element).val();
		var m = $(month_element).val();
		var y = $(year_element).val();
		
		var test_date = new Date();
		test_date.setFullYear(y, (m - 1), d);
		
		var day_name = test_date.getDay();
		d = test_date.getDate();
		m = test_date.getMonth();
		y = test_date.getFullYear();
				
		$(date_value_element).text(days[day_name] + ' ' + d + ' ' + months[m] + ' ' + y);
	}
	
	if ($(hour_element).val() != '' && $(min_element).val() != '')
	{
		var hour = $(hour_element).val();
		var min = $(min_element).val();
		if ((hour * 1 ) == 0)
		{
			$(time_value_element).text('12:' + min + ' am');
		}
		else if ((hour * 1) < 13)
		{
			$(time_value_element).text((hour - 0) + ':' + min + ' am');
		}
		else if ((hour * 1) < 24)
		{
			$(time_value_element).text((hour - 12) + ':' + min + ' pm');
		}
		else
		{
			$(time_value_element).text((hour - 12) + ':' + min + ' am');
		}
		$(time_value_element).css('padding-left', '10px');
	}
}