// JavaScript Document

var win = null;
function mail(mypage,myname,w,h,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings);
}

function createRequestObject()
{
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer")
	{
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var http	 	= createRequestObject(); 

var hotelBookingEngines = new Object();
var hotelBookingIDs = new Object();
var hotelBookingChainIDs = new Object();
var netbookerName		 = new Object();
var netbookerCity		 = new Object();

function BookingHotelSelectChanged(evnt) {
	//console.log("BookingHotelSelectChanged");
	var idMatch = this.value.match(/^([0-9]+)$/);
	if(idMatch == null) idMatch = ["", ""]; //spoof
	var hotelID = idMatch[1];
	//console.log("hotel id "+hotelID);
/*    // Welcome Online engine does not require 'adult' input/labels but the rest do
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "welcome_online") {
		$('adultLabel').style.display = "none";
		$('adultInput').style.display = "none";                			 
    } else {
		$('adultLabel').style.display = "block";
		$('adultInput').style.display = "block";          
    }    
*/         
    
    //hide promo field and label
	$('promoLabel').style.display = "none";
	$('promoInput').style.display = "none"; 
    
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "roommaster") {
		//Populate the rates select item
		new Ajax.Request('/booking/ajax_booking_form_rates/'+hotelID+'.htm', {
			method:"get", 
			onSuccess:BookingHotelSelectChangedCB
		});
	}
	else {
		//Remove the rates element, if there is one.
		$('bookingElementRateCont').style.display = "none";
		$('bookingElementRateLabel').style.display = "none";
	}
	
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "legacy") {
		//Can't launch into stage two,
		//so launch at stage one.
		var hotelBookingID = hotelBookingIDs["hotel"+hotelID];
		mail('http://bookings.legacy-hotels.co.uk/hotel-details&hotel_id='+hotelBookingID, 'legacybookng', 820, 630, 'yes');
	}
	
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "bookerrez") {
		//Show child controls	
		$('bookingElementChildrenLabel').style.display = "block";
		$('bookingElementChildCont').style.display = "block";
		//Add a listener to the child input box.
		var childInput = document.BookingTeaser.children;
		Event.observe(childInput, "keyup", BookingChildrenChanged);
	}
	else {
		//Hide child controls	
		$('bookingElementChildrenLabel').style.display = "none";
		$('bookingElementChildCont').style.display = "none";
		//Remove a listener to the child input box.
		var childInput = document.BookingTeaser.children;
		Event.stopObserving(childInput, "keyup", BookingChildrenChanged);
	}

	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "innpoints") {
		//Show child controls	
		$('bookingElementRoomsLabel').style.display = "block";
		$('bookingElementRoomsCont').style.display = "block";
	}
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "bebox2") {
		//Show child controls	
		$('bookingElementRoomsLabel').style.display = "block";
		$('bookingElementRoomsCont').style.display = "block";
	}
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "caterbook") {
		//Show room field and label
		$('bookingElementRoomsLabel').style.display = "block";
		$('bookingElementRoomsCont').style.display = "block";
		//Hide child field and label
		$('childrenLabel').style.display = "none";
		$('childrenInput').style.display = "none";
	}
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "guestlineRezrooms") {
		//Show room field and label
		$('bookingElementRoomsLabel').style.display = "block";
		$('bookingElementRoomsCont').style.display = "block";
		//Hide child field and label
	}
	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "welcome_online") {
		//Show room field and label
		$('bookingElementRoomsLabel').style.display = "none";
		$('bookingElementRoomsCont').style.display = "none";
		//Hide child field and label
		$('childrenLabel').style.display = "none";
		$('childrenInput').style.display = "none";
		//Hide adult field and label
		$('adultLabel').style.display = "none";
		$('adultInput').style.display = "none";        
	}    
	else {
		//Hide child controls	
		$('bookingElementRoomsLabel').style.display = "none";
		$('bookingElementRoomsCont').style.display = "none";
		//Show child field and label
		$('childrenLabel').style.display = "inline";
		$('childrenInput').style.display = "inline";    
		//Show adult field and label
		$('adultLabel').style.display = "inline";
		$('adultInput').style.display = "inline";              	
    }

	if(typeof(hotelBookingEngines["hotel"+hotelID]) != 'undefined' 
			&& hotelBookingEngines["hotel"+hotelID] == "hotelshop") {
		//Show room field and label
        //console.log('selected hotelshop');
		$('bookingElementRoomsLabel').style.display = "none";
		$('bookingElementRoomsCont').style.display = "none";
		//Hide child field and label
		$('childrenLabel').style.display = "none";
		$('childrenInput').style.display = "none";
		//Hide adult field and label
		$('adultLabel').style.display = "none";
		$('adultInput').style.display = "none";
		//Hide promo field and label
		//$('promoLabel').style.display = "none";
		//$('promoInput').style.display = "none";
		//Show promo field and label
		$('promoLabel').style.display = "inline";
		$('promoInput').style.display = "inline";               
	}    
	else {
		//Hide child controls	
		$('bookingElementRoomsLabel').style.display = "none";
		$('bookingElementRoomsCont').style.display = "none";
		//Show child field and label
		$('childrenLabel').style.display = "inline";
		$('childrenInput').style.display = "inline";    
		//Show adult field and label
		$('adultLabel').style.display = "inline";
		$('adultInput').style.display = "inline"; 
        
 	
    }    
}

function BookingChildrenChanged(evnt) {
	if(this.value.match(/^[0-9]*$/) == null) {
		$('BookingTeaserError').update("");
		$('BookingTeaserError').appendChild(new Element("div", {style:'color:#ff0000;'}).update("Please enter a number of children, or leave blank"));
		this.value = "";
		return;
	}
	
	if(parseInt(this.value) > 4) {
		$('BookingTeaserError').update("");
		$('BookingTeaserError').appendChild(new Element("div", {style:'color:#ff0000;'}).update("Maximum number of 4 children allowed"));
		this.value = "4";
	}
	
	var childAgesCont = $('bookingElementChildCont');
	while(childAgesCont.select("select").length > this.value) {
		childAgesCont.removeChild(childAgesCont.select("select")[0]);
	}
	
	while(childAgesCont.select("select").length < this.value) {
		var newChildAgeSel = new Element("select", {'class':'formInputSmall', style:'width:3.2em;'});
		if(childAgesCont.select("select").length > 0) childAgesCont.appendChild(document.createTextNode(' '));
		childAgesCont.appendChild(newChildAgeSel);
		for(var  i = 0; i <= 14; i++) {
			var opt = new Element("option", {value:i});
			opt.update((i == 0 ? i : i));
			newChildAgeSel.appendChild(opt);
		}
	}
}

