//====================================================================================================
//	Function Name	:	General Section
//----------------------------------------------------------------------------------------------------
function Tab_Click(tab, panel, totalCnt)
{
	for(var i=1; i<=totalCnt; i++)
	{
		if('tab'+i.toString() == tab.toString())
		{
			document.getElementById(panel).style.display = '';
			document.getElementById(tab).setAttribute("class", 'activelink'); //For most browsers
			document.getElementById(tab).setAttribute("className", 'activelink'); //For IE, harmless to other browsers
		}
		else
		{
			document.getElementById('panel'+i).style.display = 'none';
			document.getElementById('tab'+i).setAttribute("class", 'whitelink'); //For most browsers
			document.getElementById('tab'+i).setAttribute("className", 'whitelink'); //For IE, harmless to other browsers
		}
	}
}

function Date_Format(date)
{
	var dt		= new Date(date);
	var month	= dt.getMonth() + 1;
	
	if(month <= 9)
		month = '0' + month;
	
	var year 	= dt.getFullYear();
	var day		= dt.getDate();
	
	if(day <= 9)
		day = '0' + day;
	
	return year + "" + month + "" +  day + "";
}

function Radio_Value(radio)
{
	var i;
	
	for(i=0; i<radio.length; i++)
	{
		if(radio[i].checked)
			return radio[i].value;
	}
	
	return "undefined";
}

//====================================================================================================
//	Function Name	:	Flights Section
//----------------------------------------------------------------------------------------------------
function Validate_Flights(frm)
{
	with(frm)
    {
		if(!IsEmpty(B_LOCATION_1, 'Please enter From City.'))
		{
			return false;
		}
		
		if(!IsEmpty(E_LOCATION_1, 'Please enter To City.'))
		{
			return false;
		}
		
		if(!IsEmpty(External_FlightFareSearch_DepartureDate, 'Please enter Departure Date.'))
		{
			return false;
		}
		
		if(Radio_Value(air_rndtrip) == 'R')
		{
			if(!IsEmpty(External_FlightFareSearch_ReturnDate, 'Please enter Return Date.'))
			{
				return false;
			}
		}
	}
	
	Set_Flights_Hidden_Values();
	
	return true;
}

function Set_Flights_Hidden_Values()
{
	document.frmFlights.B_DATE_1.value = Date_Format(document.frmFlights.External_FlightFareSearch_DepartureDate.value) + document.frmFlights.External_FlightFareSearch_DepartureTime.value;
	document.frmFlights.E_DATE_1.value = Date_Format(document.frmFlights.External_FlightFareSearch_ReturnDate.value) + document.frmFlights.External_FlightFareSearch_ArrivalTime.value;
}

//====================================================================================================
//	Function Name	:	Hotels Section
//----------------------------------------------------------------------------------------------------
function Validate_Hotels(frm)
{
	with(frm)
    {
		if(!IsEmpty(B_LOCATION, 'Please enter City.'))
		{
			return false;
		}
		
		if(!IsEmpty(hotel_chkin_date, 'Please enter Check-In.'))
		{
			return false;
		}
		
		if(!IsEmpty(hotel_chkout_date, 'Please enter Check-Out.'))
		{
			return false;
		}
		
		if(!IsSelected(Occupancy, 'Please enter Room Type.'))
		{
			return false;
		}
		
		if(IsEmpty(External_HotelSearch_MinPrice,''))
		{
			if(!IsInt(External_HotelSearch_MinPrice, 'Oppsss!!! Invalid input. \nPlease re-check Maximum.'))
			{
				return false;
			}
		}
		
		if(IsEmpty(External_HotelSearch_MinPrice2,''))
		{
			if(!IsInt(External_HotelSearch_MinPrice2, 'Oppsss!!! Invalid input. \nPlease re-check Minimum.'))
			{
				return false;
			}
		}
	}
	
	Set_Hotels_Hidden_Values();
	
	return true;
}

function Set_Hotels_Hidden_Values()
{
	document.frmHotels.B_DATE.value = Date_Format(document.frmHotels.hotel_chkin_date.value) + "0000";
	document.frmHotels.E_DATE.value = Date_Format(document.frmHotels.hotel_chkout_date.value) + "0000";
}

//====================================================================================================
//	Function Name	:	Cars Section
//----------------------------------------------------------------------------------------------------
function Validate_Cars(frm)
{
	with(frm)
    {
		if(!IsEmpty(B_LOCATION, 'Please enter Pick-Up Location.'))
		{
			return false;
		}
		
		if(!IsEmpty(E_LOCATION, 'Please enter Drop-Off Location.'))
		{
			return false;
		}
		
		if(!IsEmpty(car_pickup_date, 'Please enter Pick-Up Date.'))
		{
			return false;
		}
		
		if(!IsEmpty(car_dropoff_date, 'Please enter Drop-Off Date.'))
		{
			return false;
		}
	}
	
	Set_Cars_Hidden_Values();
	
	return true;
}

function Set_Cars_Hidden_Values()
{
	document.frmCars.B_DATE.value = Date_Format(document.frmCars.car_pickup_date.value) + document.frmCars.car_pickup_dateTime.value;
	document.frmCars.E_DATE.value = Date_Format(document.frmCars.car_dropoff_date.value) + document.frmCars.car_dropoff_dateTime.value;
}

//====================================================================================================
//	Function Name	:	Insurance Section
//----------------------------------------------------------------------------------------------------
function Validate_Insurance(frm)
{
	with(frm)
    {
		if(!IsEmpty(ins_name, 'Please enter Name.'))
		{
			return false;
		}
		
		if(!IsEmpty(ins_email, 'Please enter Email Address.'))
		{
			return false;
		}
		else if(!IsEmail(ins_email, 'Oppsss!!! Invalid Email Address specified.'))
		{
			return false;
		}
		
		if(!IsEmpty(ins_cover_date, 'Please enter Date of Cover Start.'))
		{
			return false;
		}
		
		if(!IsEmpty(ins_mobile, 'Please enter Tel / Mobile.'))
		{
			return false;
		}
		else if(!IsPhone(ins_mobile, 'Oppsss!!! Invalid input. \nPlease re-check Tel / Mobile.'))
		{
			return false;
		}
		
		if(!IsEmpty(ins_travel, 'Please enter Where are you Travelling to?'))
		{
			return false;
		}
	}
	
	return true;
}

//====================================================================================================
//	Function Name	:	Prayer Section
//----------------------------------------------------------------------------------------------------
function Validate_Prayer(frm)
{
	with(frm)
    {
		if(!IsSelected(country, 'Please select Country.'))
		{
			return false;
		}
	}
	
	return true;
}
