﻿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, "Far2Travel 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 + "#prices", "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 + "#prices", "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 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 = $(".qbddlDay")[0];
	var f = $(".qbddlMonthAndYear")[0];
	var g = $(".qbddlHotel")[0];
	var h = $(".qbddlRooms")[0];
	var a = $(".qbddlNights")[0];
	var c = $(".qbddlAdults")[0];
	if (g.selectedIndex > 0) {
		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.options[g.selectedIndex].value;
			d += "&Rooms=" + String(h.selectedIndex + 1);
			d += "&Nights=" + String(a.selectedIndex + 1);
			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";
			if (d == null)
				alert('d is null?');
			e.location.href = d;
		}
		return false;
	} else {
		alert("Please choose a hotel...");
		g.focus();
		return false
	}
}
function checkDate() {
	var ddlDay = $(".qbddlDay")[0];
	var ddlMonth = $(".qbddlMonth")[0];
	var ddlMonthAndYear = $(".qbddlMonthAndYear")[0];
	var ddlYear = $(".qbddlYear")[0];

	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;

}



//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'));

	});

}



/* This Java script adds "visible" and "invisible" class names to 
DIV tags which will show or hide the div when styled thru CSS. 
*/
function ShowCopy() {
	document.getElementById("expanding_copy").className = "prompt";

	document.getElementById("collapse").className = "prompt";

	document.getElementById("expand").className = "exitus";
}

function HideCopy() {
	document.getElementById("expanding_copy").className = "exitus";

	document.getElementById("expand").className = "prompt";

	document.getElementById("collapse").className = "exitus";

}


function ShowCopy1() {
	document.getElementById("expanding_copy1").className = "prompt";

	document.getElementById("collapse1").className = "prompt";

	document.getElementById("expand1").className = "exitus";
}

function HideCopy1() {
	document.getElementById("expanding_copy1").className = "exitus";

	document.getElementById("expand1").className = "prompt";

	document.getElementById("collapse1").className = "exitus";

}

function ShowCopy2() {
	document.getElementById("expanding_copy2").className = "prompt";

	document.getElementById("collapse2").className = "prompt";

	document.getElementById("expand2").className = "exitus";



}

function HideCopy2() {
	document.getElementById("expanding_copy2").className = "exitus";

	document.getElementById("expand2").className = "prompt";

	document.getElementById("collapse2").className = "exitus";

}

function ShowCopy3() {
	document.getElementById("expanding_copy3").className = "prompt";

	document.getElementById("collapse3").className = "prompt";

	document.getElementById("expand3").className = "exitus";



}

function HideCopy3() {
	document.getElementById("expanding_copy3").className = "exitus";

	document.getElementById("expand3").className = "prompt";

	document.getElementById("collapse3").className = "exitus";

}

function ShowCopy4() {
	document.getElementById("expanding_copy4").className = "prompt";

	document.getElementById("collapse4").className = "prompt";

	document.getElementById("expand4").className = "exitus";



}

function HideCopy4() {
	document.getElementById("expanding_copy4").className = "exitus";

	document.getElementById("expand4").className = "prompt";

	document.getElementById("collapse4").className = "exitus";

}

function ShowCopy5() {
	document.getElementById("expanding_copy5").className = "prompt";

	document.getElementById("collapse5").className = "prompt";

	document.getElementById("expand5").className = "exitus";



}

function HideCopy5() {
	document.getElementById("expanding_copy5").className = "exitus";

	document.getElementById("expand5").className = "prompt";

	document.getElementById("collapse5").className = "exitus";

}
function ShowCopy6() {
	document.getElementById("expanding_copy6").className = "prompt";

	document.getElementById("collapse6").className = "prompt";

	document.getElementById("expand6").className = "exitus";



}

function HideCopy6() {
	document.getElementById("expanding_copy6").className = "exitus";

	document.getElementById("expand6").className = "prompt";

	document.getElementById("collapse6").className = "exitus";

}

function ShowCopy7() {
	document.getElementById("expanding_copy7").className = "prompt";

	document.getElementById("collapse7").className = "prompt";

	document.getElementById("expand7").className = "exitus";



}

function HideCopy7() {
	document.getElementById("expanding_copy7").className = "exitus";

	document.getElementById("expand7").className = "prompt";

	document.getElementById("collapse7").className = "exitus";

}

function ShowCopy8() {
	document.getElementById("expanding_copy8").className = "prompt";

	document.getElementById("collapse8").className = "prompt";

	document.getElementById("expand8").className = "exitus";



}

function HideCopy9() {
	document.getElementById("expanding_copy9").className = "exitus";

	document.getElementById("expand9").className = "prompt";

	document.getElementById("collapse9").className = "exitus";

}