function BookingHotelSelectChangedCB(transport) {
	try {
		var xml = transport.responseXML;
		var statusElem = xml.getElementsByTagName("status")[0];
		if(statusElem.firstChild == null) {
			alert("No or empty status tag found");	
			return;
		}
		
		if(statusElem.firstChild.data != "true") {
			alert(statusElem.firstChild.data);	
			return;
		}
		
		var rates = xml.getElementsByTagName("rate");
		/*
		var bookingDiv = $$('.booking-btm')[0];
		var rows = bookingDiv.select("tr");
		if(rows.length <= 5) {
			var ratesSelectRow = new Element("tr");
			var rateSelectCell = new Element("td", {colspan:2});
			rateSelectCell.style.paddingTop = "10px";
			ratesSelectRow.appendChild(rateSelectCell);
			var label = new Element("label", {"for":"bookingElementRate"});
			label.update("Rate:");
			var select = new Element("select", {name:"txtRateSelected", id:"bookingElementRate", "class":"formInputSelectHotel"});
			rateSelectCell.appendChild(label);
			rateSelectCell.appendChild(select);
			//select.appendChild(new Element("option").update("Getting rates..."));
			rows[rows.length-1].parentNode.insertBefore(ratesSelectRow, rows[rows.length-1]);
		}
		*/
		
		var rateSelect = $('bookingElementRate');
		//Remove existing.
		var options = rateSelect.getElementsByTagName("option");
		while(options.length > 0) {
			options[0].parentNode.removeChild(options[0]);	
			options = rateSelect.getElementsByTagName("option");
		}
		
		//Put in new.
		for(var i = 0; i < rates.length; i++) {
			//<option value="0">TEST Rate</option>
			var newOption = document.createElement("option");
			newOption.appendChild(document.createTextNode(rates[i].getAttribute("name")));
			newOption.value = rates[i].getAttribute("value");
			rateSelect.appendChild(newOption);		
		}
		
		$('bookingElementRateCont').style.display = "block";
		$('bookingElementRateLabel').style.display = "block";
	}
	catch(e) {
		console.log(e);	
	}
}

function RunBookingValidation ()
{
	
	var property 			= document.BookingTeaser.property;
	var property_index 		= property.options.selectedIndex;
	var property			= property.options[property_index].value;
	
	var day					= document.getElementById('arr_date').value;
	
	var nights				= document.BookingTeaser.nights.value;
	
	var adults				= document.BookingTeaser.adults.value;
	
	var children			= document.BookingTeaser.children.value;
    
    //var promo               = document.BookingTeaser.promo.value;
	
	if(hotelBookingEngines["hotel"+property] == "cybarez" 
	|| hotelBookingEngines["hotel"+property] == "rezplatform") {
		var params 				= "property=" + property + "&arr_date=" + day + "&nights=" + nights + "&adults=" + adults + "&children=" + children;
		
		http.open('POST', '/booking/ajax_handle');
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		
		http.onreadystatechange = handleAjaxReturn; 
		http.send(params);
		
		return false;
	}
	
	var errors = new Array();
	
	if(typeof hotelBookingEngines["hotel"+property] == "undefined") errors.push("Please select a hotel");
	
	if(!nights.match(/^[0-9]+$/)) errors.push("Please enter a number of nights");
	else {
		if(new Number(nights) == 0) errors.push("Please enter at least one night");	
	}
	
    
    //console.error(hotelBookingIDs);
    //console.log(hotelBookingEngines['hotel69']);
    //console.log(adults);
    
    // adults not required for welcome_online booking engine & now hotelshop
    //console.log(hotelBookingEngines);
    //console.log(hotelBookingEngines["hotel"+property]);
    if (hotelBookingEngines["hotel"+property] != "hotelshop") 
    {        
    	if(!adults.match(/^[0-9]+$/)) 
        {
            errors.push("Please enter a number of adults");
    	} else {
    		if(new Number(adults) == 0) errors.push("Please enter at least one adult");	
    	}
    }         
	
	if(!children.match(/^[0-9]*$/)) errors.push("Please enter a number of children, or leave blank");
	if(children.length == 0) children = "0";
	
	if(!day.match(/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/)) errors.push("Please enter arrival date: dd/mm/yyyy");
	else {
		var dateParts = day.split("/");
		var date =  new Date();
		date.setUTCFullYear(dateParts[2], dateParts[1] - 1, dateParts[0]);
		if(dateParts[2] != date.getUTCFullYear() 
		|| dateParts[1] != (date.getUTCMonth()+1)
		|| dateParts[0] != date.getUTCDate()) {
			 errors.push("Please enter arrival date: dd/mm/yyyy");
		}
	}
	
	var rate = null
	if(hotelBookingEngines["hotel"+property] == "roommaster") {
		////In addition, we need the rate
		var rateElement = $('bookingElementRate');
		if(rateElement == null) {
			 errors.push("Couldn't find the rate select. Try re-selecting the property.");
		}
		else {
			//console.log(rateElement.value);
			rate = rateElement.value;
		}
	}
	

	var rooms = null
	if(hotelBookingEngines["hotel"+property] == "innpoints") {
		////In addition, we need the rate
		var roomsElement = $('bookingElementRooms');
		if(roomsElement == null) {
			 errors.push("Please enter number of rooms required");
		}
		else {
			//console.log(rateElement.value);
			rooms = roomsElement.value;
		}
	}

	if(hotelBookingEngines["hotel"+property] == "bebox2") {
		////In addition, we need the rate
		var roomsElement = $('bookingElementRooms');
		if(roomsElement == null) {
			 errors.push("Please enter number of rooms required");
		}
		else {
			//console.log(rateElement.value);
			rooms = roomsElement.value;
		}
	}
	
	if(hotelBookingEngines["hotel"+property] == "caterbook") {
		////In addition, we need the rate
		var roomsElement = $('bookingElementRooms');
		if(roomsElement == null) {
			 errors.push("Please enter number of rooms required");
		}
		else {
			//console.log(rateElement.value);
			rooms = roomsElement.value;
		}
	}

	if(hotelBookingEngines["hotel"+property] == "guestlineRezrooms") {
		////In addition, we need the rate
		var roomsElement = $('bookingElementRooms');
		if(roomsElement == null) {
			 errors.push("Please enter number of rooms required");
		}
		else {
			//console.log(rateElement.value);
			rooms = roomsElement.value;
		}
	}

	
	if(errors.length > 0) {
		document.getElementById('BookingTeaserError').innerHTML = '';
		for (e in errors) {
			document.getElementById('BookingTeaserError').innerHTML += "<div style=\"color:#ff0000;\">"+errors[e]+"</div>";
		}
	}
	else {
		switch(hotelBookingEngines["hotel"+property]) {
			case "synxis":
				launchSynxis(property, date, nights, adults, children);
			break;
			case "ihotelier":
				launchIhotelier(property, date, nights, adults, children);
			case "ihotelier2":
				launchIhotelier2(property, date, nights, adults, children);
			break;
			case "roommaster":
				launchRoomMaster(property, date, nights, adults, children, rate);
			break;
			case "netbooker":
				launchNetbooker(property, date, nights, adults, children);
			break;
			case "bookerrez":
				launchBookerRez(property, date, nights, adults, children);
			break;
			case "watersmeet_custom":
				var arriveString = date.getUTCDate()+"/"+(date.getUTCMonth()+1)+"/"+date.getUTCFullYear();
				window.open('http://watersmeethotel.co.uk/hotelbooking.aspx?arrivaldate='+arriveString+'%2000:00:00&nights='+nights,'BookingWindow');
			break;
			case "bebox":
				launchBeBox(property, date, nights);
			break;
			case "bebox2":
				launchBeBox2(property, date, nights, adults, children, rooms);
			break;
			case "rocky":
			  	launchRocky(property, date, nights, adults, children);
			break;
			case "fidelio":
				launchMyfidelio(property, date, nights, adults, children);
			break;
			case "innpoints":
				launchInnpoints(property, date, nights, adults, children, rooms);
			break;
			case "bookingbutton":
				launchBookingButton(property, date, nights, adults, children);
			break;
			case "hotelexec":
			launchHotelExec(property, date, nights, adults, children, rate);
			break;
			case "avvio4":
				launchAvvio4(property, date, nights, adults, children, rate);
			break;
			case "avvio5":
				launchAvvio5(property, date, nights, adults, children, rate);
			break;
			case "navarino":
				launchNavarino(property, date, nights, adults, children);
			break;
			case "caterbook":
				launchCaterbook(property, date, nights, adults, children, rooms);
			break;
			case "guestlineRezrooms":
				launchguestlineRezrooms(property, date, nights, rooms, adults, children);
			break;
			case "welcome_online":
				launchWelcomeOnline(property, date, nights);
			break;       
            case "hotelshop":
                launchHotelShop(property, date, nights);                
            break;     
		}
	
	}
}

