var HotelCode = 'YBIGH';
function prevEmail(ID, emailserver, emailname, emailinner) {
	var span = document.getElementById(ID);
	if (span != null) {
		var str = "<a href='mailto:" + emailname + "@" + emailserver + "'>";
		if (emailinner == '') str += emailname + "@" + emailserver; else str += emailinner;
		str += "</a>";
		span.innerHTML = str;
	}
}
function Focus() { window.focus() }
function Close() { window.close() }
function BreakOutOfFrames() { if (parent != window) { parent.location = location.href } }
function bookMarkPage() { if (document.all) { window.external.AddFavorite(this.location, "Brook Hotels") } }
function addOnloadEvent(b) { if (typeof window.addEventListener != "undefined") { window.addEventListener("load", b, false) } else { if (typeof window.attachEvent != "undefined") { window.attachEvent("onload", b) } else { if (window.onload != null) { var a = window.onload; window.onload = function(c) { a(c); window[b]() } } else { window.onload = b } } } }
function oBookNow(a) { window.open("http://www.hol.co.uk/asp/bookings/availability.aspx?DoSearch=true&HotelCode=" + a, "hol", "screenx=20,screeny=20,top=20,left=20,width=780,height=600,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1") }
function oBookTNow(a) { window.open("http://www.hol.co.uk/asp/bookings/availability.aspx?DoSearch=true&TradeID=955&TradeUserID=2057&HotelCode=" + a, "hol", "screenx=20,screeny=20,top=20,left=20,width=780,height=600,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1") }
function checkDays() { var g = document.getElementById("ctl00_QuickBook1_ddlDay"); var h = document.getElementById("ctl00_QuickBook1_ddlMonth"); var k = document.getElementById("ctl00_QuickBook1_ddlMonthAndYear"); var e = document.getElementById("ctl00_QuickBook1_ddlYear"); if ((g != null && h != null && e != null) || (g != null && k != null)) { var b = g.selectedIndex + 1; var f; var m; if (k != null) { f = parseInt(k.options[k.selectedIndex].value.substring(5, 7)); m = parseInt(k.options[k.selectedIndex].value.substring(0, 4)) } else { f = h.selectedIndex + 1; m = parseInt(e.options[e.selectedIndex].value) } var j = [31, daysInFebruary(m), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; var n = j[f - 1]; var a = false; var l = false; var d = g.length; for (var c = d; c > n; c--) { g.removeChild(g.options[c - 1]); a = true } for (var c = d; c < n; c++) { AddSelectOption(g, c + 1, c + 1, false); l = true } if ((a || l) && g[b - 1] == null) { g.focus(); g.selectedIndex = g.length - 1 } } }
function AddSelectOption(d, c, b, a) { if (d != null && d.options != null) { d.options[d.options.length] = new Option(c, b, false, a) } }
function daysInFebruary(a) { return (((a % 4 == 0) && ((!(a % 100 == 0)) || (a % 400 == 0))) ? 29 : 28) }
function QuickBook() {
	if (!checkDate()) { return false } var b = document.getElementById("ctl00_QuickBook1_ddlDay"); var f = document.getElementById("ctl00_QuickBook1_ddlMonthAndYear"); var g = HotelCode; var h = document.getElementById("ctl00_QuickBook1_ddlRooms"); var a = document.getElementById("ctl00_QuickBook1_ddlNights"); var c = document.getElementById("ctl00_QuickBook1_ddlAdults");
	if (g != null) {
		var e = window.open("about:blank", "hol", "screenx=20,screeny=20,top=20,left=20,width=780,height=600,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1");
		if (e == null) { alert("popup is null?") } else { var d = "http://www.hol.co.uk/asp/bookings/availability.aspx?HotelCode=" + g; d += "&Rooms=" + String(h.selectedIndex + 1); d += "&Nights=" + String(a.selectedIndex + 2); d += "&Adults=" + String(c.selectedIndex + 1); d += "&ArrivalDate=" + f.options[f.selectedIndex].value.substring(0, 4) + "-" + f.options[f.selectedIndex].value.substring(5, 7) + "-" + String(b.selectedIndex + 1); d += "&DoSearch=true#prices"; e.location.href = d } return false
	}
	else { alert("Please choose a hotel..."); g.focus(); return false } 
}
function checkDate() {
	var ddlDay = document.getElementById("ctl00_QuickBook1_ddlDay");
	var ddlMonth = document.getElementById("ctl00_QuickBook1_ddlMonth");
	var ddlMonthAndYear = document.getElementById("ctl00_QuickBook1_ddlMonthAndYear");
	var ddlYear = document.getElementById("ctl00_QuickBook1_ddlYear");
	var dDate;
	var iYear;
	var iMonth;
	var iDay;
	var aMonthDays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	dDate = new Date();
	iDay = dDate.getDate();
	iMonth = dDate.getMonth() + 1; //changed
	iYear = dDate.getFullYear();
	var IDay = ddlDay.selectedIndex + 1; //changed
	var IMonth; var IYear;
	if (ddlMonthAndYear != null) {
		IMonth = parseInt(ddlMonthAndYear.options[ddlMonthAndYear.selectedIndex].value.substring(5, 7), 10);
		IYear = parseInt(ddlMonthAndYear.options[ddlMonthAndYear.selectedIndex].value.substring(0, 4));
	}
	else {
		IMonth = ddlMonth.selectedIndex + 1; //changed
		IYear = parseInt(ddlYear.options[ddlYear.selectedIndex].value);
	}
	// now, check if the year is OK
	if (IYear == iYear && IMonth < iMonth) {
		alert("You cannot check the availability of dates prior to today.");
		return false;
	}
	if (IYear == iYear && IMonth == iMonth && IDay < iDay) {
		alert("You cannot check the availability of dates prior to today.");
		return false;
	}
	// check that the upper date limit is OK
	if (IMonth != 2 && IDay > aMonthDays[IMonth]) {
		alert("You have chosen an invalid date in the month.");
		return false;
	}
	// check the date in february is correct
	if (IMonth == 2 && IDay > daysInFebruary(IYear)) {
		alert("You have chosen an invalid date in February.");
		return false;
	}
	return true;
}

function googleTranslateElementInit() {
	new google.translate.TranslateElement({
		pageLanguage: 'en'
	}, 'google_translate_element');
}

//called on page load (first 'full, non ajax' load);
$(document).ready(function() {
	main();
});
function main() {
	//track click-throughs to 3rd party pages via Google Analytics...
	//$("a[rel*='nofollow']").click(function() {
	$("a[target*='_blank']").click(function() {
		if (typeof (pageTracker) != "undefined")
			pageTracker._trackPageview('/outgoing/' + $(this).attr('href'));
	});


	$('a.lightbox').lightBox({ fixedNavigation: true }); // Select all links with lightbox class
}