
    //Addition of National Booking system windows (2 functions below)
	function bookWindow(bookURL)
	{
		//var retval = window.showModalDialog(bookURL, "", "dialogWidth: 500px; dialogHeight: 690px; center: yes");		
    	InfoWindow =window.open(bookURL, 'info_window', "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=800,height=450,left=0,top=0" );
		InfoWindow.focus();
	}

	function directBookWindow(bookURL)
	{
    	dBWindow =window.open(bookURL, 'Direct_Book_Window', "copyhistory=0,width=800,height=800,left=0,top=0,scrollbars=1,resizable=1,menubar=1,location=1,toolbar=1" );
		dBWindow.focus();
	}



	function zoomToPoint(x, y)
	{
		document.mapForm.pointX.value = x;
		document.mapForm.pointY.value = y;
		document.mapForm.submit();
	}
	
	
	function backToList()
	{
		document.mapForm.pageMode.value=document.mapForm.searchCategory.value ; //'Restore the previous search category
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
		document.mapForm.SortClause.value='';	//Set initial sort clause Charlie Su 14-01-05 to set initial sort 
		document.mapForm.submit();
	}

	function backToPreviousList()
	{
		document.mapForm.setExtents.value="LIST_SET" ;
		backToList();
	}


	function ClickHeading(sort) //Add by Charlie Su 14-01-05 Sort on headings
	{
		document.mapForm.SortClause.value=sort;	//Set sort clause		
		document.mapForm.submit();
	}
	

	function onZoomBox(left, top, right, bottom)
	{   document.mapForm.map_x.value = left;
		document.mapForm.map_y.value = top;
		document.mapForm.map_x2.value = right;
		document.mapForm.map_y2.value = bottom;
		document.mapForm.pageAction.value = "MAPCLICK";	
		showWaitCursor()	
		document.mapForm.submit();
	} 
	
	function showWaitCursor()
	{
        if (isNav) return;
	    document.mapForm.mapImage.style.cursor = "wait";	  	    
        document.styleSheets[0].rules[0].style.cursor = "wait";
	}
   
	function onZoomXY(x, y)
	{	  	      
	    if (document.mapForm.skipMapClick.value == 'NO')
	    {
		    document.mapForm.map_x.value = x;
		    document.mapForm.map_y.value = y;
		    document.mapForm.map_x2.value = 0; //Only a Point was clicked
		    document.mapForm.map_y2.value = 0;
		    document.mapForm.pageAction.value = "MAPCLICK";
		    showWaitCursor();
		    document.mapForm.submit();
		}
	}
	
	function openinfo(mysite) 
	{
		//InfoWindow =window.open(mysite, ident+"PK", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=,height=,left=50,top=20" );
		InfoWindow =window.open(mysite, 'info_window', "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=790,height=600,left=50,top=20" );
		InfoWindow.focus();
	}

	function openPrint(mysite) 
	{
		InfoWindow =window.open(mysite, 'print_window', "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=700,height=600,left=50,top=20" );
		InfoWindow.focus();
	}
	
	function revRoute() 
	{
		document.mapForm.reverseRoute.value=1
		document.mapForm.submit();
	}
	function entRoute() 
	{
		document.mapForm.entireRoute.value=1
		document.mapForm.submit();
	}
	function chgZoom() 
	{
		document.mapForm.zoomButton.value=1
		document.mapForm.submit();
	}

	function filterSelection(sSubcat,sFilterLevel) 
	{
		document.mapForm.searchSubCategoryLevel.value=sFilterLevel;
		document.mapForm.searchSubCategory.value=sSubcat;
		document.mapForm.submit();
	}	
	
	
	function showDetailPopup(locURL,ident)
	{
		detailInfoWindow =window.open(locURL, ident, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=740,height=520,left=50,top=20" );
		detailInfoWindow.focus();
	}

	function showDetailInfo(locURL,ident,x,y,sFeatureName,sFeatureType)
	{
		document.mapForm.showFeature.value = sFeatureName;
		document.mapForm.featureType.value = sFeatureType;
		document.mapForm.featureIdent.value = ident;
	    document.mapForm.fPointX.value = x;
		document.mapForm.fPointY.value = y;
		document.mapForm.subPage.value = locURL;
		document.mapForm.pageAction.value='BAR_CLICK';
		document.mapForm.pageMode.value='INFODETAILS';
		zoomToPoint(x, y); //submits the page
	}

    // If LEGID is 0 the system converts all the legs 
	function makeTDMyRoute(TDID,LEGID)
	{	    
        if(confirm('This allows you to open the tourist drive \nroute component AS your standard route\n\n\t Continue ...'))    
        {
		    document.mapForm.touristDriveLEGIdent.value = LEGID;
		    document.mapForm.touristDriveIdent.value = TDID;
		    document.mapForm.pageAction.value='TDRIVE_TO_ROUTE';
		    document.mapForm.submit();
		}
	}

    // If LEGID is 0 the system converts all the legs 
	function addTDToRoute(TDID,LEGID)
	{	    
        if(confirm('This allows you to ADD the tourist drive \nroute component to your standard route\n\n\t Continue ...'))    
        {
		    document.mapForm.touristDriveLEGIdent.value = LEGID;
		    document.mapForm.touristDriveIdent.value = TDID;
		    document.mapForm.pageAction.value='ADDTDRIVE_TO_ROUTE';
		    document.mapForm.submit();
		}
	}
	
	function showTouristDriveInfo(TDID)
	{
		document.mapForm.showTouristDrive.value = 'Show Drive';
		document.mapForm.touristDriveIdent.value = TDID;
		document.mapForm.pageAction.value='BAR_CLICK';
		document.mapForm.pageMode.value='TDRIVEDETAILS';
		document.mapForm.submit();
	}


	function showTDLegInfo(TDLegID)
	{
		document.mapForm.showTouristDriveLEG.value = 'Show Leg';
		document.mapForm.touristDriveLEGIdent.value = TDLegID;
		document.mapForm.pageAction.value='BAR_CLICK';
		document.mapForm.pageMode.value='TDRIVELEGDETAILS';
		document.mapForm.submit();
	}


function goSimpleMap()
{
    //Clear any search categories
    document.mapForm.searchCategory.value = ''; 
    document.mapForm.searchSubCategory.value = '';

    //Update active from simple
    document.mapForm.fromTown.value = document.mapForm.simpleFromTown.value;
    document.mapForm.toTown.value = document.mapForm.simpleToTown.value;
	if ( (document.mapForm.fromTown.value != "") && (document.mapForm.toTown.value != "" ) )
	{
		document.mapForm.pageAction.value="BUILDROUTE" 
		document.mapForm.submit();
	}	
	else
		alert('Please enter a value for the FROM and TO destination fields');
}

function goMap()
{
    //Clear any search categories
    document.mapForm.searchCategory.value = ''; 
    document.mapForm.searchSubCategory.value = '';
    //Update active from advanced
    document.mapForm.fromTown.value = document.mapForm.advancedFromTown.value;
    document.mapForm.toTown.value = document.mapForm.advancedToTown.value;
        
	if ((document.mapForm.fromTown.value != "")&& (document.mapForm.toTown.value != "" ) )
	{
		document.mapForm.pageAction.value="BUILDROUTE" 
		document.mapForm.submit();
	}	
	else
		alert('Please enter a value for the FROM and TO destination fields');
}



	function showTutorial()
	{
		tutorialWindow = window.open("", "Legend", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=650,height=300");
		tutorialWindow.window.document.open();
		tutorialWindow.window.document.write("<HTML><HEAD><TITLE>RACQ Tutorial</TITLE></HEAD><BODY BGCOLOR=#ffffff><P><IMG SRC='tutorial/images/MapLegend.png' ></P></BODY></HTML>");
		tutorialWindow.window.document.close();tutorialWindow.focus();
	}


function inputImgOn(oCtrl){oCtrl.src = eval(oCtrl.value + "On.src");}
function inputImgOff(oCtrl){oCtrl.src = eval(oCtrl.value + "Off.src");}
function imgOn(oImg){oImg.src = eval(oImg.name + "On.src");}
function imgOff(oImg){oImg.src = eval(oImg.name + "Off.src");}


    function nonCurrImgOff(oImg,sGroupName)
    {
			switch(sGroupName)
  			{
    		case "mapTools":
				if (document.mapForm.lastSet.value != oImg.name)
                    imgOff(oImg);
				break;
			case "zoomSlider":
				if (document.mapForm.lastSet.value != oImg.name)
                    imgOff(oImg);
				break;
			}
    }


	function setButtonsOff()
	{
	    if (document.mapForm.pageOrg.value == 'RAC')
	    {
            document.getElementById('zoom-in').style.backgroundImage = "url(images/travel/map/RAC/tools_zoom_In.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/travel/map/RAC/tools_zoom_Out.gif)";
        }
	    else if (document.mapForm.pageOrg.value == 'RAA')
	    {
            document.getElementById('zoom-in').style.backgroundImage = "url(images/travel/map/RAA/tools_zoom_In.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/travel/map/RAA/tools_zoom_Out.gif)";
        }
	    else if (document.mapForm.pageOrg.value == 'RACT')
	    {
            document.getElementById('zoom-in').style.backgroundImage = "url(images/travel/map/RACT/tools_zoom_In.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/travel/map/RACT/tools_zoom_Out.gif)";
        }
 	    else if (document.mapForm.pageOrg.value == 'AANT')
	    {
            document.getElementById('zoom-in').style.backgroundImage = "url(images/travel/map/AANT/tools_zoom_In.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/travel/map/AANT/tools_zoom_Out.gif)";
        }
 	    else if (document.mapForm.pageOrg.value == 'NRMA')
	    {
            document.getElementById('zoom-in').style.backgroundImage = "url(images/travel/map/NRMA/tools_zoom_In.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/travel/map/NRMA/tools_zoom_Out.gif)";
        }
        else
        {
            document.getElementById('zoom-in').style.backgroundImage = "url(images/travel/map/tools_zoom_In.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/travel/map/tools_zoom_Out.gif)";
        }
  	}
    function setOrigView(oImg)
	{
			zoomBoxOn=false;
	}  	
    
    function setDistCalc(oImg)
	{
			setButtonsOff();
			imgOn(oImg)
			_changeTo='crosshair';
			document.mapForm.lastSet.value = oImg.name;
			zoomBoxOn=false;
	}
	
    function setModeReCenter(oImg)
	{
			setButtonsOff();
			imgOn(oImg)
			document.mapForm.mapClickMode.value ='3';
			document.mapForm.lastSet.value = oImg.name;
			zoomBoxOn=false;
	}
  	function setModeRectZoom(oImg)
    	{
			setButtonsOff();
			//Set image on
    	    if (document.mapForm.pageOrg.value == 'RAC')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/RAC/tools_zoom_inOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'RAA')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/RAA/tools_zoom_inOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'RACT')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/RACT/tools_zoom_inOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'AANT')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/AANT/tools_zoom_inOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'NRMA')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/NRMA/tools_zoom_inOn.gif)";
            else    
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/tools_zoom_inOn.gif)";
			document.mapForm.mapClickMode.value ='9';
			zoomBoxOn=true;
	}
	
	function initialiseTools()
	{   
	    alert('Initialise Tools');
	    if (document.mapForm.mapClickMode.value =='9') 
	    {
    	    if (document.mapForm.pageOrg.value == 'RAC')
                document.getElementById("zoom-in").style.backgroundImage = "url(images/travel/map/RAC/tools_zoom_inOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'RAA')
                document.getElementById("zoom-in").style.backgroundImage = "url(images/travel/map/RAA/tools_zoom_inOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'RACT')
                document.getElementById("zoom-in").style.backgroundImage = "url(images/travel/map/RACT/tools_zoom_inOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'AANT')
                document.getElementById("zoom-in").style.backgroundImage = "url(images/travel/map/AANT/tools_zoom_inOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'NRMA')
                document.getElementById("zoom-in").style.backgroundImage = "url(images/travel/map/NRMA/tools_zoom_inOn.gif)"
            else
                document.getElementById("zoom-in").style.backgroundImage = "url(images/travel/map/tools_zoom_inOn.gif)"
        }        
	    if (document.mapForm.mapClickMode.value =='10') 
	    {
    	    if (document.mapForm.pageOrg.value == 'RAC')
                document.getElementById("zoom-out").style.backgroundImage = "url(images/travel/map/RAC/tools_zoom_outOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'RAA')
                document.getElementById("zoom-out").style.backgroundImage = "url(images/travel/map/RAA/tools_zoom_outOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'RACT')
                document.getElementById("zoom-out").style.backgroundImage = "url(images/travel/map/RACT/tools_zoom_outOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'AANT')
                document.getElementById("zoom-out").style.backgroundImage = "url(images/travel/map/AANT/tools_zoom_outOn.gif)"
    	    else if (document.mapForm.pageOrg.value == 'NRMA')
                document.getElementById("zoom-out").style.backgroundImage = "url(images/travel/map/NRMA/tools_zoom_outOn.gif)"
            else
                document.getElementById("zoom-out").style.backgroundImage = "url(images/travel/map/tools_zoom_outOn.gif)"
        }    
	    zoomBoxOn = ((document.mapForm.mapClickMode.value =='9') || (document.mapForm.mapClickMode.value =='10'));	
	}
	
  	function setModeRectZoomOut(oImg)
    	{
			setButtonsOff();
    	    if (document.mapForm.pageOrg.value == 'RAC')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/RAC/tools_zoom_outOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'RAA')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/RAA/tools_zoom_outOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'RACT')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/RACT/tools_zoom_outOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'AANT')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/AANT/tools_zoom_outOn.gif)";
    	    else if (document.mapForm.pageOrg.value == 'NRMA')
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/NRMA/tools_zoom_outOn.gif)";
            else
                document.getElementById(oImg.id).style.backgroundImage = "url(images/travel/map/tools_zoom_outOn.gif)";

			document.mapForm.mapClickMode.value ='10';
			zoomBoxOn=true;
	}



		function setMapClickMode()
	{
		var clickVal=document.mapForm.mapClickMode.value;
		if (clickVal != '')
    	{
			switch(clickVal)
  			{
    		case "1":
				//setModePlus(document.plusZoom);
				break
			case "2":
				//setModeMinus(document.minusZoom);
				break
			case "3":
				setModeReCenter(document.recent);
				break
			case "5":
				//setModeInfo();
				break
			case "9":
				setModeRectZoom(document.rectZoom);
				break
			}
		}	
		else	
			setModePlus();
	}

 function hide ( name ) 
 {
	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;        
	if (W3C) {
		document.getElementById(name).style.visibility = "hidden";
	} else if (NS4) {
		document.layers[name].visibility = "hidden";
	} else {
		document.all[name].style.visibility = "hidden";
	}
}

 function isVisible ( name ) 
 {
	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;        
	if (W3C) {
		return(document.getElementById(name).style.visibility != "hidden");
	} else if (NS4) {
		return(document.layers[name].visibility != "hidden");
	} else {
		return(document.all[name].style.visibility != "hidden");
	}
}

