﻿// ***                              Booking.js                                   ***
//
// Javascript Funtions: checkifReady(), parseDate(), DateAdd(), format()
// ovRes(), outRes(), onRes()
//
var pageReady = false					// Page Ready Flag: true = ready for Javascript control
var canchangeText = false				// CSS support Flag: true = able to change CSS style
var notClicked = true					// Date selected Flag: true = date has been clicked
var originalColour  = "rgb(0,0,255)"	// Default colour for available date
var highlightColour = "rgb(255,0,0)"	// Highlight colour for onmouseover event
var black           = "rgb(0,0,0)"		// Highlight colour for onmouseover event
var i = 0								// Counter
var daySrt = new String					// 1st night of booking in string format
var today = new Date					// object for todays date

// Function test if calling page has completed loading and tests Javascript CSS support
function checkifReady() {
	if ((document.forms) && (document.images)) { 
		pageReady = true
		if (document.getElementById) { 
			canchangeText = true
			document.getElementById('loading').innerHTML = ''
		}
		else {
			alert("Sorry. Your browser is unable to use this page. We are redirecting you...")
		}
	}
	else {
		i=i+1
		if ( i<10 ) { setTimeout("checkifReady()",1000) }
	}
}

// Function formats number into corrrect currency formmat
function format(n) {
	n = Math.round(100*n)/100
	if (n==Math.floor(n)) { n = n+".00" }
	else { 
		if (10*n==Math.floor(10*n)) { n = n+"0" }
		else  { n = n+"" }
	}
	return n
}


// Function returns day month and year given non-standard date string
function parseDate(sD,arrD) {
	var barPos1   = sD.indexOf("|",0)
	var barPos2   = sD.indexOf("|",barPos1+1)
	arrD.Day   = sD.substring(0,barPos1)
	arrD.Month = sD.substring(barPos1+1,barPos2)-1
	arrD.Year  = sD.substring(barPos2+1,sD.length)
	return arrD
}


// Function returns new date
Date.prototype.add = function (sInterval, iNum) {
	var inputDate = this
	outputDate = inputDate
	if (!sInterval || iNum == 0) return inputDate
	switch (sInterval.toLowerCase()){
		case "ms": outputDate.setMilliseconds(inputDate.getMilliseconds() + iNum); break
		case "s": outputDate.setSeconds(inputDate.getSeconds() + iNum); break
		case "mi": outputDate.setMinutes(inputDate.getMinutes() + iNum); break
		case "h": outputDate.setHours(inputDate.getHours() + iNum); break
		case "d": outputDate.setDate(inputDate.getDate() + iNum); break
		case "mo": outputDate.setMonth(inputDate.getMonth() + iNum); break
		case "y": outputDate.setFullYear(inputDate.getFullYear() + iNum); break
	}
	return outputDate
 }

// Function alerts user to non-standard dates
function durationAlert() {
	if (document.durationForm.Duration.selectedIndex == 4) {
		alert("Normally, you can only reserve a holiday for the duration shown in the tariff table. However, please call Stephanie on 01538 308125 to enquire further.")
		document.durationForm.Duration.selectedIndex = 2
	}
}

