﻿/********************************/
/* bookHotel.js					*/
/*	- Implements "abstract"		*/
/*		viewHotelDetails()		*/
/********************************/

/****************************/
/* Abstract Implementations */
/****************************/

function viewHotelDetails(categoryID, hotelID) {
	if (categoryID) {
		var $selection = $('[cat*=' + categoryID + ']');

		if ($selection.length > 0) {
			$selection.click();

			if (hotelID != null) {
				if (hotelID == 0) {
					$('a', $selection.siblings()).eq(0).click();
				}
				else {
					$('[sub*=' + hotelID + ']', $selection.siblings()).click();
				}
			}

			$.scrollTo($selection, 1000);
		}
	}
}

function planVacationClicked() {
	loadHotelListing(1, true);
}

function loadHotelListing(subsetIndex, reloadTickets) {
	var ages = planVacation_getChildAges();

	for (var index = 0; index < ages.length; index++) {
		if (ages[index] < 0) {
			planVacation_getActionButton().siblings('img').remove();
			delete ages;

			alert('Invalid child age(s) selected.');
			return false;
		}
	}

	delete ages;

	hotelResults_refresh(hotelResults_getContainer(), subsetIndex, reloadTickets);
}

function bookHotel_getHotel() {
	var $container = hotelResults_getContainer();

	if (parseInt($container.attr('result-type')) == 3)
		return parseInt($container.attr('result-id'));
	else
		return 0;
}

function bookHotel_getHotelGroup() {
	var $container = hotelResults_getContainer();

	if (parseInt($container.attr('result-type')) == 2)
		return parseInt($container.attr('result-id'));
	else
		return 0;
}