function handleAjaxReturn ()
{
	if(http.readyState == 4)
	{
		var response = http.responseText;
		var trimmed = response.replace(/^\s+|\s+$/g, '') ;
		//alert('|' + response + '|');
		
		if (trimmed == 'VALIDATION_PASSED')
		{
			//alert('submitting form');
			document.BookingTeaser.submit();
		} else {
			document.getElementById('BookingTeaserError').innerHTML = response;
		}
		
	} else {
		document.getElementById('BookingTeaserError').innerHTML = 'Please Wait...';	
	}
}

function launchSynxis(property, date, nights, adults, children) {
	var baseURL = "https://reservations.synxis.com/LBE/rez.aspx";
	var chainID = 6661;
	if(hotelBookingChainIDs["hotel"+property] != null) chainID = hotelBookingChainIDs["hotel"+property];
	var arriveString = (date.getUTCMonth()+1) +"/"+date.getUTCDate()+"/"+date.getUTCFullYear();
	
	var bookingURL = baseURL+"?Hotel="+hotelBookingIDs["hotel"+property]+
					"&Chain="+chainID+"&Dest=BESPOKE&level=2"+
					"&arrive="+arriveString+
					"&nights="+nights+
					"&adult="+adults;
	if(children.length > 0) bookingURL += "&child="+children;
	bookingURL += "&step=2";
	//alert(bookingURL);
	mail(bookingURL, 'SynxisBookingWindow', 850, 580, 'yes');
}

function launchNavarino(property, date, nights, adults, children) {
	var baseURL = "https://gc.synxis.com/rez.aspx";
	//var chainID = 6661;
	//if(hotelBookingChainIDs["hotel"+property] != null) chainID = hotelBookingChainIDs["hotel"+property];
	var arriveString = date.getUTCDate() +"/"+(date.getUTCMonth()+1)+"/"+date.getUTCFullYear();
	
	var bookingURL = baseURL+"?Chain="+hotelBookingChainIDs["hotel"+property]+
					"&Hotel="+hotelBookingIDs["hotel"+property]+
					"&Locale=en-GB"+
					"&Arrive="+arriveString+
					"&Nights="+nights+
					"&Adult="+adults;
	if(children.length > 0) bookingURL += "&Child="+children;
	bookingURL += "&submit";
	//alert(bookingURL);
	mail(bookingURL, 'NavarinoBookingWindow', 950, 650, 'yes');
}

