// Developed by Ermisoft LLC.

function Newsletter() 
{
	var bSubmit = true;
	
	if (document.frmNewsletter.Name.value == '' || document.frmNewsletter.Name.value == 'your name') {
		alert('Please enter your name.')
		document.frmNewsletter.Name.focus();
		bSubmit = false;
	}

	if (bSubmit && (document.frmNewsletter.Email.value == '' || document.frmNewsletter.Email.value == 'your email address')) {
		alert('Please enter your email address.')
		document.frmNewsletter.Email.focus();
		bSubmit = false;
	}

	if (bSubmit) document.frmNewsletter.submit();
}

function NewsletterName() 
{
	if (document.frmNewsletter.Name.value == 'your name')
	document.frmNewsletter.Name.value = '';
}

function NewsletterEmail() 
{
	if (document.frmNewsletter.Email.value == 'your email address')
	document.frmNewsletter.Email.value = '';
}

function goLink(sURL) 
{
	var re;
	re = /~/g;
	
	sURL = sURL.replace('http|', 'http://');
	sURL = sURL.replace(re, '.');
	
	location.href = sURL;
}

function goLinkBlank(sURL) 
{
	var re;
	re = /~/g;
	
	sURL = sURL.replace('http|', 'http://');
	sURL = sURL.replace(re, '.');
	
	window.open(sURL, '_blank');
}

function goResort(sElem) 
{
	var elSel = document.frmResort.lstItems;
	if (sElem) elSel = eval('document.frmResort.'+sElem);

	var sURL = elSel.options[elSel.selectedIndex].value;
	if (sURL.length > 0) 
		location.href = sURL
	else {
		alert('Please select item');
		elSel.focus();
	};
}


function openDlg(url, name, id, width, height) 
{
	if(isNaN(numID = parseInt(id, 10)))
		numID = id.substring(1, (id.length > 5)?5:id.length);
	openWindow(url, name + numID, width, height, "status=no,toolbar=no,resizable=yes,scrollbars=no,menubar=no");
}

function openDlgPrint(url, name, id, width, height) 
{
	if(isNaN(numID = parseInt(id, 10)))
		numID = id.substring(1, (id.length > 5)?5:id.length);
	openWindow(url, name + numID, width, height, "status=yes,toolbar=yes,resizable=yes,scrollbars=yes,menubar=yes");
}

function openWindow(url, name, width, height, features) {
	var win;
	var top = 0;
	var left = 0;
	
	if (screen.width > width) left = (screen.width - width) / 2;
	if (screen.height > height) top = (screen.height - height) / 2;
	
	if (typeof(features) == "undefined") win = window.open(url, name, 'left='+left+',top='+top+',screenX='+left+',screenY='+top+',width='+width+',height='+ height);
	else win = window.open(url, name, 'left='+left+',top='+top+',screenX='+left+',screenY='+top+',width='+width+',height='+ height +', ' + features);
		
	if (navigator.appName != 'Microsoft Internet Explorer')  { if ( window.focus )  win.focus()};
}

function closeWindow(reload, frmName) {
	if (reload == 'reload') 
		if (!top.opener.closed) {
			eval('frm = top.opener.document.' + frmName);
			if (frm) frm.submit();
		}
	
	top.close();
}

function validateEmail(strValue) {
	var objRegExp  =  /(^\w([\w\.\-\_]*)\@[\w\-\_]+\.([\w\-\_]+\.)*\w+$)/; 
	return objRegExp.test(strValue);
}

function getRandom() {
	return Math.random();
}

