function bw_GetObject(objectId)
{
//alert(objectId);
if (document.getElementById && document.getElementById(objectId))
return document.getElementById(objectId);
//alert(document.getElementById(objectId));
else if (document.all && document.all(objectId))
return document.all(objectId);
else
return false;
}

function bw_InitForm(formType)
{
	return;
/*var bwForm = document.bookingWiz;
var found = false;
for (var i = 0; i < bwForm.singleMenu.length; i++ )
{
if (formType == bwForm.singleMenu[i].value)
{
bwForm.singleMenu[i].checked = true;
found = true;
break;
}
}
if (found == false)
{
for (var i = 0; i < bwForm.comboMenu.length; i++ )
{
if (formType == bwForm.comboMenu[i].value)
{
bwForm.comboMenu[i].selected = true;
found = true;
break;
}
}
}
bw_ShowForm(formType);*/
}
function bw_ShowSingleForm()
{
var bwForm = document.bookingWiz;
var menuValue = 'air';
for (var i = 0; i < bwForm.singleMenu.length; i++ )
{
if (bwForm.singleMenu[i].checked)
{
menuValue = bwForm.singleMenu[i].value;
break;
}
}
var menuCb = bw_GetObject('comboMenu');
menuCb.selectedIndex = 0;
bw_ShowForm(menuValue);
}

function bw_ShowComboForm(value2)
{

var menuCb = bw_GetObject('comboMenu');
//var menuValue = menuCb.value || value2;
var menuValue = value2;

//alert(menuValue);
if (menuValue == '')
{
var bwForm = document.bookingWiz;
bwForm.singleMenu[0].checked = true;
bw_ShowForm('air');
return;
}
var bwForm = document.bookingWiz;


for (var i = 0; i < bwForm.singleMenu.length; i++ )
{
bwForm.singleMenu[i].checked = false;
}

formType=menuValue;
bw_ShowForm(menuValue);
}
function changetabcolor(id1,color,bcolor)
{
	
	var objectId=id1;
	id1=bw_GetObject(objectId);
	id1.style.backgroundColor=bcolor;

	

}