function launchguestlineRezrooms(property, date, nights, rooms, adults, children) {
	var baseURL = "https://www.rezrooms.com/RezRooms21/content/default/wfrmPackSearchResults.aspx";
	//var chainID = 6661;
	//if(hotelBookingChainIDs["hotel"+property] != null) chainID = hotelBookingChainIDs["hotel"+property];
	var arriveString = date.getUTCDate() +"-"+(date.getUTCMonth()+1)+"-"+date.getUTCFullYear();
	
	var bookingURL = baseURL+"?siteId="+hotelBookingIDs["hotel"+property]+
					"&arrival="+arriveString+
					"&nights="+nights+
					"&rooms="+rooms+
					"&adults="+adults+
					"&children="+children+
					"&infants=0";
	//alert(bookingURL);
	mail(bookingURL, 'GuestlineRezroomsBookingWindow', 950, 650, 'yes');
}


function launchBookerRez(property, date, nights, adults, children) { //https://www.yourreservation.net/ibe/15922-Pinewood-Htl/main.html
	var bookingURL = 'https://www.yourreservation.net/ibe/'+hotelBookingIDs["hotel"+property]+'/main.htm?quick=quick&language=EN&ccpSelectCountry=GB-XX';
	
	var month = ""+(date.getUTCMonth()+1);
	if(month.length < 2) month = "0"+month;
	var day = ""+date.getUTCDate();
	if(day.length < 2) day = "0"+day;
	
	var endDate = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 1);
	endDate.setDate(endDate.getDate() + new Number(nights));
	//////////alert(endDate);
	var endMonth = ""+(endDate.getUTCMonth()+1);
	if(endMonth.length < 2) endMonth = "0"+endMonth;
	var endDay = ""+endDate.getUTCDate();
	if(endDay.length < 2) endDay = "0"+endDay;
	
	var childAgeInputs = $$('#bookingElementChildCont select');
	bookingURL += '&calArrivalDateField='+date.getUTCFullYear()+'-'+month+'-'+day;	
	bookingURL += '&calDepartureDateField='+endDate.getUTCFullYear()+'-'+endMonth+'-'+endDay;
	bookingURL += '&occupancy='+(parseInt(adults)+parseInt(childAgeInputs.length));
	bookingURL += '&prsRoomCount=1';
	bookingURL += '&prsNumChildren='+childAgeInputs.length;
	
	for(var  i = 0; i < childAgeInputs.length; i++) {
		bookingURL += '&prsRoomAge='+childAgeInputs[i].value;
	}
	mail(bookingURL, 'BookerRezBookingWindow', 1020, 580, 'yes');
}

function launchIhotelier(property, date, nights, adults, children) {
	var baseURL = "https://reservations.ihotelier.com/istay.cfm";
	var bookingURL = baseURL+"?hotelid="+hotelBookingIDs["hotel"+property]+
					"&Rooms=1"+
					"&Length="+nights+
					"&Adults="+adults+
					"&Children="+children+
					"&DateIN="+(date.getUTCMonth()+1)+"/"+date.getUTCDate()+"/"+date.getUTCFullYear();
	//alert(bookingURL);
	mail(bookingURL, 'ihotelierbookng', 1030, 750);
}

function launchBeBox(property, date, nights) {
	var sub = netbookerName["hotel"+property];
	var baseURL 	= "http://" + sub + ".visrez.com/web_reservations/show_availability?reservation_search[arrival_date]=";
	var bookingURL	= baseURL + "" + date.getUTCDate()+"."+(date.getUTCMonth()+1)+"."+date.getUTCFullYear() +
					  "&reservation_search[nights]=" + nights +
					  "&reservation_search[property_id]=" + hotelBookingIDs['hotel' + property];
	//alert(bookingURL);
	mail(bookingURL, 'beboxbooking', 1000, 700, 'yes');
}

function launchBeBox2(property, date, nights, adults, children, rooms) {
	var sub = netbookerName["hotel"+property];
	var baseURL 	= "https://" + sub + ".visrez.com/booknow?";
	//var baseURL 	= "http://" + sub + ".operaows.com/booknow?";
	var bookingURL	= baseURL+"nights=" + nights +
						"&date=" + date.getUTCDate()+"/"+(date.getUTCMonth()+1)+"/"+date.getUTCFullYear() +
						"&property_id=" + hotelBookingIDs['hotel' + property] +
						"&rooms=" + rooms +
						"&adults=" + adults +
						"&children=" + children;
	//alert(bookingURL);
	mail(bookingURL, 'bebox2booking', 1000, 700, 'yes');
}



function launchIhotelier2(property, date, nights, adults, children) {
	var baseURL = "https://booking.ihotelier.com/istay/istay.jsp";
	var bookingURL = baseURL+"?hotelid="+hotelBookingIDs["hotel"+property]+"&locale=EN&languageid=11"+
					"&Length="+nights+
					"&adults="+adults+
					"&children="+children+
					"&datein="+(date.getUTCMonth()+1)+"/"+date.getUTCDate()+"/"+date.getUTCFullYear();
	//alert(bookingURL);
	mail(bookingURL, 'ihotelier2bookng', 1030, 750);
}

function launchRoomMaster(property, date, nights, adults, children, rate) {
	var endDate = new Date();
	endDate.setTime(date.getTime());
	endDate.setDate(endDate.getDate() + new Number(nights));
	var baseURL = "https://"+hotelBookingIDs["hotel"+property]+"/asp/AgentLogin.asp";
	
	var inDay = new String(date.getUTCDate());
	if(inDay.length < 2) inDay = "0"+inDay;
	var inMonth = new String((date.getUTCMonth()+1));
	if(inMonth.length < 2) inMonth = "0"+inMonth;
	var outDay = new String(endDate.getUTCDate());
	if(outDay.length < 2) outDay = "0"+outDay;
	var outMonth = new String((endDate.getUTCMonth()+1));
	if(outMonth.length < 2) outMonth = "0"+outMonth;
	
	var bookingURL = baseURL+"?txtNumRooms=1"+
					"&txtAdults="+adults+
					"&txtChildren="+children+
					"&txtRateSelected="+rate+
					"&CheckOutDay="+outDay+
					"&CheckOutMonth="+outMonth+
					"&CheckOutYear="+endDate.getUTCFullYear()+
					"&CheckInDay="+inDay+
					"&CheckInMonth="+inMonth+
					"&CheckInYear="+date.getUTCFullYear();
	//alert(bookingURL);
	mail(bookingURL, 'RoomMasterBookingWindow', 800, 600, 'yes');
}

