

var calendar;
var hotelTabBar, flightTabBar, carTabBar, restaurantTabBar, golfTabBar;

function page_init()
{
		if(document.images)
		{
			hotelTabBar = new Image() ;
			hotelTabBar.src = '/images/findMe/hotel_a.gif' ;

			flightTabBar = new Image() ;
			flightTabBar.src = '/images/findMe/flight_a.gif' ;

			carTabBar = new Image() ;
			carTabBar.src = '/images/findMe/car_a.gif' ;

			restaurantTabBar = new Image() ;
			restaurantTabBar.src = '/images/findMe/restaurant_a.gif' ;

			golfTabBar = new Image() ;
			golfTabBar.src = '/images/findMe/golf_a.gif';
		}
		calendar = new Calendar();
		document.body.attachEvent("onclick", hideCalendar);
		document.getElementById("btnSelectCheckOutDate").attachEvent("onclick", btnSelectCheckOutDate_click);
		document.getElementById("btnSelectCheckInDate").attachEvent("onclick", btnSelectCheckInDate_click);
		document.getElementById("btnSelectPickUpDate").attachEvent("onclick", btnSelectPickUpDate_click);
		document.getElementById("btnSelectDropOffDate").attachEvent("onclick", btnSelectDropOffDate_click);
		document.getElementById("btnSelectDprtDate").attachEvent("onclick", btnSelectDprtDate_click);
		document.getElementById("btnSelectRtrnDate").attachEvent("onclick", btnSelectRtrnDate_click);
}


function tabHotel_Click()
	{
		showTab("hotel");
	}


function tabFlight_Click()
{
	showTab("flight");
}


function tabCar_Click()
{
	showTab("car");
}


function tabRestaurant_Click()
{
	showTab("restaurant");
}

function showTab(name)
{
	tabBar.src = eval(name + "TabBar.src;");
	hideAllTabs();
	eval(name+"SearchForm.style.display = 'block';");
	event.returnValue = false;
	return false;
}


function hideAllTabs()
	{
		hotelSearchForm.style.display = 'none';
		flightSearchForm.style.display = 'none';
		carSearchForm.style.display = 'none';
		restaurantSearchForm.style.display = 'none';
	}
	
function btnSelectCheckOutDate_click()
{
		CalendarControl_Button_click("txtCheckOutDate")
}

function btnSelectCheckInDate_click()
{
		CalendarControl_Button_click("txtCheckInDate")
}

function btnSelectPickUpDate_click()
{
		CalendarControl_Button_click("txtPickUpDate")
}

function btnSelectDropOffDate_click()
{
		CalendarControl_Button_click("txtDropOffDate")
}

function btnSelectDprtDate_click()
{
		CalendarControl_Button_click("txtDprtDate")
}

function btnSelectRtrnDate_click()
{
		CalendarControl_Button_click("txtRtrnDate")
}

function CalendarControl_Button_click(dateFieldID)
{
		event.cancelBubble = true;
		var elem = event.srcElement;
		var parent = elem.offsetParent;
		var x = elem.offsetLeft;
		var y = elem.offsetTop;
		while (parent.tagName.toUpperCase() != "BODY")
		{
			x += parent.offsetLeft;
			y += parent.offsetTop;
			parent = parent.offsetParent;
		}

		var txtDate = document.getElementById(dateFieldID);
		var strDate = txtDate.value;
		var date;
		try
		{
				date = parseDate(strDate);
		}
		catch(e)
		{
				date = new Date();
		}
		calendar.setDate(date);
		calendar.moveTo(x-136, y-142);
		calendar.dateSelected = new Function("{CalendarControl_DateSelected(\""+ dateFieldID +"\");}");
		calendar.show();
}

function CalendarControl_DateSelected(fieldID)
{
		var txtDate = document.getElementById(fieldID);
		var date = calendar.date;
		txtDate.value = formatDateTime(date);
		window.setTimeout(hideCalendar, 200);
	
}

function frmCarSearch_submit()
{
	var pud = parseDate(document.forms["frmCarSearch"].elements["pickUpDate"].value);
	var dod = parseDate(document.forms["frmCarSearch"].elements["dropOffDate"].value);

	document.forms["frmCarSearch"].elements["pudate_mo"].value = pud.getMonth()+1;
	document.forms["frmCarSearch"].elements["pudate_dy"].value = pud.getDate();
	document.forms["frmCarSearch"].elements["dodate_mo"].value = dod.getMonth()+1;
	document.forms["frmCarSearch"].elements["dodate_dy"].value = dod.getDate();
	document.forms["frmCarSearch"].submit();
}