function bw_ShowForm(formType)
{
var air = (formType.indexOf('air') > -1)? true : false;
var hotel = (formType.indexOf('hotel') > -1)? true : false;
var car = (formType.indexOf('car') > -1)? true : false;

if (air)
{

	var bwForm = document.bookingWiz;
	var tocity=bwForm.tocity.value;
	var fromcity=bwForm.fromcity.value;
	var bwForm = document.bookingWiz;
	
	bwForm.city1.value=fromcity;
	bwForm.city2.value=tocity;

/*	var bwForm = document.bookingWiz;
	var fromcity=bwForm.fromcity1.value;
	var tocity=bwForm.tocity1.value; 
	bwForm.city1.value=fromcity;
	bwForm.city2.value=tocity;
/*alert(fromcity);
alert(tocity1);
alert(bwForm.city1.value);
alert(bwForm.city2.value);*/


/*
	changetabcolor('changecolorflight1','#31529c','#ffffff');
	changetabcolor('changecolorhotel','#ffffff','#31529c');
	changetabcolor('changecolorcar','#ffffff','#31529c');*/

bw_HideSection('hflighthotel');
bw_HideSection('hflighthotelcar');
bw_ShowSection('hflight');
bw_HideSection('hhotel');
bw_HideSection('hcar');

bw_ShowSection('changecolorhotel1');
bw_HideSection('changecolorhotel');
bw_ShowSection('changecolorcar');
bw_HideSection('changecolorcar1');

bw_ShowSection('flightTypeDiv');
bw_HideSection('bflightTypeDiv');
bw_ShowSection('changecolorflight');
bw_HideSection('changecolorflight1');
bw_ShowSection('city2Div');
bw_HideSection('bcity2Div');
bw_ShowSection('broomsDiv');
bw_HideSection('roomsDiv');
bw_ShowSection('travelerInfoDiv');
bw_HideSection('btravelerInfoDiv');

bw_ChangeField('city1Div', 'city1Span', 'Departing From');
bw_ChangeField('city2Div', 'city2Span', 'Traveling To');
bw_ChangeField('date1Div', 'date1Span', 'Departure Date');
bw_ChangeField('date2Div', 'date2Span', 'Return Date');
bw_ChangeField('adultsDiv', 'adultsSpan', 'Adults (12+)');
bw_ChangeField('childrenDiv', 'childrenSpan', 'Children (2-11)');
}
else if (hotel)
{
	var bwForm = document.bookingWiz;
	var fromcity=bwForm.tocity.value;
	

	bwForm.city1.value=bwForm.tocity.value;
	/*var tocity=bwForm.tocity1.value; 
	bwForm.city1.value=fromcity;*/

bw_HideSection('hflighthotel');
bw_HideSection('hflighthotelcar');
bw_HideSection('hflight');
bw_ShowSection('hhotel');
bw_HideSection('hcar');

bw_ShowSection('changecolorflight1');
bw_HideSection('changecolorflight');
bw_ShowSection('changecolorcar');
bw_HideSection('changecolorcar1');
bw_ShowSection('changecolorhotel');
bw_HideSection('changecolorhotel1');
	/*changetabcolor('changecolorflight','#ffffff','#31529c');
	changetabcolor('changecolorhotel', '#31529c','#ffffff');
	changetabcolor('changecolorcar','#ffffff','#31529c');*/
bw_ShowSection('bflightTypeDiv');
bw_HideSection('flightTypeDiv');
bw_ShowSection('bcity2Div');
bw_HideSection('city2Div');
bw_ShowSection('roomsDiv');
bw_HideSection('broomsDiv');
bw_ShowSection('travelerInfoDiv');
bw_HideSection('btravelerInfoDiv');

bw_ChangeField('city1Div', 'city1Span', 'Traveling To');
bw_ChangeField('city2Div', 'city2Span', '');
bw_ChangeField('date1Div', 'date1Span', 'Check-In Date');
bw_ChangeField('date2Div', 'date2Span', 'Check-Out Date');
bw_ChangeField('adultsDiv', 'adultsSpan', 'Adults (19+)');
bw_ChangeField('childrenDiv', 'childrenSpan', 'Children (0-18)');
var bwForm = document.bookingWiz;
bwForm.singleMenu[3].checked = true;
}
else if (car)
{
	var bwForm = document.bookingWiz;
	var fromcity=bwForm.tocity.value;
	
	bwForm.city1.value=bwForm.tocity.value;
	
/*	var bwForm = document.bookingWiz;
	var fromcity=bwForm.city1.value;
	var tocity=bwForm.city2.value;	
	/*main heading*/
bw_HideSection('hflighthotel');
bw_HideSection('hflighthotelcar');
bw_HideSection('hflight');
bw_HideSection('hhotel');
bw_ShowSection('hcar');
	/*main heading over*/
bw_ShowSection('changecolorflight1');
bw_HideSection('changecolorflight');
bw_ShowSection('changecolorcar1');
bw_HideSection('changecolorcar');
bw_ShowSection('changecolorhotel1');
bw_HideSection('changecolorhotel');


/*changetabcolor('changecolorflight','#ffffff','#31529c');
	changetabcolor('changecolorhotel', '#ffffff','#31529c');
	changetabcolor('changecolorcar','#31529c','#ffffff');*/
bw_ShowSection('bflightTypeDiv');
bw_HideSection('flightTypeDiv');
bw_ShowSection('bcity2Div');
bw_HideSection('city2Div');
bw_ShowSection('broomsDiv');
bw_HideSection('roomsDiv');
bw_ShowSection('btravelerInfoDiv');
bw_HideSection('travelerInfoDiv');

bw_ChangeField('city1Div', 'city1Span', 'Pick-Up City');
bw_ChangeField('city2Div', 'city2Span', '');
bw_ChangeField('date1Div', 'date1Span', 'Pick-Up Date');
bw_ChangeField('date2Div', 'date2Span', 'Drop-Off Date');
bw_ChangeField('adultsDiv', 'adultsSpan', '');
bw_ChangeField('childrenDiv', 'childrenSpan', '');
var bwForm = document.bookingWiz;
bwForm.singleMenu[4].checked = true;
}
if (car && !air && !hotel)
bw_HideSection('travelerInfoDiv');

else
bw_ShowSection('travelerInfoDiv');
if (hotel)
bw_ChangeField('roomsDiv', 'roomsSpan', 'Rooms');
else
bw_ChangeField('roomsDiv', 'roomsSpan', '');

if (air && !hotel && !car)
{
bw_ShowSection('flightTypeDiv');
bw_HideSection('bflightTypeDiv');


	var bwForm = document.bookingWiz;
	if (bwForm.flightType[0].checked == true)
		bw_ShowSection('date2Div');
	else
		bw_HideSection('date2Div');
}
else
{
bw_HideSection('flightTypeDiv');
bw_ShowSection('bflightTypeDiv');
}

if(air && hotel && !car)
{
bw_ShowSection('hflighthotel');
bw_HideSection('hflighthotelcar');
bw_HideSection('hflight');
bw_HideSection('hhotel');
bw_HideSection('hcar');

}
if(air && hotel && car )
	{
	bw_HideSection('hflighthotel');
bw_ShowSection('hflighthotelcar');
bw_HideSection('hflight');
bw_HideSection('hhotel');
bw_HideSection('hcar');
		
	}
if (hotel && !air && !car)
{
var city1Object = bw_GetObject('city1');
if (city1Object.value == '' || city1Object.value == 'city or airport code')
city1Object.value = 'city name';
}
else
{
var city1Object = bw_GetObject('city1');
if (city1Object.value == '' || city1Object.value == 'city name')
city1Object.value = 'city or airport code';
}
var city2Object = bw_GetObject('city2');
if (city2Object.value == '')
city2Object.value = 'city or airport code';
var date1Object = bw_GetObject('date1');
if (date1Object.value == '')
date1Object.value = 'mm/dd/yyyy';
var date2Object = bw_GetObject('date2');
if (date2Object.value == '')
date2Object.value = 'mm/dd/yyyy';
bw_ChangeSpanColor('city1Span', '#000000');
bw_ChangeSpanColor('city2Span', '#000000');
bw_ChangeSpanColor('date1Span', '#000000');
bw_ChangeSpanColor('date2Span', '#000000');
}
function bw_HideSection(sectionDiv)
{
var section = bw_GetObject(sectionDiv);
section.style.display = 'none';

}
function bw_ShowSection(sectionDiv)
{
var section = bw_GetObject(sectionDiv);
section.style.display = 'inline';

}
function bw_ChangeField(fieldDiv, labelSpan, text)
{

if (text == '')
{
	
/*	if(labelSpan=='city2Span')
	{
	bwForm.city1.value=tocity;
	}
	else{
			bwForm.city1.value='city name';	
		}*/
var myFormField = bw_GetObject(fieldDiv);
myFormField.style.display = 'none';


}
else
{
var myFormField = bw_GetObject(fieldDiv);
var myFieldLabel = bw_GetObject(labelSpan);
myFormField.style.display = '';
myFieldLabel.innerHTML = text;

}
}
function bw_ChangeSpanColor(objectId, color)
{
var myObject = bw_GetObject(objectId);
myObject.style.color = color;

}