function launchRocky(property, date, nights, adults, children, rate) {
  var endDate = new Date();
  endDate.setTime(date.getTime());
  endDate.setDate(endDate.getDate() + new Number(nights));
  var baseURL = "https://www.rockyresort.com/res/actions/reservation_component.php";
  
  var inDay = new String(date.getUTCDate());
  if(inDay.length < 2) inDay = "0"+inDay;
  var inMonth = new String((date.getUTCMonth()+1));
  if(inMonth.length < 2) inMonth = "0"+inMonth;
  var outDay = new String(endDate.getUTCDate());
  if(outDay.length < 2) outDay = "0"+outDay;
  var outMonth = new String((endDate.getUTCMonth()+1));
  if(outMonth.length < 2) outMonth = "0"+outMonth;
  
  var bookingURL = baseURL+"?checkin="+inDay+"/"+inMonth+"/"+date.getUTCFullYear()+
          "&checkout="+outDay+"/"+outMonth+"/"+date.getUTCFullYear()+
          "&nights="+nights;
  //alert(bookingURL);
  mail(bookingURL, 'RockyBookingWindow', 900, 650, 'yes');
}

function launchCaterbook(property, date, nights, adults, children, rooms) {
	var endDate = new Date();
	endDate.setTime(date.getTime());
	endDate.setDate(endDate.getDate() + new Number(nights));
	//var baseURL = "https://booking.caterbook.com/"+hotelBookingIDs["hotel"+property]+"/"+hotelBookingChainIDs["hotel"+property]+"/availability.php?ln=en&refid=1&onlyavailable=yes";
    
    // https://booking.caterbook.com/netherstowehouse/A1272/availability.php?ln=en&refid=1&monthsI=7&daysI=20&yearI=2011&monthsS=7&daysS=22&yearS=2011&&guests=2&rooms=1
    var baseURL = "https://booking.caterbook.com/"+hotelBookingIDs["hotel"+property]+"/"+hotelBookingChainIDs["hotel"+property]+"/availability.php?ln=en&refid=6&onlyavailable=yes";

	  var inDay = new String(date.getUTCDate());
	  if(inDay.length < 2) inDay = "0"+inDay;
	  var inMonth = new String((date.getUTCMonth()+1));
	  if(inMonth.length < 2) inMonth = "0"+inMonth;
	  var outDay = new String(endDate.getUTCDate());
	  if(outDay.length < 2) outDay = "0"+outDay;
	  var outMonth = new String((endDate.getUTCMonth()+1));
	  if(outMonth.length < 2) outMonth = "0"+outMonth;

    // NB Engine requires month in single digit format        
	var bookingURL = baseURL+
            "&monthsI="+inMonth.substring(2,1)+
            "&daysI="+inDay+
            "&yearI="+endDate.getFullYear()+
            "&monthsS="+outMonth.substring(2,1)+
            "&daysS="+outDay+
            "&yearS="+date.getUTCFullYear()+
            "&guests="+adults+
            "&rooms="+rooms;                  
                                                         					
	mail(bookingURL, 'caterbook', 980, 650, 'yes');	
}


function launchMyfidelio(property, date, nights, adults, children, rate) {
  var endDate = new Date();
  var hotelID  = hotelBookingIDs["hotel"+property];
  var hotelCID = hotelBookingChainIDs["hotel"+property];
  endDate.setTime(date.getTime());
  endDate.setDate(endDate.getDate() + new Number(nights));
  var baseURL = "https://www.myfidelio.net/webui/AvailabilitySearch.aspx?chain="+hotelCID+"&property="+hotelID+"&language=en-GB";
  
  var inDay = new String(date.getUTCDate());
  if(inDay.length < 2) inDay = "0"+inDay;
  var inMonth = new String((date.getUTCMonth()+1));
  if(inMonth.length < 2) inMonth = "0"+inMonth;
  var outDay = new String(endDate.getUTCDate());
  if(outDay.length < 2) outDay = "0"+outDay;
  var outMonth = new String((endDate.getUTCMonth()+1));
  if(outMonth.length < 2) outMonth = "0"+outMonth;
  
  var bookingURL = baseURL+"&arrival="+date.getUTCFullYear()+"-"+inMonth+"-"+inDay+
          "&nights="+nights+
		  "&adults="+adults+
		  "&children="+children;
  //alert(bookingURL);
  mail(bookingURL, 'MyFidelioBookingWindow', 980, 650, 'yes');
}

function launchAvvio4(property, date, nights, adults, children, rate) {
  var endDate = new Date();
  var hotelID  = hotelBookingIDs["hotel"+property];

  endDate.setTime(date.getTime());
  endDate.setDate(endDate.getDate() + new Number(nights));

  var inDay = new String(date.getUTCDate());
  if(inDay.length < 2) inDay = "0"+inDay;
  var inMonth = new String((date.getUTCMonth()+1));
  if(inMonth.length < 2) inMonth = "0"+inMonth;
  
  
  var baseURL = "http://www.avvio.com/hotels/" + hotelID + "/bookings/client.php?formname=multi_day_availability"
				+ "&ci_day=" + inDay 
				+ "&ci_ym=" + date.getUTCFullYear() + '-' + inMonth 
				+ "&nights=" + nights;

  mail(baseURL, 'Avvio4BookingWindow', 980, 650, 'yes');
}


function launchAvvio5(property, date, nights, adults, children, rate) {
  var endDate = new Date();
  var hotelID  = hotelBookingIDs["hotel"+property];

  endDate.setTime(date.getTime());
  endDate.setDate(endDate.getDate() + new Number(nights));

  var inDay = new String(date.getUTCDate());
  if(inDay.length < 2) inDay = "0"+inDay;
  var inMonth = new String((date.getUTCMonth()+1));
  if(inMonth.length < 2) inMonth = "0"+inMonth;
  
  
  var baseURL = "http://fe.avvio.com/convert/site/" + hotelID + "/en/mda.php"
				+ "?checkin=" + date.getUTCFullYear() + '-' + inMonth + '-' + inDay + '&nights=' + nights;

  mail(baseURL, 'Avvio5BookingWindow', 980, 650, 'yes');
}