// Function called from an available date by onMouseOver event
function ovRes(lmh,IntDay0,strDate) {						// IntDay0 = 1st Day of week displayed on calendar
	if (pageReady&&canchangeText&&notClicked) {				// lhm = Flag for low-medium or high season
		var dOverIndex		= new Number					// strDate = Date in Day~Month~Year Format
		var dSrtIndex		= new Number
		var dEndIndex		= new Number
		var SBCuttOffIndex	= new Number
		var UODiscCOffIndex	= new Number
		var EPDiscCOffIndex	= new Number
		var deltaD			= new Number
		var dateString		= new String
		var monthNo			= new Number
		var afterStart		= false
		var beforeEnd		= false
		var SBCuttoff		= new Number
		var UOdiscCuttoff	= new Number
		var EPdiscCuttoff	= new Number
		var dayOver			= new Array()
		dayOver.Day			= new Number
		dayOver.Month		= new Number
		dayOver.Year		= new Number
		var lmhFlag			= new String
		var UODiscRate		= new Number
		var EPDiscRate		= new Number
		var SBCuttoffDate
		var UODiscCuttoffDate
		var EPDiscCuttoffDate
		var withinSBCutOff		= new Boolean
		var withinUODiscCutOff	= new Boolean
		var withinEPDiscCutOff	= new Boolean
		var sb					= new Boolean
		var dateError			= new Boolean

		withinSBCutOff		= true
		withinUODiscCutOff	= true
		withinEPDiscCutOff 	= true
		sb					= true
		dateError      		= false

		var dOver = new Date(parseDate(strDate,dayOver).Year,parseDate(strDate,dayOver).Month,parseDate(strDate,dayOver).Day)
		dOverIndex = dOver.valueOf()
		index = document.durationForm.Duration.selectedIndex
		IntDuration = eval(document.durationForm.Duration.options[index].value)
		switch (IntDuration) {	
			case 3:  deltaD = (7+dOver.getDay()-(IntDay0-1))%7; sb = true; break
			case 4:  deltaD = (7+dOver.getDay()-(IntDay0-5))%7; sb = true; break
			default: deltaD = (7+dOver.getDay()-(IntDay0))%7; sb = false
		}
		var daySrt = dOver.add("d",-deltaD)
		dSrtIndex = daySrt.valueOf()
		today = new Date(todayYear,todayMonth,todayDate)
		var todayIndex=today.valueOf()
		var startDateisBeforeToday = (dSrtIndex<=todayIndex)
		lmhFlag = lmhArr[0][daySrt.getMonth()][daySrt.getDate()-1]
		// 															test to see if any short breaks are available	
		if (sb) {
			SBCuttoffDate = new Date(daySrt)
			switch(lmhFlag) {
				case "Low":  SBCuttoff = eval(strDaysSBLow); break
				case "Mid":  SBCuttoff = eval(strDaysSBMid); break
				case "High": SBCuttoff = eval(strDaysSBHigh); break
				default:     SBCuttoff = 365; break
			}
			if (SBCuttoff == 365) { SBCuttoffDate = today }
			else {SBCuttoffDate.add("d",-SBCuttoff)}
			SBCuttOffIndex=SBCuttoffDate.valueOf()
			withinSBCutOff = (SBCuttOffIndex<=todayIndex)
		}
		// 															test to see if early payment discounts are available
		EPDiscCuttoffDate = new Date(daySrt)
		switch(lmhFlag) {
			case "Low":  EPdiscCuttoff = eval(strDaysDueLow);  EPDiscRate = eval(strEPDiscountLow);  break
			case "Mid":  EPdiscCuttoff = eval(strDaysDueMid);  EPDiscRate = eval(strEPDiscountMid);  break
			case "High": EPdiscCuttoff = eval(strDaysDueHigh); EPDiscRate = eval(strEPDiscountHigh); break
			default: EPdiscCuttoff = 365
		}
		if (EPdiscCuttoff == 365) { EPDiscCuttoffDate = today }		// safari won't add -365 days correctly!
		else { EPDiscCuttoffDate.add("d",-EPdiscCuttoff) }
		EPDiscCOffIndex=EPDiscCuttoffDate.valueOf()
		withinEPDiscCutOff = (EPDiscCOffIndex>todayIndex)
		// 															test to see if under occupancy discounts are available
		UODiscCuttoffDate = new Date(daySrt)
		switch(lmhFlag) {
			case "Low":  UOdiscCuttoff = eval(strDaysUOLow);  UODiscRate = eval(strDiscountLow);  break
			case "Mid":  UOdiscCuttoff = eval(strDaysUOMid);  UODiscRate = eval(strDiscountMid);  break
			case "High": UOdiscCuttoff = eval(strDaysUOHigh); UODiscRate = eval(strDiscountHigh); break
			default: UOdiscCuttoff = 365
		}
		if (UOdiscCuttoff == 365) { UODiscCuttoffDate = today }		// safari won't add -365 days correctly!
		else { UODiscCuttoffDate.add("d",-UOdiscCuttoff) }

		UODiscCOffIndex=UODiscCuttoffDate.valueOf()
		withinUODiscCutOff = (UODiscCOffIndex<=todayIndex)

		var dayCount = daySrt
		var dayEnd = daySrt.add("d",IntDuration-1)
		dEndIndex = dayEnd.valueOf()
		afterStart = (dOverIndex>=dSrtIndex)
		beforeEnd = (dOverIndex<=dEndIndex)
//		if (afterStart&&beforeEnd&&withinSBCutOff&&!startDateisBeforeToday) {		// highlighted day is within an available period
		if (afterStart&&beforeEnd&&!startDateisBeforeToday) {		// highlighted day is within an available period
			for (i=0;i<IntDuration;i++) {
				monthNo  = 1+dayCount.getMonth()
				dateString=""+dayCount.getDate()+"|"+monthNo+"|"+dayCount.getFullYear()
				if (!document.getElementById(dateString)) {dateError = true }		// selects already booked days
				dayCount = dayCount.add("d",-1)
			}
			if (!dateError&&withinSBCutOff) {										// dates available; highlight calendar text
				dayCount = new Date(daySrt)
				dayCount = dayCount.add("d",IntDuration)
				for (i=0;i<IntDuration;i++) {
					monthNo  = 1+dayCount.getMonth()
					dateString=""+dayCount.getDate()+"|"+monthNo+"|"+dayCount.getFullYear()
					if (document.getElementById(dateString)) {
						document.getElementById(dateString).style.color=highlightColour
						document.getElementById(dateString).style.fontSize = "10px"
						document.getElementById(dateString).style.fontWeight = "bold"
						dayCount = dayCount.add("d",-1)
					}
				}
				//														Display Short Break Message in Short Break Table
				if (sb) {
					document.getElementById('sb').innerHTML = 'Short Breaks Available!'
					document.getElementById('sb').style.color=highlightColour
					document.getElementById('sb').style.fontSize = "10px"
					document.getElementById('sb').style.fontWeight = "bold"
				}
				else {
					document.getElementById('sb').innerHTML = "&nbsp;" 
				}
				//														Display Discount Message(s) in Discount Table

				if (withinEPDiscCutOff && withinUODiscCutOff) {			//		Display both messages
					document.getElementById('discount').innerHTML = 'A '+EPDiscRate+"% Early Payment Discount and a "+UODiscRate+"% 'Two-Person' Discount are Available!<br><br>"
					document.getElementById('discount').style.color=highlightColour
					document.getElementById('discount').style.fontSize = "10px"
					document.getElementById('discount').style.fontWeight = "bold"
				}
				else {														//		Display either messages
					if (withinUODiscCutOff) {
						document.getElementById('discount').innerHTML = 'A '+UODiscRate+"% 'Two-Person' Discount is Available!"
						document.getElementById('discount').style.color=highlightColour
						document.getElementById('discount').style.fontSize = "10px"
						document.getElementById('discount').style.fontWeight = "bold"
					}
					if (withinEPDiscCutOff) {
						document.getElementById('discount').innerHTML = "A "+EPDiscRate+'% Early Payment Discount is Available!'
						document.getElementById('discount').style.color=highlightColour
						document.getElementById('discount').style.fontSize = "10px"
						document.getElementById('discount').style.fontWeight = "bold"
					}
					if (!withinEPDiscCutOff && !withinUODiscCutOff) {			//		Display no discount message
						document.getElementById('discount').innerHTML = "&nbsp;" 
						document.getElementById('discount').style.color=black
						document.getElementById('discount').style.fontSize = "9px"
						document.getElementById('discount').style.fontWeight = "normal"
					}
				}
			}
		}
	}
}


