var imgArray = new Array(6);
var minHeight = 0;
var imgAIndex = 0;
var portraitImageCount = 0;
var landscapeImageCount = 0;
var smallImageCount = 0;
var imgContainer = new Array(7);
var imgSrc = new Array(7);
var imgTopLabel = new Array(7);
var imgTopButtons = new Array(7);
var imgControls = new Array(7);
var imgMoveControls = new Array(7);

function arrangeImageGallery()
{
	try
	{
		//alert(1);
		
		for(i = 1; i < 7; i++)
		{
			var cI = i+1;
			imgContainer[i] = document.getElementById('AdImageContainer' + cI)

			if(document.getElementById('AdImageMoveControls' + cI))
			{
				imgMoveControls[i] = document.getElementById('AdImageMoveControls' + cI)
			}
			else
			{
				imgMoveControls[i] = null;
			}

			if(document.getElementById('AdImageControls' + cI))
			{
				imgControls[i] = document.getElementById('AdImageControls' + cI)
			}
			else
			{
				imgControls[i] = null;
			}

			if(document.getElementById('AdImageSrc' + cI))
			{
				imgSrc[i] = document.getElementById('AdImageSrc' + cI)
			}
			else
			{
				imgSrc[i] = null;
			}

			if(document.getElementById('AdImageTopLabel' + cI))
			{
				imgTopLabel[i] = document.getElementById('AdImageTopLabel' + cI)
			}
			else
			{
				imgTopLabel[i] = null;
			}

			if(document.getElementById('AdImageTopButtons' + cI))
			{
				imgTopButtons[i] = document.getElementById('AdImageTopButtons' + cI)
			}
			else
			{
				imgTopButtons[i] = null;
			}
		}
		
		//alert(2);

		for(i = 0; i < imgArray.length; i++)
		{
			imgArray[i] = new Array(12);
		}
		
		//alert(3);

		for(i = 2; i < 8; i++)
		{
			var selImg = document.getElementById('AdImage' + i)
			if(selImg)
			{
				imgArray[imgAIndex][0] = selImg;
				imgArray[imgAIndex][1] = selImg.width;
				imgArray[imgAIndex][2] = selImg.height;

				if(imgArray[imgAIndex][2] > imgArray[imgAIndex][1] && imgArray[imgAIndex][2] >= 350)
				{
					imgArray[imgAIndex][3] = 1;
					portraitImageCount++;
				}
				else if(imgArray[imgAIndex][1] >= 350)
				{
					imgArray[imgAIndex][3] = 0;
					landscapeImageCount++;
				}
				else
				{
					imgArray[imgAIndex][3] = 2;
					smallImageCount++;
				}
			
				imgArray[imgAIndex][4] = document.getElementById('AdImageContainer' + i).innerHTML;

				if(document.getElementById('AdImageTopLabel' + i))
					imgArray[imgAIndex][8] = document.getElementById('AdImageTopLabel' + i).innerHTML;

				if(document.getElementById('AdImageTopButtons' + i))
					imgArray[imgAIndex][9] = document.getElementById('AdImageTopButtons' + i).innerHTML;

				imgArray[imgAIndex][5] = selImg.src;

				if(document.getElementById('AdImageTop' + i))
				{
					imgArray[imgAIndex][6] = document.getElementById('AdImageTop' + i).value;
				}
				else
				{
					imgArray[imgAIndex][6] = 0;
				}

				imgArray[imgAIndex][7] = document.getElementById('AdImagePosition' + i);

				if((minHeight == 0 || minHeight > imgArray[imgAIndex][2]) && imgArray[imgAIndex][2] > 183 && imgArray[imgAIndex][3] == 0)
				{
					minHeight = imgArray[imgAIndex][2];	
				}
				
				if(document.getElementById('AdImageControls' + i))
					imgArray[imgAIndex][10] = document.getElementById('AdImageControls' + i).innerHTML;
					
				if(document.getElementById('AdImageMoveControls' + i))
					imgArray[imgAIndex][11] = document.getElementById('AdImageMoveControls' + i).innerHTML;

				imgAIndex++;
			}
		}
		
		//alert(4);

		var contLargeIndex = 1;
		var contPortraitIndex = 1 + landscapeImageCount;
		var contSmallIndex = 1 + landscapeImageCount + portraitImageCount;
		var contIndex = 1;

		// Large landscape images first
		// Large portrait images second
		// Small images last
		
		//alert(5);

		for(i = 0; i < imgArray.length; i++)
		{	
			if(imgArray[i][0])
			{
				if(imgArray[i][3] == 0) // Large Landscape
				{
					//alert(81);
					
					contIndex = contLargeIndex;
					imgContainer[contIndex].style.width = '350px';
					imgArray[i][0].style.width = '350px';

					if(imgArray[i][2] > minHeight && minHeight > 0)
					{
						imgContainer[contIndex].style.height = minHeight + 'px';
					}

					if(imgArray[i][1] / imgArray[i][2] > 1.5 && imgTopLabel[contIndex])
						imgTopLabel[contIndex].style.backgroundColor = '#ff822f';

					contLargeIndex++;
				}
				else if(imgArray[i][3] == 1) // Large Portrait
				{
					//alert(82);

					contIndex = contPortraitIndex;

					imgContainer[contIndex].style.height = '350px';
					imgContainer[contIndex].style.width = ((350 / imgArray[i][2]) * imgArray[i][1]) + 'px';
					imgArray[i][0].style.height = '350px';
					imgArray[i][11] = '';
					imgArray[i][10] = '<p>The order of portrait images cannot be changed. <br/><br/>The image will be automatically positioned at the end of the gallery.</p>';

					contPortraitIndex++;
				}
				else if(imgArray[i][3] == 2) // Small
				{
					//alert(83);

					contIndex = contSmallIndex;

					imgContainer[contIndex].style.width = imgArray[i][1] + 'px';
					imgArray[i][0].style.width = imgArray[i][1] + 'px';
					imgArray[i][11] = '';
					imgArray[i][10] = '<p>This image is below the size guidelines for the Holiday France Direct website. <br/><br/>The gallery order cannot be changed, the image will be automatically positioned at the end of the gallery.</p>';

					contSmallIndex++;

					if(imgTopLabel[contIndex])
						imgTopLabel[contIndex].style.backgroundColor = '#ff822f';
				}

				//alert(6);

				imgContainer[contIndex].innerHTML = imgArray[i][4];

				if(imgTopLabel[contIndex])
					imgTopLabel[contIndex].innerHTML = imgArray[i][8];

				if(imgTopButtons[contIndex])
					imgTopButtons[contIndex].innerHTML = imgArray[i][9];

				if(imgControls[contIndex])
					imgControls[contIndex].innerHTML = imgArray[i][10];

				if(imgMoveControls[contIndex])
					imgMoveControls[contIndex].innerHTML = imgArray[i][11];

				if(imgSrc[contIndex])
					imgSrc[contIndex].src = imgArray[i][5].replace('.web.','.thumb.').replace('/id','/thumb/id').replace('proppics','smallproppics');
			}
		}
		
		//alert(7);

	}
	catch(err) {}
}


var lastAvailOCode = '';
var lastAvailPropertyID = '';
var lastAvailPropertyYear = '';
var availPending = false;
var ajaxPage = new Ajax();
var ajaxCSS = new Ajax();

function closeAvailability(oCode, propertyID, availYear)
{	
	availPending = false;
	
	document.getElementById('displayAvailability').style.visibility = 'hidden';
	document.getElementById('displayAvailability').style.display = 'none';
	
	if(document.getElementById('orderBySizeVisible'))
	{
		document.getElementById('orderBySizeVisible').style.visibility = 'visible';
		document.getElementById('orderBySizeVisible').style.display = '';
		document.getElementById('orderByPriceVisible').style.visibility = 'visible';
		document.getElementById('orderByPriceVisible').style.display = '';
	}
}

function showAvailability(oCode, propertyID)
{
	showAvailability(oCode, propertyID, -1);
}

function showAvailability(oCode, propertyID, availYear)
{	
	ajaxCSS.makeRequest('GET', strBaseHref + 'showavail.cfm?mode=CSS&ownerCode='+oCode+'&propertyID='+propertyID+'&year='+availYear, onViewAvailabilityCSSResponse);
	ajaxPage.makeRequest('GET', strBaseHref + 'showavail.cfm?mode=PAGE&ownerCode='+oCode+'&propertyID='+propertyID+'&year='+availYear, onViewAvailabilityResponse);
	
	lastAvailOCode = oCode;
	lastAvailPropertyID = propertyID;
	lastAvailPropertyYear = availYear;
	
	availPending = true;
	
	self.setTimeout('checkAvailabilityDisplay()', 3000);
}