function launchHotelExec(property, date, nights, adults, children, rate) {
  var endDate = new Date();
  var hotelID  = hotelBookingIDs["hotel"+property];
  //var hotelCID = hotelBookingChainIDs["hotel"+property];
  endDate.setTime(date.getTime());
  endDate.setDate(endDate.getDate() + new Number(nights));

  //var baseURL = "http://bespoke-dev.cybacat.com/welcome/booking_wait";
  var baseURL = "http://www.bespokehotels.com/welcome/booking_wait";

  var inDay = new String(date.getUTCDate());
  if(inDay.length < 2) inDay = "0"+inDay;
  var inMonth = new String((date.getUTCMonth()+1));
  if(inMonth.length < 2) inMonth = "0"+inMonth;
  var outDay = new String(endDate.getUTCDate());
  if(outDay.length < 2) outDay = "0"+outDay;
  var outMonth = new String((endDate.getUTCMonth()+1));
  if(outMonth.length < 2) outMonth = "0"+outMonth;

  var formData          = "$LICENCE$="+hotelID+"&$SMOKING$="+"&$SOURCE$="+"&$LEDGER$="+"&$DAY$="+inDay+"&$MONTH$="+inMonth+"&$YEAR$="+date.getUTCFullYear()+"&$NIGHTS$="+nights;

  new Ajax.Request('/welcome/booking_post', {method:'post', parameters: {data: formData, type: "hotelexec"}, onSuccess: function(transport){}});
  mail(baseURL, 'HotelExecBookingWindow', 980, 650, 'yes');
}

function launchInnpoints(property, date, nights, adults, children, rooms) {
	var endDate = new Date();
	endDate.setTime(date.getTime());
	endDate.setDate(endDate.getDate() + new Number(nights));
	var baseURL = "https://mycrs.innpoints.com/book/book/guest/avail";

	  var inDay = new String(date.getUTCDate());
	  if(inDay.length < 2) inDay = "0"+inDay;
	  var inMonth = new String((date.getUTCMonth()+1));
	  if(inMonth.length < 2) inMonth = "0"+inMonth;
	  var outDay = new String(endDate.getUTCDate());
	  if(outDay.length < 2) outDay = "0"+outDay;
	  var outMonth = new String((endDate.getUTCMonth()+1));
	  if(outMonth.length < 2) outMonth = "0"+outMonth;

	var bookingURL = baseURL+
					"?numAdults="+adults+
					"&numChildren="+children+
					"&hotelCode="+hotelBookingIDs["hotel"+property]+
					"&checkinDate="+inMonth+"/"+inDay+"/"+date.getUTCFullYear()+
					"&checkoutDate="+outMonth+"/"+outDay+"/"+date.getUTCFullYear()+
					"&&channelCode=INTERNET&_page=0&_target1=&numRooms="+rooms;
					
//alert(bookingURL);
	mail(bookingURL, 'innpointsbookng', 980, 650, 'yes');
	
}

function launchBookingButton(property, date, nights, adults, children) {
	var endDate = new Date();
	endDate.setTime(date.getTime());
	endDate.setDate(endDate.getDate() + new Number(nights));
	var baseURL = "https://www.thebookingbutton.co.uk/properties/";

	  var inDay = new String(date.getUTCDate());
	  if(inDay.length < 2) inDay = "0"+inDay;
	  var inMonth = new String((date.getUTCMonth()+1));
	  if(inMonth.length < 2) inMonth = "0"+inMonth;
	  var outDay = new String(endDate.getUTCDate());
	  if(outDay.length < 2) outDay = "0"+outDay;
	  var outMonth = new String((endDate.getUTCMonth()+1));
	  if(outMonth.length < 2) outMonth = "0"+outMonth;

	var bookingURL = baseURL+hotelBookingIDs["hotel"+property]+
					"?check_in_date="+date.getUTCFullYear()+"-"+inMonth+"-"+inDay+
					"&check_out_date="+date.getUTCFullYear()+"-"+outMonth+"-"+outDay+
					"&number_adults="+adults+
					"&number_children="+children;
	//alert(bookingURL);
	mail(bookingURL, 'bookingbutton', 1020, 750, 'yes');
}


// NEW NETBOOKER PARAMETERS - NEED TO OBTAIN PROPERTY NAME AND CITY DYNAMICALLY!!
function launchNetbooker(property, date, nights, adults, children, name, city) {
	//Initialise session
	//var win = mail("https://unirez.ibe.netbooker.com/web/FrontController.nb4?module=PropertySearch&operation=SinglePropertySearch&execute=yes&chainCode="+hotelBookingChainIDs["hotel"+property]+"&propertyCode="+hotelBookingIDs["hotel"+property]+"&instanceId=72", 'BookingWindow', 800, 600, 'yes');
	
	var endDate = new Date();
	endDate.setTime(date.getTime());
	endDate.setDate(endDate.getDate() + new Number(nights));
	
	var inDay = new String(date.getUTCDate());
	if(inDay.length < 2) inDay = "0"+inDay;
	var inMonth = new String((date.getUTCMonth()+1));
	if(inMonth.length < 2) inMonth = "0"+inMonth;
	var outDay = new String(endDate.getUTCDate());
	if(outDay.length < 2) outDay = "0"+outDay;
	var outMonth = new String((endDate.getUTCMonth()+1));
	if(outMonth.length < 2) outMonth = "0"+outMonth;
	
	var bookingURL = "https://secure.netbookerng.com/hotels";
	
	/*bookingURL += "/royalhotel";
	//bookingURL += "/cardiff"*/
	
	bookingURL += "/"+netbookerName["hotel"+property];
	bookingURL += "/"+netbookerCity["hotel"+property];
	
	bookingURL += "/hseoptx_"+hotelBookingChainIDs["hotel"+property];
	bookingURL += "/hseoid_"+hotelBookingIDs["hotel"+property];
	bookingURL += "?&refurl=.bespokehotels.com&autosearch=true";
	bookingURL += "&begindate="+inMonth;
	bookingURL += "/"+inDay;
	bookingURL += "/"+date.getUTCFullYear();
	bookingURL += "&enddate="+outMonth;
	bookingURL += "/"+outDay;
	bookingURL += "/"+endDate.getUTCFullYear();
	bookingURL += "&adults="+adults;
	bookingURL += "&numberOfNights="+nights;
	if(children.length > 0) bookingURL += "&children="+children;
	//mail(bookingURL, 'BookingWindow', 800, 600);
	mail(bookingURL, 'BookingWindow', 1020, 750);
	
}