function datatrack(htype,htriptype,hdeparturecity,harriavalcity,hDdate,hRdate,hadults,hchildren,hrooms)
{
alert (htype+htriptype+hdeparturecity+harriavalcity+hDdate+hRdate+hadults+hchildren+hrooms);
/*document.write ("<?php echo $test="+htype+ "?>");
alert(htype);*/
}
//var test=document.write ("<h1>htype</h1>");

function bw_Validate()
{

	//alert(searchType);
		var bwForm = document.bookingWiz;

		//var formType = '';
		for (var i = 0; i < bwForm.singleMenu.length; i++ )
		{
			if (bwForm.singleMenu[i].checked)
			{
				formType = bwForm.singleMenu[i].value;
				break;
			}
		}
		if (formType == '')
		{
			var menuCb = bw_GetObject('comboMenu');
			formType = menuCb;
		}
		var air = (formType.indexOf('air') > -1)? true : false;
		var hotel = (formType.indexOf('hotel') > -1)? true : false;
		var car = (formType.indexOf('car') > -1)? true : false;
		var isValid = true;
		if (hotel && !air && !car)
		{

			if (bw_ValidateRequiredField('city1', 'city1Span', 'city name') == false)
			isValid = false;
		}
		else
		{
			if (bw_ValidateRequiredField('city1', 'city1Span', 'city or airport code') == false)
			isValid = false;
		}
		
		if (bw_ValidateRequiredField('date1', 'date1Span', 'mm/dd/yyyy') == false)
		{
				isValid = false;
		}
		if (air)
		{
		if (bw_ValidateRequiredField('city2', 'city2Span', 'city or airport code') == false)
		isValid = false;
		}
		if (air && !hotel && !car)
		{
			var bwForm = document.bookingWiz;
			if (bwForm.flightType[0].checked == true)
			{
				if (bw_ValidateRequiredField('date2', 'date2Span', 'mm/dd/yyyy') == false)
				isValid = false;
			}
		}
		else
		{
				if (bw_ValidateRequiredField('date2', 'date2Span', 'mm/dd/yyyy') == false)
				isValid = false;
		}
				if (!isValid)
				{
				alert('Please enter required information (in red)');
				
				return isValid;
				}
	
	
			////////////////////////////tracking function call with data////////////////////////////////////////////
			if(isValid)
				
				{
				
						var htype='';
						var htriptype='';
						var hdeparturecity='';
						var harriavalcity='';
						var hDdate='dd/mm/yyyy';
						var hRdate='dd/mm/yyyy';
						var hadults='1';
						var hchildren='0';
						var hrooms='0';

					
					if(air && !hotel & !car)
					{
						htype='Flights';

						if(bwForm.flightType[0].checked==true)
						{
							 htriptype='Round Trip';
						}
						else if(bwForm.flightType[1].checked==true)
						{
								htriptype='One Way';						
						}
							
							hdeparturecity=bwForm.city1.value;
							harriavalcity=bwForm.city2.value;
							hDdate=bwForm.date1.value;
							hRdate=bwForm.date2.value;
							hadults=bwForm.adults.value;
							hchildren=bwForm.children.value;
							


					}
					else if(!air && hotel & !car)
					{
							htype='Hotel';
							harriavalcity=bwForm.city2.value;
							hDdate=bwForm.date1.value;
							hRdate=bwForm.date2.value;
							hadults=bwForm.adults.value;
							hchildren=bwForm.children.value;
							hrooms=bwForm.rooms.value;
					}
					else if(!air && !hotel & car)
					{
							htype='Car';
							harriavalcity=bwForm.city2.value;
							hDdate=bwForm.date1.value;
							hRdate=bwForm.date2.value;
																	
					}
					else if(air && hotel & !car)
					{
							htype='Flights + Hotel';
							if(bwForm.flightType[0].checked==true)
						{
							 htriptype='Round Trip';
						}
						else if(bwForm.flightType[1].checked==true)
						{
								htriptype='One Way';						
						}
							hdeparturecity=bwForm.city1.value;
							harriavalcity=bwForm.city2.value;
							hDdate=bwForm.date1.value;
							hRdate=bwForm.date2.value;
							hadults=bwForm.adults.value;
							hchildren=bwForm.children.value;
							hrooms=bwForm.rooms.value;
					}
					else if(air && hotel & car)
					{
							htype='Flights + Hotel + Car';
							if(bwForm.flightType[0].checked==true)
						{
							 htriptype='Round Trip';
						}
						else if(bwForm.flightType[1].checked==true)
						{
								htriptype='One Way';						
						}
							hdeparturecity=bwForm.city1.value;
							harriavalcity=bwForm.city2.value;
							hDdate=bwForm.date1.value;
							hRdate=bwForm.date2.value;
							hadults=bwForm.adults.value;
							hchildren=bwForm.children.value;
							hrooms=bwForm.rooms.value;
					}
					/*alert(htype);
					alert(htriptype);
					alert(hdeparturecity);
					alert(harriavalcity + hDdate + hRdate);
					alert(hadults + hchildren + hrooms);
					datatrack(htype,htriptype,hdeparturecity,harriavalcity,hDdate,hRdate,hadults,hchildren,hrooms);*/
					
				return isValid;
				}

			////////////////////////////tracking function end////////////////////////////////////////////
	//}
}
function bw_ValidateRequiredField(objectId, labelId, defaultText)
{
var myObject = bw_GetObject(objectId);
if (myObject.value == '' || myObject.value == defaultText)
{
bw_ChangeSpanColor(labelId, '#ff0000');
return false;
}
else
{
bw_ChangeSpanColor(labelId, '#000000');
return true;
}
}

function urchinTracker(page) {
	return;
}