function checkAvailabilityDisplay()
{
	if(availPending)
	{
		showAvailability(lastAvailOCode,lastAvailPropertyID,lastAvailPropertyYear);
	}
}

function onViewAvailabilityResponse()
{
	availPending = false;
	
	if(ajaxPage.checkReadyState('displayAvailability') == 200) 
	{ 
		if(document.getElementById('orderBySizeVisible'))
		{
			document.getElementById('orderBySizeVisible').style.visibility = 'hidden';
			document.getElementById('orderBySizeVisible').style.display = 'none';
			document.getElementById('orderByPriceVisible').style.visibility = 'hidden';
			document.getElementById('orderByPriceVisible').style.display = 'none';
		}
		
		var ScrollTop = 0;

		if (window.pageYOffset)
		{
			ScrollTop = window.pageYOffset;
		}
		
		if(ScrollTop == 0 && document.getElementById('displayAvailability').offsetParent)
		{
			ScrollTop = document.getElementById('displayAvailability').offsetParent.scrollTop;
		}
		
		if(ScrollTop == 0 && document.body.parentElement)
		{
			ScrollTop = document.body.parentElement.scrollTop;
		}
			
					
		ScrollTop = ScrollTop + 50;
		
		document.getElementById('displayAvailability').style.top = ScrollTop + 'px';
		document.getElementById('displayAvailability').style.visibility = 'visible';
		document.getElementById('displayAvailability').style.display = '';
		
		var bodyWidth = document.body.clientWidth;
		var availWidth = 741;
		//document.getElementById('displayAvailability').offsetWidth;
		var availLeft = 0;
		
		if(availWidth < bodyWidth)
		{
			availLeft = (bodyWidth - availWidth) / 2;
		}
		
		availLeft += 100;
		
		document.getElementById('displayAvailability').style.left = availLeft + 'px';
		
		document.getElementById('displayAvailability').innerHTML = ajaxPage.request.responseText;
	}
}

function onViewAvailabilityCSSResponse()
{
	if(ajaxCSS.checkReadyState('displayAvailabilityCSS') == 200) 
	{ 	
		try
		{
			document.getElementsByTagName("head")[0].removeChild(document.getElementsByTagName("head")[0].lastChild);
		}
		catch(err) {}
		
		var cssCode = ajaxCSS.request.responseText;
		
		var styleElement = document.createElement("style");
		styleElement.type = "text/css";
		if (styleElement.styleSheet) 
		{
			styleElement.styleSheet.cssText = cssCode;
		} 
		else 
		{
			styleElement.appendChild(document.createTextNode(cssCode));
		}
		document.getElementsByTagName("head")[0].appendChild(styleElement);
	}
}

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	// var counter = document.createElement('div');
	// counter.className = 'counter';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			// var counterClone = counter.cloneNode(true);
			// counterClone.relatedElement = x[i];
			// counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
			// x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			// x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.value = this.value.substring(0, maxLength);
	//	this.relatedElement.className = 'toomuch';
	// else
	// 	this.relatedElement.className = '';
	// this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

var newWin;
function Ajax()
{
	this.toString = function() {return "Ajax";}
	this.makeRequest = function(_method, _url, _callbackMethod)
	{
		this.request = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");
		this.request.onreadystatechange = _callbackMethod;
		this.request.open(_method, _url, true);
		this.request.send(_url);
	}
	this.checkReadyState = function(_id, waitContent)
	{
		if (!waitContent) {var waitContent = "Loading...";}
		switch(this.request.readyState)
		{
			case 1: document.getElementById(_id).innerHTML = waitContent;break;
			case 2: document.getElementById(_id).innerHTML = waitContent;break;
			case 3: document.getElementById(_id).innerHTML = waitContent;break;
			case 4: return this.request.status;
		}
	}
}

function ShowError(fName)
{
	if(document.getElementById('error_'+fName))
	{
		document.getElementById('error_'+fName).style.visibility = 'visible';
		document.getElementById('error_'+fName).style.display = '';
	}
	if(document.getElementById(fName))
	{
		document.getElementById(fName).style.border = '1px #ff0000 solid';
		document.getElementById(fName).style.background = '#ffcccc';
	}
}

function HideError(fName)
{
	if(document.getElementById('error_'+fName))
	{
		document.getElementById('error_'+fName).style.display = 'none';
		document.getElementById('error_'+fName).style.visibility = 'hidden';
	}
	if(document.getElementById(fName))
	{
		document.getElementById(fName).style.border = '1px #999999 solid';
		document.getElementById(fName).style.background = '#ffffff';
	}
}

// scroll.js
var leftmostContent;
var topPos = 0;
var slider;
var container;
var target;
var timerId = -1;
var minTop = 0;
var themeTopPos = 0;
var typeTopPos = 0;

function moveLeft()
{
	leftSide -= 1;
	slider.style.left = leftSide;

	if (target + leftSide < 0)
	{
		leftSide = 0;
		slider.style.left = leftSide;
		slider.removeChild(leftmostContent);

		leftmostContent = slider.getElementsByTagName("div")[0];
		slider.appendChild(leftmostContent.cloneNode(true));

		target = leftmostContent.offsetWidth;
	}
}

function moveThemeUp()
{
	topPos -= 1;
	
	if(topPos <= minTop)
	{
		StopThemeScroll();
	}
	else
	{
		slider.style.top = topPos + 'px';
	}
}

function moveThemeDown()
{
	topPos += 1;
	
	if(topPos >= 0)
	{
		StopThemeScroll();
	}
	else
	{
		slider.style.top = topPos + 'px';
	}
}

function moveTypeUp()
{
	topPos -= 1;
	
	if(topPos <= minTop)
	{
		StopTypeScroll();
	}
	else
	{
		slider.style.top = topPos + 'px';
	}
}

function moveTypeDown()
{
	topPos += 1;
	
	if(topPos >= 0)
	{
		StopTypeScroll();
	}
	else
	{
		slider.style.top = topPos + 'px';
	}
}

function printDebug()
{
	document.getElementById("debugLeftSide").innerHTML = "" + leftSide;
	document.getElementById("debugContentWidth").innerHTML = target + " " + leftmostContent.id;
}

function holderMouseOver()
{
	if (timerId != -1) window.clearInterval(timerId);
}

function holderMouseOut()
{
	timerId = window.setInterval(moveLeft, 20);
}

function ScrollTypeUp()
{
	slider = document.getElementById("sliderType");	
	container = document.getElementById("typeScroll");
	minTop = -363;
	topPos = typeTopPos;
	timerId = window.setInterval(moveTypeUp, 15);
}

function ScrollTypeDown()
{
	slider = document.getElementById("sliderType");	
	container = document.getElementById("typeScroll");
	topPos = typeTopPos;
	timerId = window.setInterval(moveTypeDown, 15);
}

function ScrollThemeUp()
{
	slider = document.getElementById("sliderTheme");
	container = document.getElementById("themeScroll");
	minTop = -199;
	topPos = themeTopPos;
	timerId = window.setInterval(moveThemeUp, 15);
}

function ScrollThemeDown()
{
	slider = document.getElementById("sliderTheme");	
	container = document.getElementById("themeScroll");
	topPos = themeTopPos;
	timerId = window.setInterval(moveThemeDown, 15);
}

function StopThemeScroll()
{
	themeTopPos = topPos;
	window.clearInterval(timerId);
}

function StopTypeScroll()
{
	typeTopPos = topPos;
	window.clearInterval(timerId);
}


function GetScrollYPos() {
	var y;
	if (self.pageYOffset)
	{
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		y = document.documentElement.scrollTop;
	}
	else if (document.body)
	{
		y = document.body.scrollTop;
	}
	return y;
}

function SetScrollYPos(y) {
	window.scrollTo(0,y);
}


var ScrollableViewPort_Element;
var ScrollableViewPort_TimerId;
var ScrollableViewPort_Direction;
var ScrollableViewPort_StopPos;

function ScrollableViewPort_Stop() 
{
	window.clearInterval(ScrollableViewPort_TimerId);
}

function ScrollableViewPort_DoScrollUp() 
{
	var nextpos = parseInt(ScrollableViewPort_Element.style.top) + 3;
	if (nextpos >= ScrollableViewPort_StopPos) {
		nextpos = ScrollableViewPort_StopPos;
		ScrollableViewPort_Stop();
	}
	ScrollableViewPort_Element.childNodes[1].value = -1 * nextpos;
	ScrollableViewPort_Element.style.top = nextpos + "px";
}