function launchHotelShop(property, date, nights) {    
	var inDay = new String(date.getUTCDate());
	if(inDay.length < 2) inDay = "0"+inDay;
	var inMonth = new String((date.getUTCMonth()+1));
	if(inMonth.length < 2) inMonth = "0"+inMonth;
    var inYear = new String(date.getUTCFullYear());

    var bookingURL = 'http://bookings.bespokehotels.com/hotel-details?';
    
    //var promo = document.BookingTeaser.promo.value;
    var promo = document.getElementById('promoInput').value;
    
    bookingURL  += "hotel_id="+hotelBookingIDs["hotel"+property];
    bookingURL  += "&nights="+nights;
    bookingURL  += "&date="+inYear+inMonth+inDay;   // yyyymmdd
    bookingURL  += "&promo_code="+promo;
    
    //console.log(bookingURL);
    mail(bookingURL, 'BookingWindow', 800, 750, 'yes');
}

/**
*   launch welcome online
    @param  int     property
    @param  string  date
    @param  int     nights
    @return void
*/
function launchWelcomeOnline(property, date, nights) {
// http://www.welcome-online.net/connect.asp?id=168&mode=dates&arrival_day=27&arrival_month=6&arrival_year=2012&no_of_nights=1
    var bookingID = hotelBookingIDs["hotel"+property];
    
    var baseURL = "http://www.welcome-online.net/connect.asp?";
	
	var inDay = new String(date.getUTCDate());
	if(inDay.length < 2) inDay = "0"+inDay;
	var inMonth = new String((date.getUTCMonth()+1));
	if(inMonth.length < 2) inMonth = "0"+inMonth;

	var bookingURL = baseURL+
					"id="+bookingID+
					"&mode=dates"+
                    "&no_of_nights="+nights+
					"&arrival_day="+inDay+
					"&arrival_month="+inMonth+
					"&arrival_year="+date.getUTCFullYear();
	//console.log(bookingURL);
	mail(bookingURL, 'WelcomeOnlineWindow', 800, 600, 'yes');
}

/******************************************************
			FUNCTIONS FOR THE NETSPIN BOOKING FORM 
******************************************************/

var targetfield = null;
var targetroomid = null;
var targethotelid = null;
var targetxmlroomid = null;

var isused = new Array();
isused[1] = null;
isused[2] = null;
isused[3] = null;

function getRoomFields(HotelID, RoomId, Field, XMLroomID)
{
	var ajax_fieldname;
	if (XMLroomID == 'none')
	{
		ajax_fieldname = 'AJAX_Adults_' + RoomId;
		document.getElementById(ajax_fieldname).innerHTML = '&nbsp;';
		
		ajax_fieldname = 'AJAX_Child_' + RoomId;
		document.getElementById(ajax_fieldname).innerHTML = '&nbsp;';
		
		isused[RoomId] = false;
	} else {
			
		targetfield 	= Field;
		targetroomid	= RoomId;
		targethotelid	= HotelID;
		targetxmlroomid	= XMLroomID;
		
		var A_field	= Field + '_' + RoomId;
		
		//alert('1 ' + A_field);
		
		http	 	= createRequestObject(); 
		
		http.open('get', '/booking/netspin_handle_room_ajax/' + HotelID + '/' + XMLroomID + '/' + A_field);
		http.onreadystatechange = handleRoomAjaxReturn; 
		http.send(null);
	}
}

function handleRoomAjaxReturn ()
{
	ajax_fieldname = 'AJAX_' + targetfield + '_' + targetroomid;
	
	if(http.readyState == 4)
	{
		var response = http.responseText;
				
		document.getElementById(ajax_fieldname).innerHTML = response;
		
		if (targetfield == 'Adults')
		{
			targetfield = 'Child';
			getRoomFields(targethotelid, targetroomid, 'Child', targetxmlroomid);			
			placeholder();
		} else {
			placeholder();
		}
	} else {
		document.getElementById(ajax_fieldname).innerHTML = '<img src="/images/ajax-loader.gif" width="16" height="16" border="0" alt="Loading" />';
	}
}

function placeholder ()
{
	// moo
}

function checkLimits (RoomID, Maxocupancy)
{						
	var adults 			= document.getElementById('Adults_' + RoomID);
	var adults_index	= adults.options.selectedIndex;
	var adults_count	= adults.options[adults_index].value;
	
	var child 			= document.getElementById('Child_' + RoomID);
	var child_index		= child.options.selectedIndex;
	var child_count		= child.options[child_index].value;
	
	adults_count		= parseInt(adults_count);
	child_count			= parseInt(child_count);
	
	var totalcount 		= adults_count+child_count;
	
	var tick 		= '<img src="/images/icons/tick_256.png" width="16" height="16" alt="Valid number of occupants" border="0" align="absmiddle" />';
	var cross 		= '<img src="/images/icons/cross_256.png" width="16" height="16" alt="Invalid number of occupants" border="0" align="absmiddle" />';
	var image		= null;
		
	if (!isNaN(totalcount))
	{
		isused[RoomID] = true;
		
		if (totalcount < 1)
		{
			image = cross;
			isused[RoomID] = 'fail';
			
		} else if (totalcount > Maxocupancy) {
			image = cross;
			isused[RoomID] = 'fail';
			
		} else {
			image = tick;
			isused[RoomID] = 'ok';
		}
		
		var counter 		= 'AJAX_Count_' + RoomID;
		document.getElementById(counter).innerHTML = image + ' <strong>' + totalcount + '/' + Maxocupancy + '</strong>';
	}
}