// Function called from an available date by onMouseOut event
function outRes(lmh,IntDay0,strDate) { 				// IntDay0 = 1st Day of week displayed on calendar
	if (pageReady&&canchangeText&&notClicked) {		// lhm = Flag for low-medium or high season
		var dOverIndex  	= new Number			// strDate = Date in Day~Month~Year Format
		var dSrtIndex   	= new Number
		var dEndIndex   	= new Number
		var deltaD      	= new Number
		var dateString  	= new String
		var monthNo     	= new Number
		var afterStart 		= false
		var beforeEnd   	= false
		var SBCuttoff    	= new Number
		var UOdiscCuttoff	= new Number
		var EPdiscCuttoff	= new Number
		var dayOver     	= new Array()

		dayOver.Day     	= new Number
		dayOver.Month   	= new Number
		dayOver.Year    	= new Number

		var dOver = new Date(parseDate(strDate,dayOver).Year,parseDate(strDate,dayOver).Month,parseDate(strDate,dayOver).Day)
		dOverIndex = dOver.valueOf()
		index = document.durationForm.Duration.selectedIndex
		IntDuration = eval(document.durationForm.Duration.options[index].value)
		switch (IntDuration) {	
			case 3:  deltaD = (7+dOver.getDay()-(IntDay0-1))%7; break
			case 4:  deltaD = (7+dOver.getDay()-(IntDay0-5))%7; break
			default: deltaD = (7+dOver.getDay()-(IntDay0))%7
		}
		var daySrt = dOver.add("d",-deltaD)
		dSrtIndex = daySrt.valueOf()
		today = new Date(todayYear,todayMonth,todayDate)
		var todayIndex=today.valueOf()
		var startDateisBeforeToday = (dSrtIndex<=todayIndex)
		document.getElementById('sb').innerHTML = "Short Breaks may be available at the 'last minute' or at different times of the year.<br><br>Move your mouse over the calendar to check availability."
		document.getElementById('sb').style.color=black
		document.getElementById('sb').style.fontSize = "9px"
		document.getElementById('sb').style.fontWeight = "normal"
		document.getElementById('discount').innerHTML = "If you book well ahead, and pay in full, you may be entitled to a discount.<br><br>Also, two people booking may be entitled to a couples or 'Two-Person' discount.<br><br>Move your mouse over the calendar to check availability."
		document.getElementById('discount').style.color=black
		document.getElementById('discount').style.fontSize = "9px"
		document.getElementById('discount').style.fontWeight = "normal"
		var dayCount = daySrt
		var dayEnd = daySrt.add("d",IntDuration-1)
		dEndIndex = dayEnd.valueOf()
		afterStart = (dOverIndex>=dSrtIndex)
		beforeEnd = (dOverIndex<=dEndIndex)
		if (afterStart&&beforeEnd&&!startDateisBeforeToday) {		// highlighted day is within an available period
			for (i=0;i<IntDuration;i++) {
				monthNo  = 1+dayCount.getMonth()
				dateString=""+dayCount.getDate()+"|"+monthNo+"|"+dayCount.getFullYear()
				if (document.getElementById(dateString)) {
					document.getElementById(dateString).style.color=originalColour
					document.getElementById(dateString).style.fontSize = "9px"
					document.getElementById(dateString).style.fontWeight = "normal"
					dayCount = dayCount.add("d",-1)
				}
			}
		}
	}
}