function ScrollableViewPort_DoScrollLeft() 
{
	var nextpos = parseInt(ScrollableViewPort_Element.style.left) + 3;
	if (nextpos >= ScrollableViewPort_StopPos) {
		nextpos = ScrollableViewPort_StopPos;
		ScrollableViewPort_Stop();
	}
	ScrollableViewPort_Element.childNodes[0].value = -1 * nextpos;
	ScrollableViewPort_Element.style.left = nextpos + "px";
}

function ScrollableViewPort_DoScrollRight() 
{
	var nextpos = parseInt(ScrollableViewPort_Element.style.left) - 3;
	if (nextpos <= ScrollableViewPort_StopPos) {
		nextpos = ScrollableViewPort_StopPos;
		ScrollableViewPort_Stop();
	}
	ScrollableViewPort_Element.childNodes[0].value = -1 * nextpos;
	ScrollableViewPort_Element.style.left = nextpos + "px";
}

function ScrollableViewPort_DoScrollDown() 
{
	var nextpos = parseInt(ScrollableViewPort_Element.style.top) - 3;
	if (nextpos <= ScrollableViewPort_StopPos) {
		nextpos = ScrollableViewPort_StopPos;
		ScrollableViewPort_Stop();
	}
	ScrollableViewPort_Element.childNodes[1].value = -1 * nextpos;
	ScrollableViewPort_Element.style.top = nextpos + "px";
}

function ScrollableViewPort_Scroll(elementId,direction) 
{
	ScrollableViewPort_Element = document.getElementById(elementId);
	ScrollableViewPort_Direction = direction;
	
	switch (ScrollableViewPort_Direction) 
	{
		case 1: // scroll up
			ScrollableViewPort_StopPos = 0;
			ScrollableViewPort_TimerId = window.setInterval(ScrollableViewPort_DoScrollUp, 15);
			break;
		case 2: // scroll left
			ScrollableViewPort_StopPos = 0;
			ScrollableViewPort_TimerId = window.setInterval(ScrollableViewPort_DoScrollLeft, 15);
			break;
		case 3: // scroll right
			ScrollableViewPort_StopPos = ScrollableViewPort_Element.parentNode.clientWidth - ScrollableViewPort_Element.clientWidth;
			ScrollableViewPort_TimerId = window.setInterval(ScrollableViewPort_DoScrollRight, 15);
			break;
		case 4: // scroll down
			ScrollableViewPort_StopPos = ScrollableViewPort_Element.parentNode.clientHeight - ScrollableViewPort_Element.clientHeight;
			ScrollableViewPort_TimerId = window.setInterval(ScrollableViewPort_DoScrollDown, 15);
			break;
	}
}

// site_scripts.js		
function checkFriendForm()
{
	var msg = '';
	
	if(document.frmFriend.txtFriendName.value==''){
		msg += "\n- Your friend's name";
	}
	if(document.frmFriend.txtFriendEmail.value==''){
		msg += "\n- Your friend's email";
	}
	else if(!isEmail(document.frmFriend.txtFriendEmail.value)){
		msg += "\n- Your friend's email is invalid";
	}
	if(document.frmFriend.txtName.value==''){
		msg += "\n- Your name";
	}
	if(document.frmFriend.txtEmail.value==''){
		msg += "\n- Your email";
	}
	else if(!isEmail(document.frmFriend.txtEmail.value)){
		msg += "\n- Your email is invalid";
	}
		
	if(msg==''){
		document.frmFriend.submit();
	}
	else{
		alert('Please complete the following:'+msg);
	}
}

function IsDate(year, month, day)
{
	// month argument must be in the range 1 - 12
	month = month - 1; // javascript month range : 0- 11

	var tempDate = new Date(year,month,day);

	if ((year == tempDate.getUTCFullYear()) &&
		(month == tempDate.getMonth()) &&
		(day == tempDate.getDate()) )
		return true;
	else
		return false
}

function checkReviewInviteForm()
{
	var msg = '';
	var f = document.getElementById('frmInvite');
	
	if(f.txtName.value==''){
		msg += "\n- Guest\'s name";
	}
	if(f.txtEmail.value==''){
		msg += "\n- Guest\'s email";
	}
	else if(!isEmail(f.txtEmail.value)){
		msg += "\n- Guest\'s email is invalid";
	}
	
	var fday = f.lstArrivalD.options[f.lstArrivalD.selectedIndex].value;
	var fmonth = f.lstArrivalM.options[f.lstArrivalM.selectedIndex].value;
	var fyear = f.lstArrivalY.options[f.lstArrivalY.selectedIndex].value;
	
	var tday = f.lstDepartureD.options[f.lstDepartureD.selectedIndex].value;
	var tmonth = f.lstDepartureM.options[f.lstDepartureM.selectedIndex].value;
	var tyear = f.lstDepartureY.options[f.lstDepartureY.selectedIndex].value;
	
	var datesValid = true;

	if(!IsDate(fyear,fmonth,fday))
	{
		datesValid = false;
		msg += "\n- Arrival date is invalid";
	}

	if(!IsDate(tyear,tmonth,tday))
	{
		datesValid = false;
		msg += "\n- Departure date is invalid";
	}

	if(datesValid)
	{
		var fromDate = new Date(fyear,fmonth,fday);
		var toDate = new Date(tyear,tmonth,tday);

		if(fromDate > toDate)
		{
			msg += "\n- Arrival date must be less than or equal to departure date";
		}
	}
	

	if(msg==''){
		f.submit();
	}
	else{
		alert('Please complete the following:'+msg);
	}
}

function ChangeImage(imgID, highResID)
{
	document.getElementById('GalleryMain').src = 'images/bfImgLib/id' + highResID + '.web.jpg';
}

function ChangeImagePreview(imgID, imgPath)
{
	document.getElementById('GalleryMain').src = 'OIFadverts/graphics/AdvertBookingImages/output/' + imgPath;
}

function OwnerLogin()
{
	var msg = "";
	if(document.frmLogin.OwnerCode.value=='')
	{
		msg += "\n- Owner Code";
	}
	if(document.frmLogin.Password.value=='')
	{
		msg += "\n- Password"
	}
	if(msg=="")
	{
		document.frmLogin.submit();
	}
	else
	{
		alert("Please complete the following:"+msg);
	}
}

function OwnerLogout()
{
	document.frmLogout.submit();
}

function AddToFavorites()
{
	window.external.AddFavorite(location.href, document.title);
}

function PopupMap(s){ 
	ShowPopUpWindow('winMap', strBaseHref + 'showmap.cfm/ownercode.' + s, 600, 580, 'no', 'no', 'no');
}

function showAvail(s){
	ShowPopUpWindow('winAvail', strBaseHref + 'showavail.cfm?ownercode=' + s, 720, 550, 'yes', 'yes', 'yes');
}

function SpainSearch(){
	var f = document.frmSpain;
	var g = document.frmSQL;
	f.txtSpainRegion.value = 'es';
	f.action = strBaseHref + 'default.cfm/loadindex.67';
	g.ViewResults.value = 'true';
	f.submit();

}

function OIFBookingScreen() {
	ShowPopUpWindow('BookingWin', strBaseHref+'booking.cfm?loadindex=69',550,550,'yes','yes','yes');
}

function oifbookingscreen() {
	OIFBookingScreen();
}

function printPage() {
	window.print();
}

function downloadpack() {
	document.frmAdValues.frmType.value = "download";
	document.frmAdValues.action = strThisFile;
	document.frmAdValues.submit();
}

function ShowPopUpWindow(Name,File,Width,Height,Status,Resize,Scroll,top,left,toolbar,menubar) {
	if(!left) {
		l=(screen.width/2)-(Width/2)
	} else {
		l=left
	}
	
	if(!toolbar) {
		tb='no';
	} else {
		tb=toolbar;
	}
	
	if(!menubar) {
		mb = 'no';
	} else {
		mb = 'yes';
	}

	if(!top) {
		t=(screen.height/2)-(Height/2)
	} else {
		t=top
	}
	if(newWin){
		if (!newWin.closed){
			newWin.close()
		}
	}
	winstring="width="+Width+",height="+Height+",left="+l+",top="+t+",status="+Status+",resizable="+Resize+",scrollbars="+Scroll+",toolbar="+tb+",menubar="+mb
	newWin=window.open(File,Name,winstring);
	return;
}

