	function gotoMap()
	{
		var hrefStr = window.location.href;
		if (hrefStr.search('tours.asp') != -1)
		{
			document.form2.gotoMaps.value = 'yes';
			saveVTs();
		}
		else if (hrefStr.search('suggestions.asp') != -1)
		{
			window.location.href = hrefStr.replace('suggestions.asp','maps.asp');
		}
		else if (hrefStr.search('before.asp') != -1)
		{
			window.location.href = hrefStr.replace('before.asp','maps.asp');
		}
		else if (hrefStr.search('maps.asp') != -1)
		{
			document.form2.submit();
		}
	}
	function gotoVT()
	{
		var hrefStr = window.location.href;
		if (hrefStr.search('maps.asp') != -1)
		{
			document.form2.gotoVTs.value = 'yes';
			document.form2.submit();
		}
		else if (hrefStr.search('suggestions.asp') != -1)
		{
			window.location.href = hrefStr.replace('suggestions.asp','tours.asp');
		}
		else if (hrefStr.search('before.asp') != -1)
		{
			window.location.href = hrefStr.replace('before.asp','tours.asp');
		}
		else if (hrefStr.search('tours.asp') != -1)
		{
			saveVTs();
		}
	}
	function gotoHome()
	{
		var currentHref = window.location.href
		
		if (currentHref.search('maps.asp') != -1)
		{
			document.form2.gotoHomepage.value = 'yes';
			document.form2.submit();
		}
		else if (currentHref.search('tours.asp') != -1)
		{
			document.form2.gotoHomepage.value = 'yes';
			saveVTs();
		}
		else if (currentHref.search('suggestions.asp') != -1)
		{
			window.location.href = currentHref.replace('suggestions.asp','index.asp');
		}
		else if (currentHref.search('before.asp') != -1)
		{
			window.location.href = currentHref.replace('before.asp','index.asp');
		}
	}
	function gotoSuggestion()
	{
		var currentHref = window.location.href
		
		if (currentHref.search('maps.asp') != -1)
		{
			document.form2.gotoSuggestions.value = 'yes';
			document.form2.submit();
		}
		else if (currentHref.search('tours.asp') != -1)
		{
			document.form2.gotoSuggestions.value = 'yes';
			saveVTs();
		}
		else if (currentHref.search('before.asp') != -1)
		{
			window.location.href = currentHref.replace('before.asp','suggestions.asp');
		}
	}
	function checkMap(mapid)
		{
			var selMap = eval('document.form2.map' + mapid);
			var selDesc = eval('document.form2.description' + mapid);
			
			if (selMap.checked == true)
			{
				selDesc.disabled = false;
				selDesc.checked = true;
			}
			else
			{
				selDesc.disabled = true;
				selDesc.checked = false;
			}
	}
	function showMap(mapid)
		{
			var settings = 'width=590,height=575,top=5,left=5,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
			var win = window.open('mapPopup.asp?mapid=' + mapid + '&desc=1','vrxmapviewer',settings);
			win.focus();
	}
	function enableOptions()
		{
			if (document.form2.customViewer.checked == true)
			{
				document.form2.logo.disabled = false;
				document.form2.booknow.disabled = false;
				document.form2.bgColors.disabled = false;
				document.form2.textlinks.disabled = false;
				document.form2.banner.disabled = false;
				document.form2.other.disabled = false;
			}
			else
			{
				document.form2.logo.disabled = true;
				document.form2.booknow.disabled = true;
				document.form2.bgColors.disabled = true;
				document.form2.textlinks.disabled = true;
				document.form2.banner.disabled = true;
				document.form2.other.disabled = true;
			}
	}
	//clear options when custom viewer is deselected
	function clearOptions()
	{
		if (document.form2.customViewer.checked == false)
		{
			document.form2.logo.checked = false;
			document.form1.logo.value = 'no';
			document.form2.booknow.checked = false;
			document.form1.booknow.value = 'no';
			document.form2.bgColors.checked = false;
			document.form1.bgColors.value = 'no';
			document.form2.textlinks.checked = false;
			document.form1.textlinks.value = 'no';
			document.form2.banner.checked = false;
			document.form1.banner.value = 'no';
			document.form2.other.checked = false;
			document.form1.other.value = 'no';
		}
	}
	//get VTs based on the map (region) selected
	function getVTs(mapid)
	{
		document.form1.attractionList[0].selectedIndex = true;
		document.form1.searchByMap.value = mapid;
		document.form1.action = 'tours.asp#vts';
		document.form1.submit();
	}
	//record the viewer choice just in case the VT selection changes
	function updateViewerChoice(viewer)
	{
		var sel = eval('document.form2.' + viewer);
		
		if (sel.checked == true)
		{
			document.form1.viewerChoice.value = viewer;
		}
		else
		{
			document.form1.viewerChoice.value = '';
		}
	}	
	//popup for virtual tours	
	function showpano(imageid,showid)
	{
		var settings = 'width=340,height=500,top=5,left=5,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		if (showid)
		{
			var win = window.open('http://www.maxvr.com/buymap/euroviewer.asp?pic=' + imageid + '&show=' + showid,'vrxviewer',settings);
		}
		else
		{
			var win = window.open('http://www.maxvr.com/buymap/euroviewer.asp?pic=' + imageid,'vrxviewer',settings);
		}
		win.focus();
	}
	// custom popup for virtual tours	
	function showcustompano(imageid,showid)
	{
		var settings = 'width=350,height=530,top=5,left=5,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		if (showid)
		{
			var win = window.open('viewer_custom.asp?pic=' + imageid + '&show=' + showid,'vrxcustomviewer',settings);
		}
		else
		{
			var win = window.open('viewer_custom.asp?pic=' + imageid,'vrxcustomviewer',settings);
		}
		win.focus();
	}
	//reminder popup to add maps to their order of virtual tours
	function showpopup(page)
	{
		var height
		if (page == 'vt_pop.asp')
		{
			height = '360'
		}
		else
		{
			height = '300'
		}
		
		var settings = 'width=380,height=' + height + ',top=50,left=50,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		var win = window.open(page,'vrxpopup',settings);
		win.focus();
	}
	
	//only generic viewer or customer viewer can be selected at any given time
	function checkUncheck(box)
	{
		var sel = eval('document.form2.' + box);
		
		if (box == 'customViewer')
		{
			var otherSel = document.form2.genericViewer;
		}
		else
		{
			var otherSel = document.form2.customViewer;
		}
		
		if (sel.checked == true)
		{
			otherSel.checked = false;
		}
		updateViewerChoice(box);
		clearOptions();
	}
	//when search by neighbourhood is selected, the attractionlist is changed to its default value and the list is disabled
	function chgSearchOption()
	{
		if (document.form1.searchOption[0].checked == true)
		{
			document.form1.attractionList.disabled = false;
		}
		else
		{
			document.form1.attractionList[0].selected = true;
			document.form1.attractionList.disabled = true;
		}
	}
	//when an attraction other than the default selection is selected from the attractionList, the form is submitted
	function checkForBlank()
	{
		if (document.form1.attractionList.selectedIndex != '0')
		{
			document.form1.action = 'tours.asp#vts';
			document.form1.submit();
		}
	}
	//when a VT checkbox is checked, the text checkbox is enabled and checked off; otherwise
	//text checkbox is disabled and the checkbox is cleared
	function checkText(imagefileid)
	{
		var sel1 = eval('document.form2.vt' + imagefileid);
		var sel2 = eval('document.form2.text' + imagefileid);
		
		if (sel1.checked == true)
		{
			sel2.disabled = false;
			sel2.checked = true;
			chgSelectedVTList(imagefileid,'add');
			chgSelectedTextList(imagefileid,'add');
		}
		else
		{
			sel2.disabled = true;
			sel2.checked = false;
			chgSelectedVTList(imagefileid,'remove');
			chgSelectedTextList(imagefileid,'remove');
		}
	}
	//add or removes imagefiled for text
	function addRemoveText(imagefileid)
	{
		var sel = eval('document.form2.text' + imagefileid);
		
		if (sel.checked == true)
		{
			chgSelectedTextList(imagefileid,'add');
		}
		else
		{
			chgSelectedTextList(imagefileid,'remove');
		}
	}
	//add or remove VTs from the list of selected VTs
	function chgSelectedVTList(imagefileid,addRemove)
	{
		var VTList
		if (document.form1.selectedVTs.value != '')
		{
			VTList = document.form1.selectedVTs.value;
		}
		else
		{
			VTList = '';
		}
		if ((addRemove == 'add') && (VTList.search(imagefileid) == -1))
		{
			if (document.form1.selectedVTs.value == '')
			{
				document.form1.selectedVTs.value = imagefileid;
			}
			else
			{
				document.form1.selectedVTs.value = VTList + ',' + imagefileid;
			}
		}
		// remove
		else 
		{
			if ((addRemove == 'remove') && (VTList.search(imagefileid) != -1))
			{
				//if the imagefileid is the last or only entry in VTList
				if ((VTList.search(imagefileid) + imagefileid.length - 1) == (VTList.length - 1))
				{
					//if there is only one imagefileid in the list
					if (imagefileid.length == VTList.length)
					{
						document.form1.selectedVTs.value = VTList.replace(imagefileid,'');
					}
					else
					{
						//get rid of imagefileid with the starting comma when the imagefileid is at the end of the list
						document.form1.selectedVTs.value = VTList.replace(',' + imagefileid,'');
					}
				}
				else
				{
					//get rid of imagefileid with the trailing comma
					document.form1.selectedVTs.value = VTList.replace(imagefileid + ',','');
				}
			}
		}
	}
	//add or remove imagefileid from the list of selected text
	function chgSelectedTextList(imagefileid,addRemove)
	{
		var TextList
		if (document.form1.selectedText.value != '')
		{
			TextList = document.form1.selectedText.value;
		}
		else
		{
			TextList = '';
		}
		if ((addRemove == 'add') && (TextList.search(imagefileid) == -1))
		{
			if (document.form1.selectedText.value == '')
			{
				document.form1.selectedText.value = imagefileid;
			}
			else
			{
				document.form1.selectedText.value = TextList + ',' + imagefileid;
			}
		}
		// remove
		else 
		{
			if ((addRemove == 'remove') && (TextList.search(imagefileid) != -1))
			{
				//if the imagefileid is the last or only entry in TextList
				if ((TextList.search(imagefileid) + imagefileid.length - 1) == (TextList.length - 1))
				{
					//if there is only one imagefileid in the list
					if (imagefileid.length == TextList.length)
					{
						document.form1.selectedText.value = TextList.replace(imagefileid,'');
					}
					else
					{
						//get rid of imagefileid with the starting comma when the imagefileid is at the end of the list
						document.form1.selectedText.value = TextList.replace(',' + imagefileid,'');
					}
				}
				else
				{
					//get rid of imagefileid with the trailing comma
					document.form1.selectedText.value = TextList.replace(imagefileid + ',','');
				}
			}
		}
	}
	//when all VTs checkbox is checked, every VT and Text is checked off as well
	function checkVTS(attractionid,imagefilelist)
	{
		var sel1 = eval('document.form2.allVTs' + attractionid);
		var sel2
		var imageArray = imagefilelist.split(',');
		
		if (sel1.checked == true)
		{
			for (var i=0; i<imageArray.length; i++)
			{
				sel2 = eval('document.form2.vt' + imageArray[i]);
				sel2.checked = true;
				chgSelectedVTList(imageArray[i],'add');
				checkText(imageArray[i]);
			}
		}
		else
		{
			for (var j=0; j<imageArray.length; j++)
			{
				sel2 = eval('document.form2.vt' + imageArray[j]);
				sel2.checked = false;
				chgSelectedVTList(imageArray[j],'remove');
				checkText(imageArray[j]);
			}
		}
	}
	//when a checkbox is unchecked, the all VTs checkbox is unchecked as well
	function checkAllVTs(attractionid, imagefileid)
	{
		var sel1 = eval('document.form2.vt' + imagefileid);
		var sel2 = eval('document.form2.text' + imagefileid);
		var sel3 = eval('document.form2.allVTs' + attractionid);
		if ((sel1.checked == false) || (sel2.checked == false))
		{
			sel3.checked = false;
		}
	}
	function saveVTs()
	{
		var hrefStr = window.location.href;
		
		if (hrefStr.search('tours.asp') != -1)
		{
			document.form2.selectedVTs2.value = document.form1.selectedVTs.value;
			document.form2.selectedText2.value = document.form1.selectedText.value;
			document.form2.viewerChoice2.value = document.form1.viewerChoice.value;
			document.form2.logo2.value = document.form1.logo.value;
			document.form2.textlinks2.value = document.form1.textlinks.value;
			document.form2.booknow2.value = document.form1.booknow.value;
			document.form2.banner2.value = document.form1.banner.value;
			document.form2.bgColors2.value = document.form1.bgColors.value;
			document.form2.other2.value = document.form1.other.value;
			document.form2.submit();
		}
	}
	function checkCustomViewer(option)
	{
		var selOption = eval('document.form2.' + option);

		if (selOption.checked == true)
		{
			//check that custom viewer is selected
			if (document.form2.customViewer.checked != true)
			{
				//open warning window
				var settings = 'width=380,height=125,top=100,left=100,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
				var win = window.open('warning.asp?option=' + option,'vrxWarning',settings);
				win.focus();
			}
			else
			{
				var selOption2 = eval('document.form1.' + option);
				selOption2.value = 'yes';
			}
		}
		else
		{
			var selOption2 = eval('document.form1.' + option);
			selOption2.value = 'no';
		}
	}