// Function called from an available date by onMouseDown event
function onRes(lmh,IntDay0,strDate) {				// IntDay0 = 1st Day of week displayed on calendar
	if (pageReady&&canchangeText&&notClicked) {		// lhm = Flag for low-medium or high season
		var dOverIndex		= new Number			// strDate = Date in Day~Month~Year Format
		var dSrtIndex		= new Number
		var dEndIndex		= new Number
		var SBCuttOffIndex	= new Number
		var UODiscCOffIndex	= new Number
		var EPDiscCOffIndex	= new Number
		var deltaD			= new Number
		var dateString		= new String
		var monthNo			= new Number
		var afterStart		= false
		var beforeEnd		= false
		var j				= new Number
		var k				= new Number
		var l				= new Number
		var total			= new Number
		var dailyTotal		= new Number
		var strDay			= new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
		var strMonth		= new Array("January","February","March","April","May","June","July","August","September","October","November","December")
		var strDateofMonth	= new Array("","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st")
		var dateStr			= new String		// Short form dates string used for step 3 output
		var dateStrVB		= new String		// VB format dates string used for step 3 output
		var vbMonth			= new Number		// VB month = 1-12, ( JS = 0-11 )
		var black			= "rgb(0,0,0)"		// Colour for visible text
		var blue			= "rgb(0,0,255)"	// Colour for visible link
		var lmhFlag			= new String
		var UODiscRate		= new Number
		var depositRate		= new Number
		var SBCuttoff		= new Number
		var UOdiscCuttoff	= new Number
		var EPdiscCuttoff	= new Number		
		var dayOver			= new Array()
		dayOver.Day			= new Number
		dayOver.Month		= new Number
		dayOver.Year		= new Number
		var UODiscRate		= new Number
		var EPDiscRate		= new Number
		var SBCuttoffDate
		var UODiscCuttoffDate
		var EPDiscCuttoffDate
		var withinSBCutOff		= new Boolean
		var withinUODiscCutOff	= new Boolean
		var withinEPDiscCutOff	= new Boolean
		var sb					= new Boolean
		var dateError			= new Boolean

		withinSBCutOff		= true
		withinUODiscCutOff	= true
		withinEPDiscCutOff 	= true
		sb					= true
		dateError      		= false

		total = 0
		dailyTotal = 0

		var dOver = new Date(parseDate(strDate,dayOver).Year,parseDate(strDate,dayOver).Month,parseDate(strDate,dayOver).Day)
		dOverIndex = dOver.valueOf()
		index = document.durationForm.Duration.selectedIndex
		IntDuration = eval(document.durationForm.Duration.options[index].value)
		document.getElementById('duration').innerHTML = IntDuration
		document.bookingForm.holidayDuration.value = IntDuration
		switch (IntDuration) {	
			case 3:
				k = 0
				l = 1
				deltaD = (7+dOver.getDay()-(IntDay0-1))%7
				sb = true
				break
			case 4:
				k = 1
				l = 1
				deltaD = (7+dOver.getDay()-(IntDay0-5))%7
				sb = true
				break
			case 14:
				k = 2
				l = 2
				deltaD = (7+dOver.getDay()-(IntDay0))%7
				sb = false
				break
			default:
				k = 2
				l = 1
				deltaD = (7+dOver.getDay()-(IntDay0))%7
				sb = false
		}
		daySrt = dOver.add("d",-deltaD)
		dSrtIndex = daySrt.valueOf()
		today = new Date(todayYear,todayMonth,todayDate)
		var todayIndex=today.valueOf()
		var startDateisBeforeToday = (dSrtIndex<=todayIndex)
		lmhFlag = lmhArr[0][daySrt.getMonth()][daySrt.getDate()-1]

		// 															test to see if any short breaks are available
		if (sb) {
			SBCuttoffDate = new Date(daySrt)
			switch(lmhFlag) {
				case "Low":  SBCuttoff = eval(strDaysSBLow); break
				case "Mid":  SBCuttoff = eval(strDaysSBMid); break
				case "High": SBCuttoff = eval(strDaysSBHigh); break
				default:     SBCuttoff = 365; break
			}
			if (SBCuttoff == 365) { SBCuttoffDate.add("mo",-12) }
			else {SBCuttoffDate.add("d",-SBCuttoff)}
			SBCuttOffIndex=SBCuttoffDate.valueOf()
			withinSBCutOff = (SBCuttOffIndex<=todayIndex)
		}
		// 															test to see if early payment discounts are available
		EPDiscCuttoffDate = new Date(daySrt)
		switch(lmhFlag) {
			case "Low":  EPdiscCuttoff = eval(strDaysDueLow);  EPDiscRate = eval(strEPDiscountLow);  break
			case "Mid":  EPdiscCuttoff = eval(strDaysDueMid);  EPDiscRate = eval(strEPDiscountMid);  break
			case "High": EPdiscCuttoff = eval(strDaysDueHigh); EPDiscRate = eval(strEPDiscountHigh); break
			default: EPdiscCuttoff = 365
		}
		if (EPdiscCuttoff == 365) { EPDiscCuttoffDate = today }		// safari won't add -365 days correctly!
		else { EPDiscCuttoffDate.add("d",-EPdiscCuttoff) }
		EPDiscCOffIndex=EPDiscCuttoffDate.valueOf()
		withinEPDiscCutOff = (EPDiscCOffIndex>todayIndex)
		// 															test to see if under occupancy discounts are available
		UODiscCuttoffDate = new Date(daySrt)
		switch(lmhFlag) {
			case "Low":  UOdiscCuttoff = eval(strDaysUOLow);  UODiscRate = eval(strDiscountLow);  break
			case "Mid":  UOdiscCuttoff = eval(strDaysUOMid);  UODiscRate = eval(strDiscountMid);  break
			case "High": UOdiscCuttoff = eval(strDaysUOHigh); UODiscRate = eval(strDiscountHigh); break
			default: UOdiscCuttoff = 365
		}
		if (UOdiscCuttoff == 365) { UODiscCuttoffDate = today }		// safari won't add -365 days correctly!
		else { UODiscCuttoffDate.add("d",-UOdiscCuttoff) }

		UODiscCOffIndex=UODiscCuttoffDate.valueOf()
		withinUODiscCutOff = (UODiscCOffIndex<=todayIndex)

		dateStr = strDay[daySrt.getDay()]+" "+strDateofMonth[daySrt.getDate()]+" "+strMonth[daySrt.getMonth()]+" "+daySrt.getFullYear()
		vbMonth = daySrt.getMonth()+1
		dateStrVB = ""+vbMonth+"/"+daySrt.getDate()+"/"+daySrt.getFullYear()
		document.getElementById('firstnight').innerHTML = dateStr
		document.bookingForm.fromDate.value = dateStr
		document.bookingForm.fromDateVB.value = dateStrVB
		switch(lmhFlag) {
			case "Low": 
				UODiscRate = strDiscountLow
				depositRate = strDepositLow
				EPDiscRate = strEPDiscountLow
				daysDue = strDaysDueLow
				break
			case "Mid":
				UODiscRate = strDiscountMid
				depositRate = strDepositMid
				EPDiscRate = strEPDiscountMid
				daysDue = strDaysDueLow
				break
			case "High":
				UODiscRate = strDiscountHigh
				depositRate = strDepositHigh
				EPDiscRate = strEPDiscountHigh
				daysDue = strDaysDueLow
				break
			default:
				UODiscRate = 0
				depositRate = 30
				EPDiscRate = 10
				daysDue = 42
		}
		depositDate = new Date(daySrt)
		depositDate.setDate(depositDate.getDate() - daysDue)
		dateStr = strDay[depositDate.getDay()]+" "+strDateofMonth[depositDate.getDate()]+" "+strMonth[depositDate.getMonth()]+" "+depositDate.getFullYear()
		vbMonth = depositDate.getMonth()+1
		dateStrVB = ""+vbMonth+"/"+depositDate.getDate()+"/"+depositDate.getFullYear()

		var dayCount = daySrt
		var dayEnd = daySrt.add("d",IntDuration-1)
		dEndIndex = dayEnd.valueOf()
		afterStart = (dOverIndex>=dSrtIndex)
		beforeEnd = (dOverIndex<=dEndIndex)
		if (afterStart&&beforeEnd&&withinSBCutOff&&!startDateisBeforeToday) {					// highlighted day is within an available period
			for (i=0;i<IntDuration;i++) {
				monthNo  = 1+dayCount.getMonth()
				dateString=""+dayCount.getDate()+"|"+monthNo+"|"+dayCount.getFullYear()
				if (!document.getElementById(dateString)) {dateError = true }	// setects already booked days
				dayCount = dayCount.add("d",-1)
			}
			if (!dateError) {
				dayCount = new Date(daySrt)
				dayCount = dayCount.add("d",IntDuration)
			
				var dateDiff = new Number
				for (i=0;i<IntDuration;i++) {
					monthNo  = 1+dayCount.getMonth()
					dateString=""+dayCount.getDate()+"|"+monthNo+"|"+dayCount.getFullYear()
					if (document.getElementById(dateString)) {
						document.getElementById(dateString).style.color=highlightColour
						document.getElementById(dateString).style.fontSize = "10px"
						document.getElementById(dateString).style.fontWeight = "bold"
						lmhFlag = lmhArr[0][dayCount.getMonth()][dayCount.getDate()-1]
					}
					switch(lmhFlag) {
						case "Low": j = 0; break
						case "Mid": j = 1; break
						case "High": j = 2; break
						default: j = 0
					}
					// check to see which tariff table to use
					// use 1st set before rateExpDate, 2ns set after
					dateDiff = today-rateExpDate.valueOf()
					if (dateDiff<0) {
						dailyTotal = (rateArr0[j][k]*l)/IntDuration
					}
					else {
						dailyTotal = (rateArr1[j][k]*l)/IntDuration
					}
					total = total + dailyTotal
					dayCount = dayCount.add("d",-1)
				}
				total = format(""+Math.round(100*total)/100)
				document.bookingForm.depositDueDate.value = dateStr
				document.bookingForm.depositDueDateVB.value = dateStrVB
				//																//		Display discount messages at bottom of page
				if (withinEPDiscCutOff && withinUODiscCutOff) {					//		Display both messages
					document.getElementById("discountHTML").innerHTML = ", pre-discounts:... An Early Payment Discount of "+EPDiscRate+"% plus a 'Two-Person' Discount of "+UODiscRate+"% is available." 
				}
				else {															//	Display either messages
					if (withinUODiscCutOff) {
						document.getElementById("discountHTML").innerHTML = ", pre-discount:... A 'Two-Person' Discount of "+UODiscRate+"% is applicable."
					}
					if (withinEPDiscCutOff) {
						document.getElementById("discountHTML").innerHTML = ", pre-discount:... An Early Payment Discount of "+EPDiscRate+"% is available."
					}
					if (!withinEPDiscCutOff && !withinUODiscCutOff) {			//	Display no discount message
						document.getElementById("discountHTML").innerHTML  = "&nbsp;" 
					}
				}
				document.getElementById("discountHTML").style.color=black
				//														Set Form values
				document.bookingForm.epdCuttoff.value = daysDue
				document.bookingForm.epdiscountPercent.value = EPDiscRate
				document.bookingForm.discountPercent.value = UODiscRate
				document.bookingForm.depositPercent.value = depositRate
				document.bookingForm.totalAmount.value = total
				//														Dispay booking summary at bottom of page
				document.getElementById("total").innerHTML = total
				document.getElementById("Step3").style.color=black
				document.getElementById("resetlink").style.color=blue
				document.getElementById("submitlink").style.color=blue
				document.getElementById("duration").style.color=black
				document.getElementById("firstnight").style.color=black
				document.getElementById("total").style.color=black
				notClicked = false
			}
		}
		else {										// highlighted day is not available period
			var browser=navigator.appName
			if ((browser.indexOf("Microsoft")>-1) || (browser.indexOf("Explorer")>-1)) {
				window.location.reload()
			}
		}
	}
}