function SubmitForm(c){
	var f = document.frmSQL;
	var strOwnerCode = document.frmPSearch.txtSearch.value;
	f.sql.value = "SELECT * FROM SearchOwners WHERE OwnerCode = '" + strOwnerCode.toUpperCase() + "' AND WebPublish = 1;";
	f.ViewAd.value = 'true';
	f.tmpOwnerCode.value = strOwnerCode;
	f.ViewResults.value = 'false';
	f.AdNum.value = '1';
	f.action = strBaseHref;
	f.submit();
}
function SubmitFormMonth(oc,yearmonth){

	var f = document.frmSQL;
	var strOwnerCode = oc;

	f.sql.value = "SELECT * FROM SearchOwners WHERE OwnerCode = '" + strOwnerCode.toUpperCase() + "' AND WebPublish = 1;";
	f.ViewAd.value = 'true';
	f.ViewResults.value = 'false';
	f.AdNum.value = '1';
	f.action = strBaseHref + "default.cfm/"+ "yearmonth." + yearmonth + "/scrollto.bottom";
	f.submit();
}
function SubmitSCSearch(){

	var f = document.frmSearch;
	var msgString = '';

	// if a date is selected, check it's valid
	if( f.lstDay.value == 'any' || f.lstMonth.value == 'any' || f.lstYear.value == 'any' ){
		f.lstDay.selectedIndex = 0;
		f.lstMonth.selectedIndex = 0;
		f.lstYear.selectedIndex = 0;
	}
	else{

		var dtSearch = f.lstMonth.value + '/' + f.lstDay.value + '/' + f.lstYear.value;

		if( !isDate( dtSearch ) ){
			msgString += 'Please enter a valid date!';
		}
		else{ // check date is after today
			var stringList = dtNow.split('/');

			if( parseInt(f.lstYear.value) < parseInt(stringList[2]) ){
				msgString += 'Please enter a future date!';
			}
			else if( parseInt(f.lstYear.value) == parseInt(stringList[2]) ){
				if( parseInt(f.lstMonth.value) < parseInt(stringList[1]) ){
					msgString += 'Please enter a future date!';
				}
				else if( parseInt(f.lstMonth.value) == parseInt(stringList[1]) ){
					if( parseInt(f.lstDay.value) < parseInt(stringList[0]) )
						msgString += 'Please enter a future date!';
				}
			}
		}
	}

	if( msgString == '' ){
		f.action = strThisFile;
		f.submit();
	}
	else
		alert( msgString );

}

function SubmitCDSearch(){

	var f = document.frmSearch;

	f.flgCDSearch.value = 'true';
	f.action = strThisFile;
	f.submit();

}

function ClickMapSpec(RegionCode){

	var f = document.frmRegsearch;

	f.lstRegions.value = RegionCode;
	
	f.action = strThisFile;
	f.submit();
}
function ClickMap(RegionCode, spanishProp){
	var f = document.frmSearch;

	if( spanishProp ){
		SpainSearch();
	}
	else{

		f.lstRegions.value = RegionCode;
		if( f.txtSearch )
			f.txtSearch.value = '';
		f.action = strThisFile;

		f.submit();

	}
}

function PrevAd(){
	var f = document.frmSQL;

	f.action = strThisFile;
	f.AdNum.value = parseInt(f.AdNum.value) - 1;
	f.submit();
}

function NextAd(){
	var f = document.frmSQL;

	f.action = strThisFile;
	f.AdNum.value = parseInt(f.AdNum.value) + 1;
	f.submit();
}

function ShowDetails(CurrRow, oc, propType){
	var f = document.frmSQL;

	if( oc ) var CurrRow = oc;

	f.FromPage.value = '';

	if( propType )
		f.FromPage.value = propType;

	f.AdNum.value = CurrRow;
	f.ViewAd.value = 'true';
	f.ViewResults.value = 'false';
	f.action = strBaseHref + 'default.cfm';
	f.submit();

}

function BackResults(fromPage){
	var f = document.frmSQL;

	f.ViewAd.value = 'false';
	f.ViewResults.value = 'true';

	if( fromPage == 'latest' ){
		document.location.href = strBaseHref + 'default.cfm/loadindex.59';
	}
	else if( fromPage == 'offers' ){
		document.location.href = strBaseHref + 'default.cfm/loadindex.58';
	}
	else if( fromPage == 'shortlist' ){
		document.location.href = strBaseHref + 'default.cfm/loadindex.87';
	}
	else{
		f.action = strBaseHref + 'default.cfm/loadindex.65';
		f.submit();
	}

}

function PrintableVersion(DocName) {
	ShowPopUpWindow('winprint', strBaseHref+'printadpage.cfm/adpage.'+DocName, 590, 500, 'no','yes','yes','','','yes','yes');
}

function ShowAboutCD(DocName){
	ShowPopUpWindow('winAbout', strBaseHref + 'showdoc.cfm?docname=' + DocName, 450, 500, 'no', 'no', 'yes');
}

function ShowAboutSC(DocName){
	ShowPopUpWindow('winAbout', strBaseHref + 'showdoc.cfm?docname=' + DocName, 450, 500, 'no', 'no', 'yes');
}

function ShowHowToBook(DocName){
	ShowPopUpWindow('winAbout', strBaseHref + 'showdoc.cfm?docname=' + DocName, 450, 500, 'no', 'no', 'yes');
}

function ShowNeedHelp(DocName){
	
	ShowPopUpWindow('winAbout', strBaseHref + 'showdoc.cfm?docname=' + DocName, 450, 500, 'no', 'no', 'yes');
}

function MultiPic(oc){
	ShowPopUpWindow('winMultiPic', strBaseHref + 'multipic.cfm?ownercode=' + oc, 300, 350, 'no', 'no', 'yes');
}

function Add2Shortlist(oc){
	document.location.href = strBaseHref + 'default.cfm/adcode.'+oc+'/shortlistadd.'+oc;
	// document.location.href = document.location.href + '/shortlistadd.'+oc;
	// ShowPopUpWindow('winAdd2Short', strBaseHref + 'add2shortlist.cfm?ownercode=' + oc, 410, 225, 'no', 'no', 'no');
}

function OwnerArea(){
	ShowPopUpWindow('winOwner', strBaseHref + 'availadmin/index.cfm' , 500, 500, 'no', 'no', 'no');
}

function ViewShortList(){
	document.location.href = strBaseHref + 'default.cfm/loadindex.999';
}

function RemoveFromShortlist(oc){
	document.location.href = document.location.href + '/shortlistremove.'+oc;
}

function isEmail(eml) {
	if(eml.indexOf("@") != "-1" &&
		eml.indexOf(".") != "-1" &&
		eml != "")
	return true;
	else return false;
}
// generic function for validating and submitting forms
function SubmitForm2(formName){
	var f = eval('document.' + formName);
	var msgString = '';

	switch( formName.toLowerCase() ){
		case 'frmbrochure':{
			// lsttitle
			if( f.lstTitle.selectedIndex == 0 ) msgString += '\n* Title';
			if( f.Initial.value == '' ) msgString += '\n* Initial';
			if( f.Surname.value == '' ) msgString += '\n* Surname';
			if( f.House.value == '' ) msgString += '\n* House Name';
			if( f.Street.value == '' ) msgString += '\n* Address 1';			
			if( f.Town.value == '' ) msgString += '\n* Town';			
			if( f.Postcode.value == '' ) msgString += '\n* Postcode';
			if( f.Email.value !='' || f.Data_Protection.checked) {
				if (!isEmail(f.Email.value)){
					msgString += '\n* valid Email';
				}
			}
			break;
		}
		case 'frmquicksubscribe':{
			if(f.txtQuickEmail.value == ''){
				msgString += '\n* Email Address';
			}
			else if (!isEmail(f.txtQuickEmail.value)){
				msgString += '\n* valid Email';
			}			
			break;
		}
		case 'frmmailing':{
			if( f.Title.value == '' ) msgString += '\n* Title';
			if( f.Forename.value == '' ) msgString += '\n* Forename';
			if( f.Surname.value == '' ) msgString += '\n* Surname';
			if (!isEmail(f.Email.value)){
				msgString += '\n* valid Email';
			}
			break;
		}
		case 'frmcontact':{
			if( f.Title.value == '' ) msgString += '\n* Title';
			if( f.Forename.value == '' ) msgString += '\n* Forename';
			if( f.Surname.value == '' ) msgString += '\n* Surname';
			if( f.HouseName.value == '' ) msgString += '\n* Housename';
			if( f.StreetName.value == '' ) msgString += '\n* Streetname';
			if( f.Town.value == '' ) msgString += '\n* Town';
			if( f.Postcode.value == '' ) msgString += '\n* Postcode';
			if( f.Country.value == '' ) msgString += '\n* Country';
			if( f.Email_Address.value == '' ) msgString += '\n* Email Address';
			if( f.Enquiry.value == '' ) msgString += '\n* Enquiry text';
			break;
		}
		case 'frmadvertise':{
			if( f.Title.value == '') msgString += '\n* Title';
			if( f.Forename.value == '') msgString += '\n* Forename';
			if( f.Surname.value == '') msgString += '\n* Surname';
			if( f.House_Name.value == '') msgString += '\n* House_Name';
			if( f.Street_Name.value == '') msgString += '\n* Street_Name';
			if( f.Town.value == '') msgString += '\n* Town';
			if( f.PostCode.value == '') msgString += '\n* PostCode';
			if( f.Country.value == '') msgString += '\n* Country';
			
			if( f.Email.value !='' || f.Email_Agreement.checked) {
				if (!isEmail(f.Email.value)){
					msgString += '\n* valid Email';
				}
			}
			
			if(f.lstEnquirySource.selectedIndex < 1) msgString += '\n* How did you hear about us';
			
			break;
		}
		default:{
			break;
		}
	}

	if( msgString == '' ){
		f.action = strThisFile;
		f.submit();
	}
	else{
		alert('Please enter the following fields:' + msgString);
	}

}