function getRandomDlgID() {
	return Math.round(getRandom() * 10000);
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function FormatN(iNum, iPos) {
	var iNewNum = iNum;
	for (var i=iNewNum.toString().length; i<iPos; i++)
		iNewNum = '0' + iNewNum;
	return iNewNum;
}
function Page(frm, nPage) {
	frm.target = "";
	frm.CurPage.value = nPage;
	frm.submit();
}
function DoSortOpt(frmEx) {
	var frm = document.frmSearchResult;
	
	frm.target = "";
	frm.CurPage.value = 1;
	frm.PrintList.value = '';
	frm.SortOpt.value = frmEx.SortOpt.options[frmEx.SortOpt.selectedIndex].value;
	frm.submit();
}

function DoFilterOpt(frmEx) {
	var frm = document.frmSearchResult;
	
	frm.target = "";
	frm.CurPage.value = 1;
	frm.PrintList.value = '';
	frm.FilterOpt.value = frmEx.FilterOpt.options[frmEx.FilterOpt.selectedIndex].value;
	frm.submit();
}

function DoSort(frmEx, sSortBy) {
	var frm = document.frmSearchResult;
	
	frm.target = "";
	frm.CurPage.value = 1;
	frm.PrintList.value = '';
	frm.SortBy.value = sSortBy;
	frm.SortDir.value = frmEx.SortDir.options[frmEx.SortDir.selectedIndex].value;
	frm.submit();
}
function DoFilterStars(frmEx) {
	var frm = document.frmSearchResult;
	
	frm.target = "";
	frm.CurPage.value = 1;
	frm.PrintList.value = '';
	frm.Stars.value = frmEx.Stars.selectedIndex;
	frm.submit();
}
function DoFilterPrice(frmEx) {
	var frm = document.frmSearchResult;
	
	frm.target = "";
	frm.CurPage.value = 1;
	frm.PrintList.value = '';
	frm.PriceRange.value = frmEx.PriceRange.options[frmEx.PriceRange.selectedIndex].value;
	frm.submit();
}

function DoQuickLink(frmEx) {
	if (frmEx.HotelQuickLink.selectedIndex <= 0) {
		alert('Please select a Hotel');
		frmEx.HotelQuickLink.focus();
		return;
    	};

	location.href = 'hotel.asp?' + frmEx.HotelQuickLink.options[frmEx.HotelQuickLink.selectedIndex].value;
}

function DoRefresh(frm) {
	frm.target = "";
	frm.submit();
}

function DoHotelList(frm, sValue) {
	frm.target = "";
	frm.CurPage.value = 1;
	frm.PrintList.value = '';
	frm.HotelList.value = sValue;
	frm.submit();
}
function DoPrintList(frm) {
	frm.target = "_blank";
	frm.PrintList.value = 1;
	frm.submit();
}

function OpenAni(sType) {
	var frm = document.frmAni;
	if (frm) {
		frmAni.Action.value = '';
	}
	
	openWindow('ani.asp?ani=' + sType, 'winAni', 320, 270, 'fullscreen=yes,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no')
}

function GoBack() {
	history.go(-1);
}

function BookAccomOnly() {
	var frm = document.frmSearch;

	
	for (i = 0; i <= frm.HLType.length - 1; i++) 
		if (frm.HLType[i].value == 'HO')  {
			frm.HLType[i].checked = true;
			setHLType();
		}
	
	SearchHotels();
}

function ConfirmFlightHotel(sFlightID) {
	OpenAni('3');

	var frm = document.frmSearchResult;

	frm.target = "";
	frm.action = "hotels.asp";
	
	frm.Action.value = "get";
	frm.FlightID.value = sFlightID;
	frm.FilterOpt.value = "";

	frm.submit();
}

function ConfirmCharter(sFlightID) {
	var frm = document.frmSearchResult;

	frm.target = "";
	frm.action = "valuation1.asp";
	
	frm.Action.value = "charter";
	frm.FlightID.value = sFlightID;
	frm.FilterOpt.value = "";

	frm.submit();
}

function ConfirmFlight(sFlightID) {
	OpenAni('3');

	var frm = document.frmSearchResult;

	frm.target = "";
	frm.action = "valuation1.asp";
	
	frm.Action.value = "get";
	frm.FlightID.value = sFlightID;
	frm.FilterOpt.value = "";

	frm.submit();
}

function ConfirmCostHotelOnly(sConfirmInfo, searchHotel) {
	var frm = document.frmSearchResult;
	frm.FlightID.value = "";

	ConfirmCost(sConfirmInfo, searchHotel);
}

function ConfirmCost(sConfirmInfo, searchHotel) {
	var frm = document.frmSearchResult;
	
	if (typeof(searchHotel) != "undefined") {
		if (searchHotel == '1') frm = document.frmSearchResultHotel;
	}
	
	frm.target = "";
	frm.action = "valuation1.asp";
	
	frm.ConfirmInfo.value = sConfirmInfo;
	
	var nRooms = parseInt(frm.Rooms.value);
	
	if (sConfirmInfo.charAt(0) == '0' &&  nRooms > 1) {
		var bSameBoard = true;
		var arrConfirmInfo = sConfirmInfo.split('|');
		for (var i=1; i<nRooms; i++) {
			var el1, el2;
			eval('var sel1 = frm.room' + arrConfirmInfo[2] + '_' + i);
			eval('var sel2 = frm.room' + arrConfirmInfo[2] + '_' + (i+1));
			if (sel1.length) {
				for (var j=0; j<sel1.length; j++)
					if (sel1[j].checked) el1 = sel1[j];
			} else {
				el1 = sel1;
			}
			if (sel2.length) {
				for (var j=0; j<sel2.length; j++)
					if (sel2[j].checked) el2 = sel2[j];

			} else {
				el2 = sel2;
			}

			if (el1 && el2) {
				var sEl1 = el1.value.split('|');
				var sEl2 = el2.value.split('|');
				if (sEl1[1] != sEl2[1]) bSameBoard = false;
			}
		}
		if (!(bSameBoard)) {
			alert('Board basis should be same for all rooms.');
		}
		else
			frm.submit();

	}
	else
		frm.submit();
}

function ValuateRH(sURL) {
	var frm = document.frmValuate;
	frm.RHArrivals.value = "1";
	
	Valuate(sURL);
}

function ValuateAcc(sURL) {
	var frm = document.frmValuate;
	frm.RHArrivals.value = "0";
	
	Valuate(sURL);
}

function Valuate(sURL) {
	var frm = document.frmValuate;
	frm.ByPhone.value = "";
	frm.target = "";
	frm.action = sURL + "valuation2.asp";
	
	frm.submit();
}

function selectTransfer() {
	nTransferPrice = getTransferPrice();
	
	var elSP = document.all('idTransferCost');
	if (elSP) elSP.innerHTML = formatGBP(nTransferPrice);

	var elSP = document.all('idTransferCostT');
	if (elSP) elSP.innerHTML = formatGBP(nTransferPrice);
}

function getTransferPrice() {
	var frm = document.frmValuate;
	
	nPrice = 0;
	
	if (frm.RHTransferCode) {
		var sel1 = frm.RHTransferCode;
		for (var j=0; j<sel1.length; j++)
			if (sel1[j].checked) {
				nPrice = nTransferArr[j];
				if (nTransferArrShar[j] == '1')
					nPrice = nPrice * frm.RHParty[frm.RHParty.selectedIndex].value;
			}                       
	}
	return nPrice;
}

function selectBaggage() {
	nBaggagePrice = getBaggagePrice();
	
	var elSP = document.all('idBaggageCost');
	if (elSP) elSP.innerHTML = formatGBP(nBaggagePrice);
	
	var elSP = document.all('idBaggageCostT');
	if (elSP) elSP.innerHTML = formatGBP(nBaggagePrice);
}

function getBaggagePrice() {
	var frm = document.frmValuate;
	var iQty;
	
	nPrice = 0;
	
	var sel1 = frm.BaggageCode;
	if (sel1) 
		if (sel1.length) {
			for (var j=0; j<sel1.length; j++)
			if (sel1[j].checked) {
			iQty = parseInt(frm.BaggageCodeQty[j].value);
			if (iQty < 1) {
				iQty = 1;
				frm.BaggageCodeQty[j].value = iQty;
			}
			nPrice = nPrice + nBaggageArr[j] * iQty;
			}
		}
		else {
			if (sel1.checked) {
			iQty = parseInt(frm.BaggageCodeQty.value);
			if (iQty < 1) {
				iQty = 1;
				frm.BaggageCodeQty.value = iQty;
			}
			nPrice = nPrice + nBaggageArr[0] * iQty;
			}
		}

	return nPrice;
}

function showAccPrice() {
	var elSP = document.all('idAccCost');
	if (elSP) elSP.innerHTML = formatGBP(nAccPrice);
	var elSP = document.all('idAccCostT');
	if (elSP) elSP.innerHTML = formatGBP(nAccPrice);
}

function showFlightPrice() {
	var elSP = document.all('idFlightCost');
	if (elSP) elSP.innerHTML = formatGBP(nFlightPrice);
	var elSP = document.all('idFlightCostT');
	if (elSP) elSP.innerHTML = formatGBP(nFlightPrice);
}

function showHolidayPrice() {
	showAccPrice();
	showFlightPrice();
	selectBaggage();
	selectTransfer();

	var nHolPrice = nFlightPrice + nAccPrice + nTransferPrice + nBaggagePrice;
	
	var elSP = document.all('idHolPrice');
	if (elSP) elSP.innerHTML = formatGBP(nHolPrice);
	
	var elSP = document.all('idHolPriceFlight');
	if (elSP) elSP.innerHTML = formatGBP(nHolPrice);
	var elSP = document.all('idHolPriceAcc');
	if (elSP) elSP.innerHTML = formatGBP(nHolPrice);
	var elSP = document.all('idHolPriceTransfer');
	if (elSP) elSP.innerHTML = formatGBP(nHolPrice);
	var elSP = document.all('idHolPriceBaggage');
	if (elSP) elSP.innerHTML = formatGBP(nHolPrice);
}

function formatCurrency(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

function formatGBP(amount)
{
	return ' &pound; ' + formatCurrency(amount);
}


function CheckPromoCode()
{
	var frm = document.frmConfirmBooking;
	frm.ByPhone.value = "";
	frm.target = "";
	frm.action = "valuation2.asp";
	
	if (frm.PromoCode.value == '') 
	{
	alert('Please enter promotional code');
	frm.PromoCode.focus();
	return false;
	};

	frm.submit();
}

function ShowEmailFriend() {
	var elItem = document.all("dvEmailFriend");
	if (elItem) elItem.style.display = "inline";
	
	var frm = document.frmEmailFriend;
	
	frm.FromName.focus();
}

function EmailFriend() {
	var frm = document.frmEmailFriend;
	
	if (frm.FromName.value == '') 
	{
	alert('Please enter "Your Name"');
	frm.FromName.focus();
	return false;
	};

	if (frm.FromEmail.value == '') 
	{
	alert('Please enter "Your Email"');
	frm.FromEmail.focus();
	return false;
	};

	if (frm.ToName.value == '') 
	{
	alert('Please enter "Friend Name"');
	frm.ToName.focus();
	return false;
	};

	if (frm.ToEmail.value == '') 
	{
	alert('Please enter "Friend Email"');
	frm.ToEmail.focus();
	return false;
	};

	
	frm.submit();
}

function ShowHotelReview() {
	var elItem = document.all("dvPostHotelReview");
	if (elItem) elItem.style.display = "inline";
	
	var frm = document.frmPostHotelReview;
	
	frm.Name.focus();
}

function Alternatives() {
	var frm = document.frmSearchResult;
	
	frm.Action.value = 'get';
	frm.ZoneDesc.value = '';
	frm.Zone.value = '';
	
	frm.submit();
}

function RoomRequest() {
	var frm = document.frmRoomRequest;
	
	if (frm.Name.value == '') 
	{
	alert('Please enter "Your Name"');
	frm.Name.focus();
	return false;
	};

	if (frm.Email.value == '') 
	{
	alert('Please enter "Your Email"');
	frm.Email.focus();
	return false;
	};

	if (frm.DaytimePhone.value == '') 
	{
	alert('Please enter "Daytime Phone"');
	frm.DaytimePhone.focus();
	return false;
	};

	if (frm.Destination.value == '') 
	{
	alert('Please enter "Destination"');
	frm.Destination.focus();
	return false;
	};

	if (frm.RoomType.value == '') 
	{
	alert('Please enter "Room Type"');
	frm.RoomType.focus();
	return false;
	};

	if (frm.Arrival.value == '') 
	{
	alert('Please enter "Arrival"');
	frm.Arrival.focus();
	return false;
	};

	if (frm.Duration.value == '') 
	{
	alert('Please enter "Duration"');
	frm.Duration.focus();
	return false;
	};

	if (frm.Adults.value == '') 
	{
	alert('Please enter "Adults"');
	frm.Adults.focus();
	return false;
	};

	if (frm.Children.value == '') 
	{
	alert('Please enter "Children"');
	frm.Children.focus();
	return false;
	};
	
	frm.submit();
}


function PostHotelReview()
{
	var frm = document.frmPostHotelReview;
	
	if (frm.Name.value == '') 
	{
	alert('Please enter your name');
	frm.Name.focus();
	return false;
	};
	if (frm.Location.value == '') 
	{
	alert('Please enter home town');
	frm.Location.focus();
	return false;
	};
	if (frm.Notes.value == '') 
	{
	alert('Please review hotel');
	frm.Notes.focus();
	return false;
	};
	
	frm.submit(); 
}

function ConfirmRH() {
	var frm = document.frmConfirmBooking;

	frm.ByPhone.value = "";
	frm.target = "";
	frm.action = "";

	if (!(checkSelection(frm.RHTransferCode))) {
		alert('Please select transfer type');
		return;
	}

	frm.Action.value = '';
	frm.submit(); 

}

function AccOnly() {
	var frm = document.frmConfirmBooking;

	frm.ByPhone.value = "";
	frm.RHArrivals.value = "0";
	frm.target = "";
	frm.action = "";
	frm.Action.value = '';
	frm.submit(); 

}

function EmptyRH() {
	var frm = document.frmConfirmBooking;
	frm.ByPhone.value = "";
	frm.RHArrivals.value = "2";
	frm.target = "";
	frm.action = "";

	frm.Action.value = '';
	frm.submit(); 

}

function ConfirmBooking() {
	var frm = document.frmConfirmBooking;
	frm.ByPhone.value = "";
	frm.target = "";
	frm.action = "confirm_booking.asp";
	
	if (sProcess == 'process') {
	alert('Please wait...');
	return false;
	};
	
	if (frm.PaymentVariant.length > 1) {
		if (!frm.PaymentVariant[0].checked && !frm.PaymentVariant[1].checked) {
			alert('Please select "Payment Type"');
			frm.PaymentVariant[0].focus();
			return false;
		}
	}
		
	if (frm.CCType.selectedIndex <= 0) 
	{
	alert('Please select "Card Type"');
	frm.CCType.focus();
	return false;
	};

	if (frm.CCHolder.value == '') 
	{
	alert('Please enter "Card Holder"');
	frm.CCHolder.focus();
	return false;
	};
	if (frm.CCNo.value == '') 
	{
	alert('Please enter "Card Number"');
	frm.CCNo.focus();
	return false;
	};


	var ccnum = frm.CCNo.value;
	var cctype = frm.CCType.options[frm.CCType.selectedIndex].value;

	if (cctype == 'Visa')
		if (verifyCardExt('Delta',ccnum)) {
		alert('You have selected the incorrect card type. Please try again using Visa Delta.');
		frm.CCType.focus();
		return false;
		}

	if (!verifyCardExt(cctype,ccnum)) {
            alert("You have entered either an incorrect number or selected the wrong card type - please check and re-enter details.\n\n" +
		  "Prefer to book by phone? \n" +
		  "Reservations helpline: \n" +
		  "0844 251 0454 \n" +
		  "Opening hours: \n" +
		  "Monday - Friday 9:00am - 9:00pm\n" +
		  "Saturday - Sunday 9:00am - 5:00pm\n");
		frm.CCNo.focus();
		return false;
	}

	if (frm.CCSecCode.value == '') 
	{
	alert('Please enter "Security Code"');
	frm.CCSecCode.focus();
	return false;
	};

	if (frm.CCPassenger_Address1.value == '') 
	{
	alert('Please enter "Address"');
	frm.CCPassenger_Address1.focus();
	return false;
	};
	if (frm.CCPassenger_Town.value == '') 
	{
	alert('Please enter "Town/City"');
	frm.CCPassenger_Town.focus();
	return false;
	};
	if (frm.CCPassenger_County.value == '') 
	{
	alert('Please enter "County"');
	frm.CCPassenger_County.focus();
	return false;
	};
	if (frm.CCPassenger_Postcode.value == '') 
	{
	alert('Please enter "Postcode"');
	frm.CCPassenger_Postcode.focus();
	return false;
	};
	if (frm.CCPassenger_HomePhone.value == '') 
	{
	alert('Please enter "Daytime Phone"');
	frm.CCPassenger_HomePhone.focus();
	return false;
	};
	
	if (frm.Passenger_FirstName.value == '') 
	{
	alert('Please enter "First Name"');
	frm.Passenger_FirstName.focus();
	return false;
	};
	if (frm.Passenger_LastName.value == '') 
	{
	alert('Please enter "Last Name"');
	frm.Passenger_LastName.focus();
	return false;
	};
	if (frm.Passenger_Email.value == '') 
	{
	alert('Please enter "EMail"');
	frm.Passenger_Email.focus();
	return false;
	};
	if (frm.Passenger_ConfirmEmail.value != frm.Passenger_Email.value) 
	{
	alert('Please reconfirm "Email"');
	frm.Passenger_ConfirmEmail.focus();
	return false;
	};

	if (frm.RHTransferCode.value != '') 
	{
		if (frm.RHDepartureAirport.value == '') 
		{
		alert('Please enter "Departure Airport"');
		frm.RHDepartureAirport.focus();
		return false;
		};
		if (frm.RHOutboundFlight.value == '') 
		{
		alert('Please enter "Outbound Flight Number"');
		frm.RHOutboundFlight.focus();
		return false;
		};
		if (frm.RHInboundFlight.value == '') 
		{
		alert('Please enter "Inbound Flight Number"');
		frm.RHInboundFlight.focus();
		return false;
		};
		if (frm.RHPropertyName.value == '') 
		{
		alert('Please enter "Property Name"');
		frm.RHPropertyName.focus();
		return false;
		};

	};


	if (frm.Reviewed.checked == false) 
	{
	alert('Please review and accept booking details');
	frm.Reviewed.focus();
	return false;
	};
	if (frm.HaveRead.checked == false) 
	{
	alert('Please read and accept the booking terms and conditions');
	frm.HaveRead.focus();
	return false;
	};
	
	notePayment();
	
	frm.Action.value = 'process';
	sProcess = 'process';
	frm.submit(); 
}

function CopyDetails() {
	var frm = document.frmConfirmBooking;
	if (frm.chkCopyDetails.checked)
		frm.CCHolder.value = frm.Passenger_FirstName.value + ' ' + frm.Passenger_LastName.value;
}

function AddToFavourites() {
	if (window.opera && window.print) alert('Please, press Ctrl+T to add our site to your favourites.');
	
	var title = 'Holiday Rooms Direct - low cost hotels at a click';
	var url = 'http://www.holidayroomsdirect.com/';
	if (window.sidebar) window.sidebar.addPanel(title, url, '')
	else if (window.external) window.external.AddFavorite( url, title);
};

function ShowPrice() {
	var cPaymentToday, cPaymentTodayCCCharge, cCCCharge;
	var st, sValue1, sValue2;
	var frm = document.frmConfirmBooking;
	var valCCType = frm.CCType.options[frm.CCType.selectedIndex].value;
	
	if (frm.CCType.selectedIndex == 0) {
		var elItem = document.all("trCCCharge");
		if (elItem) elItem.style.display = "none";
		var elItem = document.all("trCCCharge_foot");
		if (elItem) elItem.style.display = "none";

		elItem = document.all("trBalanceDue");
		if (elItem) elItem.style.display = "none";
		elItem = document.all("trBalanceDue_foot");
		if (elItem) elItem.style.display = "none";

		elItem = document.all("trPaymentToday");
		if (elItem) elItem.style.display = "none";
		elItem = document.all("trPaymentToday_foot");
		if (elItem) elItem.style.display = "none";

		return;
	}
	
	if (frm.PaymentVariant.length > 1) {
		if (frm.PaymentVariant[0].checked) {
			cPaymentToday = c_deposit0;
			cPaymentTodayCCCharge = c_deposit0_ccchargedeposit;
			cCCCharge = c_ccchargedeposit0;
			st = "block";
		} else {
			cPaymentToday = c_total0;
			cPaymentTodayCCCharge = c_total0_cccharge;
			cCCCharge = c_cccharge0;
			st = "none";
		}
		elItem = document.all("trBalanceDue");
		if (elItem) elItem.style.display = st;
		elItem = document.all("trBalanceDue_foot");
		if (elItem) elItem.style.display = st;

	}
	
	elItem = document.all("trPaymentToday");
	if (elItem) elItem.style.display = "block";
	elItem = document.all("trPaymentToday_foot");
	if (elItem) elItem.style.display = "block";
	
	if (valCCType == 'Visa' || valCCType == 'Master Card') {
		st = "block";
		sValue1 = cPaymentTodayCCCharge;
		sValue2 = cCCCharge;
	}
	else {
		st = "none";
		sValue1 = cPaymentToday;
		sValue2 = 0;
	}
	var elItem = document.all("trCCCharge");
	if (elItem) elItem.style.display = st;
	var elItem = document.all("trCCCharge_foot");
	if (elItem) elItem.style.display = st;

	var elItem = document.all("spPaymentToday");
	if (elItem) elItem.innerText = sValue1;
	var elItem = document.all("spPaymentToday_foot");
	if (elItem) elItem.innerText = sValue1;

	var elItem = document.all("spCCCharge");
	if (elItem) elItem.innerText = sValue2;
	var elItem = document.all("spCCCharge_foot");
	if (elItem) elItem.innerText = sValue2;

};

function ShowBalance() {
	var st1, st2;
	var frm = document.frmConfirmBooking;

	if (frm.PayBalance[0].checked) {
		st1 = 'block'; 
		st2 = 'none';
	} else
	{
		st1 = 'none';
		st2 = 'block'; 
	}

	elItem = document.all("tblSameCard");
	if (elItem) elItem.style.display = st1;
	elItem = document.all("tblNewCard");
	if (elItem) elItem.style.display = st2;


};

function PayBalanceNew() {
	var frm = document.frmConfirmBooking;
	frm.target = "";
	
	if (sProcess == 'process') {
	alert('Please wait...');
	return false;
	};
	
	if (frm.CCType.selectedIndex <= 0) 
	{
	alert('Please select "Card Type"');
	frm.CCType.focus();
	return false;
	};

	if (frm.CCHolder.value == '') 
	{
	alert('Please enter "Card Holder"');
	frm.CCHolder.focus();
	return false;
	};
	if (frm.CCNo.value == '') 
	{
	alert('Please enter "Card Number"');
	frm.CCNo.focus();
	return false;
	};


	var ccnum = frm.CCNo.value;
	var cctype = frm.CCType.options[frm.CCType.selectedIndex].value;

	if (cctype == 'Visa')
		if (verifyCardExt('Delta',ccnum)) {
		alert('You have selected the incorrect card type. Please try again using Visa Delta.');
		frm.CCType.focus();
		return false;
		}

	if (!verifyCardExt(cctype,ccnum)) {
            alert("You have entered either an incorrect number or selected the wrong card type - please check and re-enter details.\n\n" +
		  "Prefer to book by phone? \n" +
		  "Reservations helpline: \n" +
		  "0844 251 0454 \n" +
		  "Opening hours: \n" +
		  "Monday - Friday 9:00am - 9:00pm\n" +
		  "Saturday - Sunday 9:00am - 5:00pm\n");
		frm.CCNo.focus();
		return false;
	}

	if (frm.CCSecCode.value == '') 
	{
	alert('Please enter "Security Code"');
	frm.CCSecCode.focus();
	return false;
	};

	if (frm.CCPassenger_Address1.value == '') 
	{
	alert('Please enter "Address"');
	frm.CCPassenger_Address1.focus();
	return false;
	};
	if (frm.CCPassenger_Town.value == '') 
	{
	alert('Please enter "Town/City"');
	frm.CCPassenger_Town.focus();
	return false;
	};
	if (frm.CCPassenger_County.value == '') 
	{
	alert('Please enter "County"');
	frm.CCPassenger_County.focus();
	return false;
	};
	if (frm.CCPassenger_Postcode.value == '') 
	{
	alert('Please enter "Postcode"');
	frm.CCPassenger_Postcode.focus();
	return false;
	};

	frm.Action.value = 'process';
	sProcess = 'process';
	frm.submit(); 
}

function PayBalanceSame() {
	var frm = document.frmConfirmBooking;
	frm.target = "";
	
	if (sProcess == 'process') {
	alert('Please wait...');
	return false;
	};
	
	frm.Action.value = 'process';
	sProcess = 'process';
	frm.submit(); 
}

function ChangedCCType()
{
	var frm = document.frmConfirmBooking;
	
	var valCCType_Store = frm.CCType_Store.value;
	var valCCType = frm.CCType.options[frm.CCType.selectedIndex].value;
	
	if ( (valCCType_Store == '') ||
	     ((valCCType_Store == 'Visa' || valCCType_Store == 'Master Card') && 
	      (valCCType != 'Visa' && valCCType != 'Master Card')) ||
	     ((valCCType_Store != 'Visa' && valCCType_Store != 'Master Card') && 
	      (valCCType == 'Visa' || valCCType == 'Master Card'))
	   ) {
		frm.CCType_Store.value = valCCType;
	}
	else
	frm.CCType_Store.value = valCCType;

	if (valCCType == 'Visa' || valCCType == 'Master Card') st = "block"
	else st = "none";
	elItem = document.all("trCCCharge");
	if (elItem) elItem.style.display = st;
}

function checkSelection(objSelection){
	if (typeof(objSelection) != "undefined") {
		if(objSelection.length) {
			for(var i=0; i < objSelection.length; i++){
				if(objSelection[i].checked) {
					return true;
				}
			}
		}
		else {
			return (objSelection.checked);
		}
	}
	return false;
}

function doByPhone() {
	var frm = document.frmValuate;
	if (typeof(frm) == "undefined")
		frm = document.frmConfirmBooking;
	
	if (typeof(frm) != "undefined")	
		if (frm.ByPhone.value == '1')
			if (window.confirm('Prefer to make your booking by phone?')) {
				openWindow('by_phone.asp', 'winByPhone', 740, 440, 'fullscreen=no,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=no')
				return;
			}

}

function doCheckAvail() {
	var frm = document.frmCheckAvail;
	var frm1 = document.frmSearch;
	
	if (typeof(frm) != "undefined")	
		if (frm.DoCheck.value == '1')
			if (window.confirm('Prefer to check availability and follow the booking process?')) {
				if (typeof(frm1) != "undefined") {
					alert('Please fill out the search form and submit it');
					frm1.ArrD.focus();
					return false;
				}
			}
	return true;
}

function showRoomRequest() {
	elItem = document.all("tblRoomrequest");
	if (elItem) elItem.style.display = "block";
}

function addShortList(id, provider) {
	var frm = document.frmSearchResult;
	frm.target = "";
	frm.action = "hotels.asp";

	frm.ShortList.value = "add";
	frm.ShortID.value = id;
	frm.ShortProvider.value = provider;
	
	frm.submit();
}

function removeShortList(id, provider) {
	var frm = document.frmSearchResult;
	frm.target = "";
	frm.action = "hotels.asp";

	frm.ShortList.value = "remove";
	frm.ShortID.value = id;
	frm.ShortProvider.value = provider;
	
	frm.submit();
}

function viewShortList() {
	var frm = document.frmSearchResult;
	frm.target = "";
	frm.action = "hotels.asp";

	frm.ShortList.value = "view";
	
	frm.submit();
}

function rhTypeChanged() {
	var st;
	var frm = document.frmConfirmBooking;
	var nType = frm.RHType.options[frm.RHType.selectedIndex].value;

	if (nType == '1') 
		st = "block"
	else 
		st = "none";

	var elItem = document.all("trRHDep1");
	if (elItem) elItem.style.display = st;
	var elItem = document.all("trRHDep2");
	if (elItem) elItem.style.display = st;
	var elItem = document.all("trRHDep3");
	if (elItem) elItem.style.display = st;
	var elItem = document.all("trRHDep4");
	if (elItem) elItem.style.display = st;

}

function rhSearch() {
	var frm = document.frmConfirmBooking;
	if (frm.RHArrival.selectedIndex <= 0) {
		alert('Please select arrival airport and resort');
		frm.RHArrival.focus();
		return;
    	};
	
	frm.target = "";
	frm.action = "";
	frm.Action.value = "rhsearch";
	frm.ByPhone.value = "";
	frm.RHArrivals.value = "1";
	
	frm.submit();
}

function rhBack() {
	var frm = document.frmConfirmBooking;
	frm.ByPhone.value = "";
	
	history.go(-1);
}

function fitCot() {
	var frm = document.frmConfirmBooking;
	if (frm.SRCots.selectedIndex > 0) {
		alert('Please call our reservations helpline to confirm the cot will fit into your room - 0844 251 0454. Should it be out of our office hours, please confirm the booking and contact us within 24 hours. Should you not fit, your booking will be cancelled free of charge. ');
    	}
}

function notePayment() {
	alert('If the booking confirmaiton is not displayed after 30 seconds, please do not click more than once because your payment WILL have been taken. Contact our helpline immediately on 0844 251 0454')
}


function goLCB(sURL) {	
	var sQ = '', sLoc = '';
	
	if (sURL.indexOf('?') == 0) sQ = '?cref=0';
	sLoc= 'http://www.lowcostholidays.com/'+sURL+sQ+'&RefID=HRD';
	window.location = sLoc;
	//alert(sLoc);
}
function goLCBHotel(sURL) {	

	var sQ = '', sLoc = '';
	
	//sLoc= 'val2.asp'+sURL+sQ;
	window.location = sLoc;
	//alert(sLoc);
}
function doVal2(prID) {
	document.frmResults.PropertyID.value = prID;
	document.frmResults.submit();
}

function doBooking() {
	var frm = document.frmConfirmBooking;
	frm.ByPhone.value = "";
	frm.target = "";
	frm.action = "confirm_booking.asp";
	
	if (sProcess == 'process') {
	alert('Please wait...');
	return false;
	};
	
	if (frm.CCType.selectedIndex <= 0) 
	{
	alert('Please select "Card Type"');
	frm.CCType.focus();
	return false;
	};

	if (frm.CCHolder.value == '') 
	{
	alert('Please enter "Card Holder"');
	frm.CCHolder.focus();
	return false;
	};
	if (frm.CCNo.value == '') 
	{
	alert('Please enter "Card Number"');
	frm.CCNo.focus();
	return false;
	};


	var ccnum = frm.CCNo.value;
	var cctype = frm.CCType.options[frm.CCType.selectedIndex].value;

	if (cctype == 'Visa')
		if (verifyCardExt('Delta',ccnum)) {
		alert('You have selected the incorrect card type. Please try again using Visa Delta.');
		frm.CCType.focus();
		return false;
		}

	if (!verifyCardExt(cctype,ccnum)) {
            alert("You have entered either an incorrect number or selected the wrong card type - please check and re-enter details.\n\n" +
		  "Prefer to book by phone? \n" +
		  "Reservations helpline: \n" +
		  "0844 251 0454 \n" +
		  "Opening hours: \n" +
		  "Monday - Friday 9:00am - 9:00pm\n" +
		  "Saturday - Sunday 9:00am - 5:00pm\n");
		frm.CCNo.focus();
		return false;
	}

	if (frm.CCSecCode.value == '') 
	{
	alert('Please enter "Security Code"');
	frm.CCSecCode.focus();
	return false;
	};

	if (frm.CCPassenger_Address1.value == '') 
	{
	alert('Please enter "Address"');
	frm.CCPassenger_Address1.focus();
	return false;
	};
	if (frm.CCPassenger_Town.value == '') 
	{
	alert('Please enter "Town/City"');
	frm.CCPassenger_Town.focus();
	return false;
	};
	if (frm.CCPassenger_County.value == '') 
	{
	alert('Please enter "County"');
	frm.CCPassenger_County.focus();
	return false;
	};
	if (frm.CCPassenger_Postcode.value == '') 
	{
	alert('Please enter "Postcode"');
	frm.CCPassenger_Postcode.focus();
	return false;
	};
	if (frm.CCPassenger_HomePhone.value == '') 
	{
	alert('Please enter "Daytime Phone"');
	frm.CCPassenger_HomePhone.focus();
	return false;
	};
	
	if (frm.Passenger_FirstName.value == '') 
	{
	alert('Please enter "First Name"');
	frm.Passenger_FirstName.focus();
	return false;
	};
	if (frm.Passenger_LastName.value == '') 
	{
	alert('Please enter "Last Name"');
	frm.Passenger_LastName.focus();
	return false;
	};
	if (frm.Passenger_Email.value == '') 
	{
	alert('Please enter "EMail"');
	frm.Passenger_Email.focus();
	return false;
	};
	if (frm.Passenger_ConfirmEmail.value != frm.Passenger_Email.value) 
	{
	alert('Please reconfirm "Email"');
	frm.Passenger_ConfirmEmail.focus();
	return false;
	};

	if (frm.Reviewed.checked == false) 
	{
	alert('Please review and accept booking details');
	frm.Reviewed.focus();
	return false;
	};
	if (frm.HaveRead.checked == false) 
	{
	alert('Please read and accept the booking terms and conditions');
	frm.HaveRead.focus();
	return false;
	};
	
	notePayment();
	
	frm.Action.value = 'process';
	sProcess = 'process';
	frm.submit(); 
}