function show (name ) 
{
	var ele;                //points to the popup element

	NS4 = (document.layers) ? 1 : 0;
	IE4 = (document.all) ? 1 : 0;
	W3C = (document.getElementById) ? 1 : 0;

	if ( W3C ) {
		ele = document.getElementById(name);
	} else if ( NS4 ) {
		ele = document.layers[name];
	} else {        // meant for IE4
		ele = window.opener.document.all[name];
	}

	if ( NS4 ) {
		ele.visibility = "show";
	} else {  // IE4 & W3C
		ele.style.visibility = "visible";
	}
}

    var _changeTo="crosshair"
    
    function mapCursorOn()
    {
    document.styleSheets[0].rules[0].style.cursor=_changeTo;
    }

    function printTouristDrive(tDID,legID,sClub,sMapImage)
    {
    var  printURL='DrivePrint.aspx?TDID=' + tDID + '&LEGID=' + legID + '&CLUB=' + sClub + '&IMGNAME=' + sMapImage
        //alert(printURL);
		tDrivePrintWin = window.open(printURL, "TDPrint", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=800,height=450,left=0,top=0");
		tDrivePrintWin.focus();
    }

    function showPhotoGallery(tDID,legID,clubID)
    {
    var  galleryURL='DriveGallery.aspx?TDID=' + tDID + '&LEGID=' + legID + '&CLUB=' + clubID
		tDriveGalleryWin = window.open(galleryURL, "TDPrint", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=800,height=600,left=0,top=0");
		tDriveGalleryWin.focus();
    }

	function mapCursorOff()
	{
	  document.styleSheets[0].rules[0].style.cursor='default';
	}


     function clearRouteInput()
    {
	    document.mapForm.fromTown.value = '';
	    document.mapForm.toTown.value = '';
	    document.mapForm.simpleFromTown.value = '';
	    document.mapForm.simpleToTown.value = '';
	    document.mapForm.pageAction.value = 'CLEARROUTE'; //Added for server based clear
	    document.mapForm.submit(); //Added for server based clear
	}    
	
	
	function clearAdvancedDriveSearch()
    {
	    document.mapForm.searchAdvDriveCategory.value='';
  	    document.mapForm.TDTourLength1.checked = 0;
  	    document.mapForm.TDTourLength2.checked = 0;
  	    document.mapForm.TDTourLength3.checked = 0;
  	    document.mapForm.TDTourLength4.checked = 0;
  	    document.mapForm.TDTourLength5.checked = 0;
  	    document.mapForm.TDTourLength6.checked = 0;
        document.mapForm.TDTypeFOODANDWINE.checked = 0;
        document.mapForm.TDTypeINDIGENOUS.checked = 0;
        document.mapForm.TDTypeAGRICULTURE.checked = 0; 
        document.mapForm.TDTypeARCHITECTURE.checked = 0; 
        document.mapForm.TDTypeENVIRONMENTAL.checked = 0; 
        document.mapForm.TDTypeHISTORY.checked = 0;
        document.mapForm.TDType4WD.checked = 0; 
	    document.mapForm.submit();
    }

	
    
    function clearAdvancedSearch(type)
    {
    
	    document.mapForm.searchAdvCategory.value='';
	    if (type == 'PlacesToStay') {
  	    document.mapForm.ApartmentsHolidayUnits.checked = 0;
	    document.mapForm.BackpackerHostels.checked = 0;
	    document.mapForm.BedBreakfastGuestHouse.checked = 0;
	    document.mapForm.CottagesCabinsHouses.checked = 0;
	    document.mapForm.HotelsMotelsApartmentHotels.checked = 0;
	    document.mapForm.HouseboatsCruisers.checked = 0;
	    document.mapForm.TouristParksCampingAreas.checked = 0;
	    document.mapForm.Barbeque.checked = 0;
	    document.mapForm.CableTV.checked = 0;                            
	    document.mapForm.ConferenceFacilities.checked = 0;
	    document.mapForm.Cooling.checked = 0;
	    document.mapForm.DisabledAccess.checked = 0;
	    document.mapForm.PetsAllowed.checked = 0;
	    document.mapForm.inHouseMovies.checked = 0;
	    document.mapForm.nonSmoking.checked = 0;
	    document.mapForm.Restaurant.checked = 0;
	    document.mapForm.SwimmingPool.checked = 0;
	    document.mapForm.CookingFacilities.checked = 0;
	    document.mapForm.Cots.checked = 0;
	    document.mapForm.OpenFireplace.checked = 0;
	    document.mapForm.Playground.checked = 0;
	    document.mapForm.Spa.checked = 0;
	    document.mapForm.Video.checked = 0;
	    document.mapForm.fiveStar.checked = 0;
	    document.mapForm.fourStar.checked = 0;
	    document.mapForm.threeStar.checked = 0;
	    document.mapForm.twoStar.checked = 0;
	    document.mapForm.goldenChain.checked = 0;
	    document.mapForm.Big4HolidayPark.checked = 0;
	    document.mapForm.budgetMotel.checked = 0;
	    document.mapForm.Comfort.checked = 0;
	    document.mapForm.quality.checked = 0;
	    document.mapForm.clarion.checked = 0;
	    document.mapForm.bestWestern.checked = 0;
	    document.mapForm.TopTouristPark.checked = 0;
	    }
	    if (type == 'ThingsToSee') {
	    //Things To See part
	    document.mapForm.historyArtsCulture.checked = 0;
        document.mapForm.natureParksGardens.checked = 0;
	    document.mapForm.tours.checked = 0;
	    document.mapForm.activities.checked = 0;                           
	    document.mapForm.entertainmentThemeParks.checked = 0;
	    document.mapForm.foodWineRelaxation.checked = 0;
	    }
	    
	    document.mapForm.SortClause.value='';
	    document.mapForm.submit();
	}
	
    function setAdvancedSearch()
    {
        document.mapForm.SortClause.value='';
        document.mapForm.searchAdvCategory.value='ON';
        backToList(); //Requirement is to go directly to list after advanced search - replace with submit() to return to previous system
	}
	
    function setAdvancedDriveSearch()
    {
        document.mapForm.SortClause.value='';
        document.mapForm.searchAdvDriveCategory.value='ON';
        backToList(); //Requirement is to go directly to list after advanced search - replace with submit() to return to previous system
	}

    function findtown()
    {
        var catStr = document.mapForm.searchCategory.value;
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.pageMode.value=catStr.toUpperCase()
        zoomToTown(document.mapForm.townName2.value,'');    
    }
	
    function findTownMain()
    {
        var catStr = document.mapForm.searchCategory.value;
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.pageMode.value=catStr.toUpperCase()
        zoomToTown(document.mapForm.find.value,'');    
    }
	

	function showLegend()
	{
		LegendWindow = window.open("", "Legend", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=360,height=400");
		LegendWindow.window.document.open();
		LegendWindow.window.document.write("<HTML><HEAD><TITLE>Map Legend</TITLE></HEAD><BODY BGCOLOR=#ffffff><P><IMG SRC='/lic/MapLegend.gif' ></P></BODY></HTML>");
		LegendWindow.window.document.close();LegendWindow.focus();
	}

	
	function zoomToTown(sTownName, sTownState, sTownPCode)
	{
		//To stop the literal "undefined" from being used in locating towns
		if (sTownState == null) 
		    sTownState='';
		if (sTownPCode == null)
		    sTownPCode='';
		document.mapForm.showTown.value = 'NEW';
		document.mapForm.townName.value = sTownName;
		document.mapForm.townState.value = sTownState;
		document.mapForm.townPCode.value = sTownPCode;
		document.mapForm.submit();
	}

	function addToRoute(sAddLabel, sXCoord, sYCoord, iPointNbr)
	{
		document.mapForm.pageAction.value = 'REBUILDROUTE';
		document.mapForm.addRLabel.value = sAddLabel; 
		document.mapForm.addRXcoord.value = sXCoord;
		document.mapForm.addRYcoord.value = sYCoord;
		document.mapForm.addRNbr.value = iPointNbr;
		document.mapForm.submit();
	}
	

	function centerFeature(x,y,sFeatureName)
	{
		document.mapForm.showFeature.value = sFeatureName;
		zoomToPoint(x, y);
	}

    function goForward()
	{
		history.forward();
  	}
    function goBack()
	{
			history.go(-1);
	}
	
			
	
function getRealLeft(imgElem)
{
 xPos = eval(imgElem).offsetLeft;
 tempEl = eval(imgElem).offsetParent;
 while (tempEl != null)
 {
   xPos += tempEl.offsetLeft;
   tempEl = tempEl.offsetParent;
 }
 return xPos;
}
 
function getRealTop(imgElem)
{
 yPos = eval(imgElem).offsetTop;
 tempEl = eval(imgElem).offsetParent;
 while (tempEl != null)
 {
   yPos += tempEl.offsetTop;
   tempEl = tempEl.offsetParent;
 }
 return yPos;
}
 
function ImagePageX(imageElement)
{
 if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null)
 {
   return getRealLeft(imageElement);
 }
 if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null)
 {
 return imageElement.x;
 }
}
 

function ImagePageY(imageElement)
{
 if (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null)
 {
   return getRealTop(imageElement);
 }
 if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null)
 {
 return imageElement.y;
 }
}