function sendbypost() {
	document.frmAdValues.frmType.value = "post";
	document.frmAdValues.action = strThisFile;
	document.frmAdValues.submit();
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	
	if (s.length == 0) {
		return false;
	}
	
	var i;
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	return true;
}

function trim(str) { return str.replace(/^\s*|\s*$/g,""); }

function stripCharsInBag(s, bag){
	var i;
	var returnString = "";
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year){
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
	return true
}

function switchSearch(advancedSearch){
	var defaultForm = document.frmSQL;
	var searchForm = document.frmSearch;
	var actionString = strThisFile;

	defaultForm.lstRegions.value = searchForm.lstRegions.value;
	defaultForm.lstDay.value = searchForm.lstDay.value;
	defaultForm.lstMonth.value = searchForm.lstMonth.value;
	defaultForm.lstYear.value = searchForm.lstYear.value;
	defaultForm.lstPeople.value = searchForm.lstPeople.value;
	defaultForm.lstBeds.value = searchForm.lstBeds.value;

	if( advancedSearch ){
		actionString += "/advanced.true";
	}
	else{
		actionString += "/advanced.false";
	}

	defaultForm.action = actionString;
	defaultForm.submit();

}
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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
				
function ShowHotelBookingService(){
	opener.document.location.href = strBaseHref + 'default.cfm/loadindex.93';
	self.close();
}

function ShowTravelInsurance() {
	opener.document.location.href = strBaseHref + 'default.cfm/loadindex.94';
	self.close();
}

function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function SetValue(id, newValue) {
	var identity=document.getElementById(id);
	identity.value=newValue;
}

function SetInnerHtml(id, newValue) {
	var identity=document.getElementById(id);
	identity.innerHTML=newValue;
}

function SetStyle(id, newClass) {
	var identity=document.getElementById(id);
	identity.className=newClass;
}

function AddStyle(id, newClass) {
	var identity=document.getElementById(id);
	if (identity.className != "false") {
		var style = identity.className;
		style = style + " " + newClass;
		identity.className = style;
	}
	else {
		identity.className = newClass;
	}
}

function RemoveStyle(id, oldClass) {
	var identity=document.getElementById(id);
	if (identity.className != "false") {
		var style = identity.className;
		style = replace(style,oldClass,"");
		identity.className = replace(identity.className,oldClass,"");
	}
}

function SetVisibility(id, visible) {
	var identity=document.getElementById(id);
	var style = "";
	if (identity.className) {
		style = identity.className;
	}
	if (visible) {
		style = replace(style,"hiddenElement","") + " visibleElement";
	}
	else {
		style = replace(style,"visibleElement","") + " hiddenElement";
	}
	identity.className = style;
}

/* getElementsByClassName
Written by Jonathan Snook, http://www.snook.ca/jonathan
Add-ons by Robert Nyman, http://www.robertnyman.com */
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}
			
function getRadioButtonValue(radioButtonArray) {
	var value = '';
	
	if (!radioButtonArray.length) {
		// Only one radio button, so form.radiobuttonname returns a radiobutton element, not an array
		if (radioButtonArray.checked) {
			value = radioButtonArray.value;
		}
	}
	else {
		for (var i=0; i<radioButtonArray.length; i++) {
			if (radioButtonArray[i].checked) {
				value = radioButtonArray[i].value;
				break;
			}
		}
	}
	
	return value;
}

function addToFavorites(urlAddress, pageName) { 
	if (window.external) { 
		window.external.AddFavorite(urlAddress,pageName) 
	} else { 
		alert("Sorry! Your browser doesn't support this function."); 
	}
}

function popupImageGallery(linkElement) {
	if (!window.focus) 
	{
		return true;
	}
	var popupHref = linkElement.href;
	ShowPopUpWindow("galleryimg",popupHref,440,578,'no','no','yes');
	return false;
}

function popupAvailability(linkElement) {
	if (!window.focus) 
	{
		return true;
	}
	var popupHref = linkElement.href;
	ShowPopUpWindow("availpopup",popupHref,750,600,'no','no','yes');
	return false;
}

// http://radio.javaranch.com/pascarello/replyToComment.action?entry=1105293729000
function ScrollToElement(id){
	var selectedPosX = 0;
	var selectedPosY = 0;

	var element = document.getElementById(id);

	while (element != null) {
		selectedPosX += element.offsetLeft;
		selectedPosY += element.offsetTop;
		element = element.offsetParent;
	}

	window.scrollTo(selectedPosX,selectedPosY);
}

function ScrollTo(y)
{
	window.scrollTo(0, y);
}

// search_scripts.js
var ajax = new Ajax();

