﻿var ShortForms =
{

	Reservation:
	{
		Continue: function () {
			var fastBookingRootUrl = 'http://www.fastbookings.biz/DIRECTORY/';
			var clusterName = 'silifeclasshtls';

			// Variables & Data
			var isValid = true;
			var hotel = document.getElementById('ShortForm_Reservation_Hotel').value;
			var arrivalDay = 0;
			var arrivalMonth = 0;
			var arrivalYear = 0;
			var stayNights = parseInt(document.getElementById('ShortForm_Reservation_Stay').options[document.getElementById('ShortForm_Reservation_Stay').selectedIndex].value);
			var adults = parseInt(document.getElementById('ShortForm_Reservation_Adults').options[document.getElementById('ShortForm_Reservation_Adults').selectedIndex].value);
			var children = parseInt(document.getElementById('ShortForm_Reservation_Children').options[document.getElementById('ShortForm_Reservation_Children').selectedIndex].value);
			var code = document.getElementById('ShortForm_Reservation_Code').value;
			var language = document.getElementById('ShortForm_Reservation_Language').value;
			var gaProfile = "";

			// Data validity check
			var arrival = document.getElementById('ShortForm_Reservation_Arrival').value.split(".");
			if (arrival.length >= 3) {
				arrivalDay = parseInt(arrival[0]);
				arrivalMonth = parseInt(arrival[1]);
				arrivalYear = parseInt(arrival[2]);
			}
			var today = new Date();
			if ((isNaN(arrivalDay)) || (arrivalDay < 1) || (arrivalDay > 31)) isValid = false;
			if ((isNaN(arrivalMonth)) || (arrivalMonth < 1) || (arrivalMonth > 12)) isValid = false;
			if ((isNaN(arrivalYear)) || (arrivalYear < today.getFullYear()) || (arrivalYear > today.getFullYear() + 10)) isValid = false;
			if (isNaN(stayNights) || stayNights < 1 || stayNights > 31) isValid = false;
			if (isNaN(adults) || adults < 1 || adults > 4) isValid = false;
			if (isNaN(children) || children < 0 || children > 2) isValid = false;

			// Transfer GA data
			var gaIsUsed = false;
			if (gaIsUsed) {
				var time = new Date();
				var sessionId = time.getSeconds() + '' + Math.floor(Math.random() * 1000000000);

				gaProfile = escape("SESSION=" + sessionId + "&CODE=GoogleAnalytics");

				pageTracker._initData();
				new Image().src = pageTracker._getLinkerUrl(fastBookingRootUrl + "ga.phtml?clusterName=" + encodeURIComponent(clusterName) + "&id=" + encodeURIComponent(sessionId));
				pageTracker._trackPageview('/FastBooking/ClicBook');
			}

			// Open booking
			if (isValid) {
				var url = fastBookingRootUrl + 'dispoprice.phtml' +
						'?Clusternames=' + encodeURIComponent(clusterName) +
						'&showPromotions=3' +
						'&Hotelnames=' + encodeURIComponent(hotel) +
						'&fromday=' + encodeURIComponent(arrivalDay) +
						'&frommonth=' + encodeURIComponent(arrivalMonth) +
						'&fromyear=' + encodeURIComponent(arrivalYear) +
						'&nbdays=' + encodeURIComponent(stayNights) +
						'&adulteresa=' + encodeURIComponent(adults) +
						'&enfantresa=' + encodeURIComponent(children) +
						'&AccessCode=' + encodeURIComponent(code) +
						'&langue=' + encodeURIComponent(language) +
						'&profil=' + encodeURIComponent(gaProfile);
				window.open(url, 'dispoprice', 'toolbar=no,width=800,height=550,menubar=no,scrollbars=yes,resizable=yes');
			}

		}
	},

	Inquiry:
	{
}

};