function doFinalCheck ()
{
	var fail 	= false;
	var allnull = true;
	
	if (isused[1] != null)
	{
		allnull = false;
		if (isused[1] == 'fail')
		{
			fail = true;
		}
	}
	
	if (isused[2] != null)
	{
		allnull = false;
		if (isused[2] == 'fail')
		{
			fail = true;
		}
	}
	
	if (isused[3] != null)
	{
		allnull = false;
		if (isused[3] == 'fail')
		{
			fail = true;
		}
	}
	
	var message = document.getElementById('AJAX_Message');
	
	if (allnull == true)
	{
		message.innerHTML = "Please select at least one room and ensure you have selected <br />both the number of adults and number of children.";
	} else {
		if (fail == true)
		{
			message.innerHTML = "At least one selected room does not meet occupancy. <br />(Look for a red cross)";
		} else {
			document.SelectRooms.submit();
		}
	}
}

/*
* Snowing routine based on one <canvas> element dynamically 
* injected in the background of the page.
* 
* The code is not optimized, feel free to make your own edits!
*
* Copyright 2010 by David Flanagan
* http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* Modified by Giorgio Sardo
* http://blogs.msdn.com/Giorgio

(function () {

    // Start Animation only if browser support <canvas>
    if (document.createElement('canvas').getContext) {
        if (document.readyState === 'complete')
            Snow();
        else
            window.addEventListener('DOMContentLoaded', Snow, false);
    }

    var deg = Math.PI / 180;         // For converting degrees to radians
    var sqrt3_2 = Math.sqrt(3) / 2;  // Height of an equilateral triangle
    var flakes = [];               // Things that are dropping
    var scrollspeed = 64;   // How often we animate things
    var snowspeed = 200;    // How often we add a new snowflake
    var maxflakes = 120;     // Max number of flakes to be added at the same time
    var rand = function (n) { return Math.floor(n * Math.random()); }

    var canvas, sky;
    var snowingTimer;
    var invalidateMeasure = false;

    function Snow() {
        canvas = document.createElement('canvas');
        canvas.style.position = 'fixed';
        canvas.style.top = '0px';
        canvas.style.left = '0px';
        canvas.style.zIndex = '0';
        document.body.insertBefore(canvas, document.body.firstChild);
        sky = canvas.getContext('2d');

        ResetCanvas();

        snowingTimer = setInterval(createSnowflake, snowspeed);
        setInterval(moveSnowflakes, scrollspeed);

        window.addEventListener('resize', ResetCanvas, false);
    }

    function ResetCanvas() {
        invalidateMeasure = true;
        canvas.width = document.body.offsetWidth;
        canvas.height = window.innerHeight;
        sky.strokeStyle = 'white';
        sky.fillStyle = 'white';
    }

    function drawFlake(x, y, size, order) {
        sky.save();
        sky.translate(x, y);
        snowflake(order, 0, Math.floor(sqrt3_2 * y), size);
        sky.fill();
        sky.stroke();
        sky.restore();
    }

    function snowflake(n, x, y, len) {
        sky.save();           // Save current transformation
        sky.beginPath();
        sky.translate(x, y);   // Translate to starting point
        sky.moveTo(0, 0);      // Begin a new subpath there
        leg(n);             // Draw the first leg of the fractal
        sky.rotate(-120 * deg); // Rotate 120 degrees anticlockwise
        leg(n);             // Draw the second leg
        sky.rotate(-120 * deg); // Rotate again.
        leg(n);             // Draw the final leg
        sky.closePath();      // Close the subpath
        sky.restore();        // Restore original transformation

        // Draw a single leg of a level-n Koch snowflake.
        // This function leaves the current point at the end of
        // the leg it has drawn and translates the coordinate
        // system so the current point is (0,0). This means you
        // can easily call rotate() after drawing a leg.
        function leg(n) {
            sky.save();               // Save current transform
            if (n == 0) {           // Non-recursive case:
                sky.lineTo(len, 0);   //   Just a horizontal line
            }
            else { // Recursive case:           _  _
                //     draw 4 sub-legs like:  \/
                sky.scale(1 / 3, 1 / 3);   // Sub-legs are 1/3rd size
                leg(n - 1);           // Draw the first sub-leg
                sky.rotate(60 * deg);   // Turn 60 degrees clockwise
                leg(n - 1);           // Draw the second sub-leg
                sky.rotate(-120 * deg); // Rotate 120 degrees back
                leg(n - 1);           // Third sub-leg
                sky.rotate(60 * deg);   // Back to original heading
                leg(n - 1);           // Final sub-leg
            }
            sky.restore();            // Restore the transform
            sky.translate(len, 0);    // Translate to end of leg
        }
    }

    function createSnowflake() {
        var order = 2;
        var size = 2 + rand(10);
        var t = (document.body.offsetWidth - 964) / 2;
        var x = (rand(2) == 0) ? rand(t) : t + 964 + rand(t); // Make it fit with my blog
        var y = window.pageYOffset;

        flakes.push({ x: x, y: y, vx: 0, vy: 3 + rand(3), size: size, order: order });

        if (flakes.length > maxflakes) clearInterval(snowingTimer);
    }

    function moveSnowflakes() {
        sky.clearRect(0, 0, canvas.width, canvas.height);

        var maxy = canvas.height;

        for (var i = 0; i < flakes.length; i++) {
            var flake = flakes[i];

            flake.y += flake.vy;
            flake.x += flake.vx;

            if (flake.y > maxy) flake.y = 0;
            if (invalidateMeasure) {
                var t = (canvas.width - 964) / 2;
                flake.x = (rand(2) == 0) ? rand(t) : t + 964 + rand(t);
            }

            drawFlake(flake.x, flake.y, flake.size, flake.order);

            // Sometimes change the sideways velocity
            if (rand(4) == 1) flake.vx += (rand(11) - 5) / 10;
            if (flake.vx > 2) flake.vx = 2;
            if (flake.vx < -2) flake.vx = -2;
        }
        if (invalidateMeasure) invalidateMeasure = false;
    }

} ()); */