function submitAjaxQuery() {
	var url = 'search/results_sc_resultcount.cfm';
	var fR = document.frmRefineSearch;
	var f = document.frmSearch;

	url += "?chkChildFac=";
	if (fR.chkChildFac.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkCouples=";
	if (fR.chkCouples.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkPets=";
	if (fR.chkPets.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkMeals=";
	if (fR.chkMeals.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkCleaning=";
	if (fR.chkCleaning.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkLinen=";
	if (fR.chkLinen.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkNoSmoking=";
	if (fR.chkNoSmoking.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkBandB=";
	if (fR.chkBandB.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkSpecNeeds=";
	if (fR.chkSpecNeeds.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkOoS=";
	if (fR.chkOoS.checked==true) { url+="1"; } else { url+="0"; }

	url += "&chkShortBk=";
	if (fR.chkShortBk.checked==true) { url+="1"; } else { url+="0"; }
	
	url += "&chkInternetAccess=";
	if (fR.chkInternetAccess.checked==true) { url+="1"; } else { url+="0"; }

	url += "&lstBeds="+f.lstBeds.value;
	url += "&orderType="+f.orderType.value;
	url += "&SearchPageSize="+f.SearchPageSize.value;
	url += "&searchType="+f.searchType.value;
	url += "&lstDay="+f.lstDay.value;
	url += "&lstMonth="+f.lstMonth.value;
	url += "&lstYear="+f.lstYear.value;
	url += "&lstPeople="+f.lstPeople.value;
	url += "&lstRegions="+f.lstRegions.value;
	url += "&lstLocation="+f.lstLocation.value;
	url += "&lstPool="+f.lstPool.value;
	url += "&departmentCode="+f.departmentCode.value;
	
	if (f.filterRegionCode.value != "") { url += "&filterRegionCode="+f.filterRegionCode.value; }
	if (f.filterDepartmentCode.value != "") { url += "&filterDepartmentCode="+f.filterDepartmentCode.value; }
	if (f.filterSleeps.value != "") { url += "&filterSleeps="+f.filterSleeps.value; }
	if (f.filterActivity.value != "") { url += "&filterActivity="+f.filterActivity.value; }
	if (f.filterPropertyType.value) { url += "&filterPropertyType="+f.filterPropertyType.value; }
	if (f.IsPartialAvailabilitySearch.value == "1") { url += "&IsPartialAvailabilitySearch=1"; }
	if (f.IsDailyAvailabilitySearch.value == "1") { url += "&IsDailyAvailabilitySearch=1"; }
	if (f.searchtextEncode.value != '') { url += "&searchtext="+f.searchtextEncode.value; }
	if (f.searchType.value == 'theme') { url += "&themeID="+f.ThemeID.value; }
	if (f.searchType.value == 'type' || f.searchType.value == 'leftmenu') { url += "&typeID="+f.TypeID.value; }

	var actString = '';
	for(i=0; i<fR.chkActivity.length; i++)
	{
		if(fR.chkActivity[i].checked==true)
		{
			actString += fR.chkActivity[i].value;
			actString += ',';
		}
	}
	url += "&activityIcons=" + actString;

	ajax.makeRequest('GET',url,onSearchResponse);
}


function onSearchResponse() {
	if(ajax.checkReadyState('searchTotal') == 200) { document.getElementById('searchTotal').innerHTML = ajax.request.responseText; }
}
		
function SubmitKeywordSearch() {
	var f = document.getElementById('frmKeywordSearch');
	var msg = '';
	
/* 	if(getRadioButtonValue(f.keywordref) == "")
	{
		msg += "\r\n- Select to search by keyword or by reference";
	}
	else
	{
		if(getRadioButtonValue(f.keywordref) == "keyword")
		{ */
			if (trim(f.searchtext.value) == '') {
				msg += "\r\n- Enter a reference or one or more keywords to search for.";
			}
/*		}
		else if(getRadioButtonValue(f.keywordref) == "ref")
		{
			if (trim(f.searchtext.value) == '') {
				msg += "\r\n- Enter a reference to search for.";
			}		
		}
	} */

	if ('' == msg) {
/*		if(getRadioButtonValue(f.keywordref) == "keyword")
		{ */
			f.action = strBaseHref + 'default.cfm/loadindex.65/searchType.keyword'
			f.submit();
/*		}
		else if(getRadioButtonValue(f.keywordref) == "ref")
		{
			f.action = strBaseHref + 'default.cfm/loadindex.65/searchType.ref'
			f.submit(); */
			
//			location.href = strBaseHref + 'default.cfm/adcode.'+f.searchtext.value;
//		}
	}
	else {
		alert ('Please correct the following errors and try again.' + msg);
	}
}

function startMapSearch(sType, squareID)
{
	var sURL = strBaseHref + searchURLTemplate;	
	sURL = sURL.replace('{squareID}', squareID);
	mainStartSearch(sType, sURL);
}

function startSearch(sType)
{
	var sURL = strBaseHref + searchURLTemplate;	
	mainStartSearch(sType, sURL);
}

function mainStartSearch(sType, sURL)
{	
	sURL = sURL.replace('{searchType}', sType);

	if(document.getElementById('orderBySizeVisible'))
	{
		sURL = sURL.replace('{orderBySize}', document.getElementById('orderBySizeVisible').options[document.getElementById('orderBySizeVisible').selectedIndex].value);
	}
	
	if(document.getElementById('orderByPriceVisible'))
	{
		sURL = sURL.replace('{orderByPrice}', document.getElementById('orderByPriceVisible').options[document.getElementById('orderByPriceVisible').selectedIndex].value);
	}
	
	if(sType == 'bnb')
	{
		var r = document.getElementById('region2').options[document.getElementById('region2').selectedIndex].value;
		if(r == '')
			r = 'all';
			
		sURL = sURL.replace('{lstRegions}', r);
		
	}
	else if(sType == 'selfcatering')
	{
		var r = document.getElementById('region').options[document.getElementById('region').selectedIndex].value;
		if(r == '')
			r = 'all';
			
		sURL = sURL.replace('{lstRegions}', r);
		
		sURL = sURL.replace('{lstPeople}', document.getElementById('lstPeople').options[document.getElementById('lstPeople').selectedIndex].value);
		sURL = sURL.replace('{lstBeds}', document.getElementById('lstBeds').options[document.getElementById('lstBeds').selectedIndex].value);
		sURL = sURL.replace('{lstDay}', document.getElementById('day').options[document.getElementById('day').selectedIndex].value);
		sURL = sURL.replace('{lstMonth}', document.getElementById('month').options[document.getElementById('month').selectedIndex].value);
		sURL = sURL.replace('{lstYear}', document.getElementById('year').options[document.getElementById('year').selectedIndex].value);
		sURL = sURL.replace('{TypeID}', document.getElementById('TypeID').options[document.getElementById('TypeID').selectedIndex].value);
		sURL = sURL.replace('{ThemeID}', document.getElementById('ThemeID').options[document.getElementById('ThemeID').selectedIndex].value);
		sURL = sURL.replace('{lstLocation}', document.getElementById('lstLocation').options[document.getElementById('lstLocation').selectedIndex].value);
		sURL = sURL.replace('{lstPool}', document.getElementById('lstPool').options[document.getElementById('lstPool').selectedIndex].value);
	}
	
	sURL = replaceSearchUrlDefaults(sURL);
	
	document.location.href = sURL;

/*
	var f = document.frmPropertySearch;
	
	if(document.getElementById('orderBySizeVisible'))
	{
		f.orderBySize.value = document.getElementById('orderBySizeVisible').options[document.getElementById('orderBySizeVisible').selectedIndex].value;
	}
	
	if(document.getElementById('orderByPriceVisible'))
	{
		f.orderByPrice.value = document.getElementById('orderByPriceVisible').options[document.getElementById('orderByPriceVisible').selectedIndex].value;
	}
	
	f.action = strBaseHref + 'default.cfm/loadindex.65/searchType.'+sType;
	
	f.submit();
*/
}

function replaceSearchUrlDefaults(sURL)
{
	sURL = sURL.replace('{frompanel}', '0');
	sURL = sURL.replace('{orderBySize}', 'ANY');
	sURL = sURL.replace('{orderByPrice}', 'ANY');
	sURL = sURL.replace('{page}', '1');
	sURL = sURL.replace('{lstRegions}', 'all');
	sURL = sURL.replace('{countryID}', '-1');
	sURL = sURL.replace('{squareID}', '-1');
	sURL = sURL.replace('{lstPeople}', 'all');
	sURL = sURL.replace('{lstBeds}', 'all');
	sURL = sURL.replace('{lstDay}', 'any');
	sURL = sURL.replace('{lstMonth}', 'any');
	sURL = sURL.replace('{lstYear}', 'any');
	sURL = sURL.replace('{TypeID}', 'any');
	sURL = sURL.replace('{ThemeID}', 'any');
	sURL = sURL.replace('{lstLocation}', 'all');
	sURL = sURL.replace('{lstPool}', 'all');
	sURL = sURL.replace('{orderType}', 'random');
	sURL = sURL.replace('{partialAvail}', 'NO');
	sURL = sURL.replace('{dailyAvail}', 'NO');
	sURL = sURL.replace('{orderType}', 'random');
	sURL = sURL.replace('{chkNoSmoking}', '0');
	sURL = sURL.replace('{chkChildFac}', '0');
	sURL = sURL.replace('{chkCouples}', '0');
	sURL = sURL.replace('{chkInternetAccess}', '0');
	sURL = sURL.replace('{chkPets}', '0');
	sURL = sURL.replace('{chkMeals}', '0');
	sURL = sURL.replace('{chkCleaning}', '0');
	sURL = sURL.replace('{chkLinen}', '0');
	sURL = sURL.replace('{chkBandB}', '0');
	sURL = sURL.replace('{departmentCode}', '');
	
	return sURL;
}

function clearSearch(){
	var fR = document.frmRefineSearch;
	
	fR.chkChildFac.checked = false;
	fR.chkCouples.checked = false;
	fR.chkPets.checked = false;
	fR.chkMeals.checked = false;
	fR.chkLinen.checked = false;
	fR.chkNoSmoking.checked = false;
	fR.chkCleaning.checked = false;
	fR.chkShortBk.checked = false;
	fR.chkOoS.checked = false;
	fR.chkSpecNeeds.checked = false;
	
	for(i=0; i<fR.chkActivity.length; i++)
	{
		fR.chkActivity[i].checked=false;
	}
	
	submitAjaxQuery();
}

function submitRefineSearch() {
	var fR = document.frmRefineSearch;
	var f = document.frmSearch;
	
	if (fR.chkChildFac.checked==true) { f.chkChildFac.value = 1; } else {f.chkChildFac.value = 0; }
	if (fR.chkCouples.checked==true) { f.chkCouples.value = 1; } else {f.chkCouples.value = 0; }
	if (fR.chkPets.checked==true) { f.chkPets.value = 1; } else {f.chkPets.value = 0; }
	if (fR.chkMeals.checked==true) { f.chkMeals.value = 1; } else {f.chkMeals.value = 0; }
	if (fR.chkCleaning.checked==true) { f.chkCleaning.value = 1; } else {f.chkCleaning.value = 0; }
	if (fR.chkLinen.checked==true) { f.chkLinen.value = 1; } else {f.chkLinen.value = 0; }
	if (fR.chkNoSmoking.checked==true) { f.chkNoSmoking.value = 1; } else {f.chkNoSmoking.value = 0; }
	if (fR.chkBandB.checked==true) { f.chkBandB.value = 1; } else {f.chkBandB.value = 0; }
	if (fR.chkShortBk.checked==true) { f.chkShortBk.value = 1; } else {f.chkShortBk.value = 0; }
	if (fR.chkOoS.checked==true) { f.chkOoS.value = 1; } else {f.chkOoS.value = 0; }
	if (fR.chkSpecNeeds.checked==true) { f.chkSpecNeeds.value = 1; } else {f.chkSpecNeeds.value = 0; }
	if (fR.chkInternetAccess.checked==true) { f.chkInternetAccess.value = 1; } else {f.chkInternetAccess.value = 0; }

	var actString = '';
	for(i=0; i<fR.chkActivity.length; i++)
	{
		if(fR.chkActivity[i].checked==true)
		{
			actString += fR.chkActivity[i].value;
			actString += ',';
		}
	}
	
	f.action = location.href + "/page.1";
	f.page.value = 1;
	f.activityIcons.value = actString;
	f.submit();
}

function SearchByOwnerCode()
{
	if(document.getElementById('txtOwnerCode').value.length>=8)
	{
		location.href = strBaseHref + 'default.cfm/adcode.'+document.getElementById('txtOwnerCode').value
	}
	else
	{
		alert("The reference number is invalid");
	}
}

function SearchSpain()
{
	document.frmSpain.submit();
}

function SearchBandB()
{
	document.frmBandB.submit();
}

function SearchSelfCatering()
{
	document.frmSelfCatering.submit();
}

function AutomateRegionSearch(region)
{
	var f = document.frmSearch;
	f.lstRegions.value = region;
	f.action = strBaseHref + 'default.cfm/searchType.selfcatering/loadindex.65';
	f.submit();
}

function ChangeSearchDiv(RadioOption)
{
	SetVisibility("SpainDiv", false);
	SetVisibility("BandBDiv", false);
	SetVisibility("SelfCateringDiv", false);
	SetVisibility(RadioOption.value+"Div", true);
}

function NavForm(formaction) 
{
	var f = document.frmSearch;
	f.action = formaction;
	f.submit();
}

function navToPage(searchType, orderByPrice, orderBySize, page)
{
	if(document.getElementById('frmSearch'))
	{
		var f = document.getElementById('frmSearch');
		f.searchType.value = searchType;
		f.orderByPrice.value = orderByPrice;
		f.orderBySize.value = orderBySize;
		f.page.value = page;
		
		submitSearchUrl(f);
		
		// f.action = 'default.cfm/searchType.'+searchType+'/page.'+page;

		// if (f.loadindex.value != "") {
		// 	f.action += "/loadindex." + f.loadindex.value;
		// }
		// f.submit();
	}
}

function removeSearchFilter(paramName, paramValue)
{
	var f = document.frmSearch;
	
	if(paramName == 'availability')
	{
		f.lstDay.value = 'any';
		f.lstMonth.value = 'any';
		f.lstYear.value = 'any';
	}
	else if(paramName == 'departmentCode')
	{
		f.departmentCode.value = '';
	}
	else if(paramName == 'lstRegions')
	{
		f.departmentCode.value = '';
		f.lstRegions.value = '';
	}
	else if(paramName == 'countryID')
	{
		f.countryID.value = '';
		f.lstRegions.value = '';
		f.departmentCode.value = '';
	}
	else
	{
		f[paramName].value = paramValue;
	}
	
	f.page.value = 1;
	
	// f.action = 'default.cfm/searchType.'+f.searchType.value+'/page.1';
	// if (f.loadindex.value != "") {
		// f.action += "/loadindex." + f.loadindex.value;
	// }
	
	// f.submit();

	submitSearchUrl(f);
}

function submitSearchUrl(f)
{
	var u = strBaseHref + searchURLTemplate;	
	
	for(i=0; i < f.elements.length; i++)
	{
		if(f.elements[i].value != '')
		{
			u = u.replace('{' + f.elements[i].name + '}', f.elements[i].value);
		}
	}	
	
	u = replaceSearchUrlDefaults(u);
	
	document.location.href = u;
}

var lastShortlistOCode = '';
var shortListPending = false;

function addToShortlist(ownerCode)
{	
	ajax.makeRequest('GET', 'shortlistadd.cfm?shortlistadd='+ownerCode, onShortlistAddResponse);
	lastShortlistOCode = ownerCode;
	shortListPending = true;
	
	self.setTimeout('checkShortListUpdate()', 3000);

	// var f = document.frmSearch;
	// f.action = 'default.cfm/searchType.'+f.searchType.value+'/page.'+f.page.value+'/shortlistadd.'+ownerCode;
	// f.submit();
}

function checkShortListUpdate()
{
	if(shortListPending)
	{
		addToShortlist(lastShortlistOCode);
	}
}

function onShortlistAddResponse()
{
	shortListPending = false;
	
	if(ajax.checkReadyState('shortlistConfirmOCode') == 200) 
	{ 
		document.getElementById('shortlistConfirmOCode').innerHTML = '<strong>'+lastShortlistOCode+'</strong>';
		
		var ScrollTop = 0;

		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
					
		document.getElementById('shortlistConfirm').style.top = ScrollTop + 210;
		document.getElementById('shortlistConfirm').style.visibility = 'visible';
		document.getElementById('shortlistConfirm').style.display = '';
		
		if(document.getElementById('addToShortlistButton'))
		{
			document.getElementById('addToShortlistButton').style.visibility = 'hidden';
			document.getElementById('addToShortlistButton').style.display = 'none';
		}
		
		if(document.getElementById('myShortlistTotal'))
		{
			ajax.makeRequest('GET', 'getshortlisttotal.cfm', onShortlistTotalResponse);
		}
	}
}

function onShortlistTotalResponse()
{
	if(ajax.checkReadyState('myShortlistTotal') == 200) 
	{ 
		var sListTotal = ajax.request.responseText;
		
		if(sListTotal == 1)
		{
			document.getElementById('myShortlistTotal').innerHTML = 'My Shortlist (1 property)';
		}
		else
		{
			document.getElementById('myShortlistTotal').innerHTML = 'My Shortlist (' + sListTotal + ' properties)';
		}
	}
}

function closeShortlistConfirm()
{
	document.getElementById('shortlistConfirm').style.visibility = 'hidden';
	document.getElementById('shortlistConfirm').style.display = 'none';
}

function changeSearchSort()
{
	var f = document.frmSearch;
	
	f.orderBySize.value = document.getElementById('orderBySizeVisible').options[document.getElementById('orderBySizeVisible').selectedIndex].value;
	f.orderByPrice.value = document.getElementById('orderByPriceVisible').options[document.getElementById('orderByPriceVisible').selectedIndex].value;
	f.page.value = '1';
	
	submitSearchUrl(f);
	
	// f.action = 'default.cfm/searchType.'+f.searchType.value+'/page.'+1;
	// if (f.loadindex.value != "") {
	// 	f.action += "/loadindex." + f.loadindex.value;
	// }
	
	// f.submit();
}

function BackToResults()
{
	var f = document.frmSearch;	
	f.action = strBaseHref + 'default.cfm/loadindex.'+f.loadindex.value+'/searchType.'+f.searchType.value+'/orderByPrice.'+f.orderByPrice.value+'/orderBySize.'+f.orderBySize.value+'/page.'+f.page.value;
	f.submit();
}

function SetAjaxContent(id, url, waitContent) {
	ajax.makeRequest('GET', url, function() {SetAjaxContentCallback(id,waitContent);} );	
}

function SetAjaxContentCallback(id, waitContent) {
	if (ajax.checkReadyState(id, waitContent)) {
		var e = document.getElementById(id);
		if (e) {
			e.innerHTML = ajax.request.responseText;
		}
	}
}

function MapViewPort_SetZoomScale(id, mapScaleId) {
	var f = document.getElementById(id).form;
	f.MapViewPort_MapZoomImageId.value = mapScaleId;

	f.action = strBaseHref;
	if (f.action == strBaseHref) {
		f.action += "default.cfm";
	}
	if (f.action.indexOf("#mappos") == -1) {
		f.action += "#mappos";
	}
	f.submit();
}

function RemoveNode(id){var e=document.getElementById(id);e.parentNode.removeChild(e);}

function GalleryPopup_Close(){if (window.name=="galleryimg"){window.close();return false;}return true;}
function ResizeWin(w,h){var x=(screen.width/2)-(w/2);var y=(screen.height/2)-(h/2);window.resizeTo(w,h);window.moveTo(x,y);}

function contact_RefreshForm() 
{
	var f = document.getElementById('emailform');
	f.postback.value = 1;
	f.submit();
}

function contact_ValidateForm(f) {
	var msg = "";

	if (f.lstProps && f.lstProps.listCount > 0) {
		if (f.lstProps.selectedIndex == 0) { msg += "\n* The property you wish to enquire about"; }
	}
	if (f.EnquirerTitle.selectedIndex == 0) { msg += "\n* Your title"; }
	if (trim(f.EnquirerInitial.value) == "") { msg += "\n* Your initial"; }
	if (trim(f.EnquirerSurname.value) == "") { msg += "\n* Your surname"; }
	if (!isEmail(f.EnquirerEmail.value)) { msg += "\n* Your email"; }
	if (!isEmail(f.EnquirerEmailConfirm.value)) { msg += "\n* Confirm email"; }
	if (f.EnquirerEmail.value != f.EnquirerEmailConfirm.value) { msg += "\n* Email addresses must match"; }
	if (trim(f.EnquiryText.value) == "") { msg += "\n* Your enquiry"; }
	if (trim(f.captchatext.value) == "") { msg += "\n* The code in the image"; }

	if (msg == "") {
		return true;
	}
	else {
		alert("Please correct the following fields, and try again:" + msg);
		return false;
	}
}
function SubmitRequestShortlistForm(f) {
	var msg = "";

	if (!isEmail(f.email.value)) {
		msg += "\n* Please enter your email address";
	}

	if (msg == "") {
		f.RequestShortlistForm_Submit.value = "Yes";
		f.submit();
	}
	else {
		alert("Please correct the following error(s), and try again:" + msg);
	}
}
function friend_RefreshForm() {
	var f = document.getElementById('frmFriend');
	f.submit();
}
function SignInDetect(){
	try {
		document.getElementById("browserdetect_browser").value = BrowserDetect.browser;
		document.getElementById("browserdetect_version").value = BrowserDetect.version;
	}
	catch (ex) {}
}

function mainsearch_ShowMap(TagId) {
	var expandStateElement = document.getElementById(TagId + "_ExpandState");
	expandStateElement.value = '1';
	SetVisibility(TagId + "_Intro", false);
	SetAjaxContent(TagId + "_Content","search/mainsearch_Map.cfm","Loading...");
}
function refine_ShowMap(TagId) {
	var expandStateElement = document.getElementById(TagId + "_ExpandState");
	expandStateElement.value = '1';
	SetVisibility(TagId + "_Intro", false);
	SetAjaxContent(TagId + "_Content","search/refinesearch_Map.cfm","Loading...");
}
function ChangeSearchPageSize(size,ac)
{
	if (size != "") {
		var f = document.frmSearch;
		f.page.value = 1;
		f.SearchPageSize.value = size;
		if (ac && ac != "") {f.action = ac;} else {f.action = strBaseHref + 'default.cfm/searchType.'+f.searchType.value+'/orderType.'+f.orderType.value+'/page.'+f.page.value;}
		f.submit();
	}
}
function ChangeFilterRegion(i,ac) {
	var f = document.frmSearch;
	f.page.value = 1;
	f.filterRegionCode.value = i;
	if (ac && ac != "") {f.action = ac;} else {f.action = strBaseHref + 'default.cfm/searchType.'+f.searchType.value+'/orderType.'+f.orderType.value+'/page.'+f.page.value;}
	f.submit();
}
function ChangeFilterDepartment(i,ac) {
	var f = document.frmSearch;
	f.page.value = 1;
	f.filterDepartmentCode.value = i;
	if (ac && ac != "") {f.action = ac;} else {f.action = strBaseHref + 'default.cfm/searchType.'+f.searchType.value+'/orderType.'+f.orderType.value+'/page.'+f.page.value;}
	f.submit();
}
function ChangeFilterSleeps(i,ac) {
	var f = document.frmSearch;
	f.page.value = 1;
	f.filterSleeps.value = i;
	if (i == "" && f.orderType.value != "Random") {f.orderType.value = "Random";}
	if (i != "" && f.orderType.value == "Random") {f.orderType.value = "CapASC";}
	if (ac && ac != "") {f.action = ac;} else {f.action = strBaseHref + 'default.cfm/searchType.'+f.searchType.value+'/orderType.'+f.orderType.value+'/page.'+f.page.value;}
	f.submit();
}
function ChangeFilterActivity(i,ac) {
	var f = document.frmSearch;
	f.page.value = 1;
	f.filterActivity.value = i;
	if (ac && ac != "") {f.action = ac;} else {f.action = strBaseHref + 'default.cfm/searchType.'+f.searchType.value+'/orderType.'+f.orderType.value+'/page.'+f.page.value;}
	f.submit();
}
function ChangeFilterPropertyType(i,ac) {
	var f = document.frmSearch;
	f.page.value = 1;
	f.filterPropertyType.value = i;
	if (ac && ac != "") {f.action = ac;} else {f.action = strBaseHref + 'default.cfm/searchType.'+f.searchType.value+'/orderType.'+f.orderType.value+'/page.'+f.page.value;}
	f.submit();
}
function MapDot_OnMouseOver(text,x,y) {
	if (text != "") {
		try {
			var el = document.getElementById("mapdotTooltip");
			if (el) {
				el.innerHTML = text;
				el.style.marginLeft = x + 20 + "px";
				el.style.marginTop = y + 20 + "px";
				el.className = "MapDotTooltipVisible";
			}
		}
		catch (e) {
			alert(e);
		}
	}
}
function MapDot_OnMouseOut() {
	var el = document.getElementById("mapdotTooltip");
	if (el) {
		el.innerHTML = "";
		el.className = "MapDotTooltipHidden";
	}
}

function updateBanner()
{
	document.getElementById('banneradvertising').innerHTML = bannerArr[aInd];

	aInd++;

	if(aInd > maxInd)
	{
		aInd = 0;
	}

	setTimeout('updateBanner()',30000);
}

function regionSlideShowNext()
{
	stopRegionSlideShow();
	
	regionSlideShowNextAction();
}

function regionSlideShowNextAction()
{
	regionSlideShowPos++;
	if(regionSlideShowPos == regionSlideShowImgs.length)
	{
		regionSlideShowPos = 0;
	}

	document.getElementById('regionSlideShow').src = regionSlideShowImgs[regionSlideShowPos];
	document.getElementById('regionSlideShow').alt = regionSlideShowImgsAlt[regionSlideShowPos];
	document.getElementById('regionSlideShow').title = regionSlideShowImgsAlt[regionSlideShowPos];
}

function regionSlideShowPrevious()
{
	stopRegionSlideShow();
		
	regionSlideShowPos--;
	if(regionSlideShowPos < 0)
	{
		regionSlideShowPos = (regionSlideShowImgs.length - 1);
	}

	document.getElementById('regionSlideShow').src = regionSlideShowImgs[regionSlideShowPos];
	document.getElementById('regionSlideShow').alt = regionSlideShowImgsAlt[regionSlideShowPos];
	document.getElementById('regionSlideShow').title = regionSlideShowImgsAlt[regionSlideShowPos];
}

function stopRegionSlideShow()
{
	playingSlideShow = false;
	window.clearInterval(slideShowIntervalID);	
	
	document.getElementById('regionSummaryPlayButton').style.background =  'url(images/navigation/slideshow_play.gif) no-repeat';
}

function startRegionSlideShow()
{
	if(playingSlideShow)
	{
		stopRegionSlideShow();
	}
	else
	{
		playingSlideShow = true;
		
		document.getElementById('regionSummaryPlayButton').style.background =  'url(images/navigation/slideshow_pause.gif) no-repeat';
		
		
		regionSlideShowNextAction();
		slideShowIntervalID = window.setInterval(regionSlideShowNextAction, 1500);
	}
}

function showRefineSearchSection(itemID)
{
	document.getElementById('refineSearchDiv' + itemID).style.visibility = 'visible';
	document.getElementById('refineSearchDiv' + itemID).style.display = '';
	
	document.getElementById('refineSearchLink' + itemID).style.visibility = 'hidden';
	document.getElementById('refineSearchLink' + itemID).style.display = 'none';
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function toggleReviewSummary()
{
	//var l = document.getElementById('toggleReviewSummaryLink');
	var d = document.getElementById('guestreviewbreakdown');
	
	if(d.style.display == 'none')
	{
		d.style.display = '';
	//	l.innerHTML = '-';
	}
	else
	{
		d.style.display = 'none';
	//	l.innerHTML = '+';
	}
}

function showBFBookingTerms()
{
	ShowPopUpWindow('BookingWin', strBaseHref+'booking.cfm?showterms=1',550,550,'yes','yes','yes');
}

function directBFBooking()
{
	var termsCheck = document.getElementById('chkTermsandConditions');
	
	if(termsCheck.checked)
	{
		ShowPopUpWindow('BookingWin', 'http://www.brittany-ferries.co.uk/index.cfm?articleid=880articleaction=nb&OIFMode=True',805,600,'yes','yes','yes');
	}
	else
	{
		alert('Please confirm your acceptance of the terms and conditions of booking and travel');
	}
}