
    //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();
		//*** Uncomment to open in the system Iframe *** (PA)
		//document.mapForm.subPage.value = bookURL;
		//document.mapForm.pageAction.value='BAR_CLICK';
		//document.mapForm.pageMode.value='INFODETAILS';
		//document.mapForm.submit();
	}

	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) //Map has been clicked but no box has been drawn
	{	  	      
	    if (document.mapForm.skipMapClick.value == 'NO')
	    {
            var sURL = document.mapForm.mouseOverURL.value;
            var featX = Number(document.mapForm.mouseOverX.value);
            var featY = Number(document.mapForm.mouseOverY.value);
            var radius = Number(document.mapForm.mouseOverRadius.value);
            if (sURL!='') //click on a feature submit for feature action
            {
                if ((x > featX - radius)&&(x < featX + radius) && (y > featY - radius)&&(y < featY + radius))
                {
                    //alert('Show Feature')
		            var ident = document.mapForm.mouseFeatureIdent.value;
		            var sFeatureName = document.mapForm.mouseFeature.value;
		            var sFeatureType = document.mapForm.mouseFeatureType.value;
	                var longitude = document.mapForm.mouseFPointX.value;
		            var latitude = document.mapForm.mouseFPointY.value;
	                showDetailInfo(sURL,ident,longitude,latitude,sFeatureName,sFeatureType)
                    return; //Exits the function if this action is taken
                }    
            }                
            //alert('Normal Zoom')
		    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();
		}
	}
	
	//sets page variables for the last mouse-Overed feature
	function setMouseOverVars(sURL,X,Y,radius,ident,longitude,latitude,sFeatureName,sFeatureType) 
	{
        document.mapForm.mouseOverURL.value = sURL;
        document.mapForm.mouseOverX.value = X;
        document.mapForm.mouseOverY.value = Y;
        document.mapForm.mouseOverRadius.value = radius;
		document.mapForm.mouseFeatureIdent.value = ident;
		document.mapForm.mouseFeature.value = sFeatureName;
		document.mapForm.mouseFeatureType.value = sFeatureType;
	    document.mapForm.mouseFPointX.value = longitude;
		document.mapForm.mouseFPointY.value = latitude;
	}
	
	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.pageMode.value = PM;
		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();
	}

    // adds a via to the advanced routing system (application.inc controls the max vias)
	function addVia()
	{	    
		document.mapForm.pageAction.value='ADD_VIAS'; //Need to preserve content of controls
        document.mapForm.pViaCount.value = 5
        //document.mapForm.pViaCount.value = Number(document.mapForm.pViaCount.value) + 1
		document.mapForm.submit();
	}

function pageDefault()
{
 ;//Does nothing   
}    

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.fromState.value = document.mapForm.simpleFromState.value; //added for Revamp
    document.mapForm.toTown.value = document.mapForm.simpleToTown.value;
    document.mapForm.toState.value = document.mapForm.simpleToState.value; //added for Revamp
	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 viewMap()
	{
	    document.mapForm.searchScope.value="MAP"
		document.mapForm.pageAction.value="VIEWMAP" 
		document.mapForm.submit();
	}


function findProd() {
        var catStr = document.mapForm.searchCategory.value;
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.searchScope.value='MAP';  //Force a search in the map  
        document.mapForm.pageMode.value=catStr.toUpperCase();
        document.mapForm.searchAdvCategory.value = 'ON';
		document.mapForm.submit();
}


function goMap()
{
    
    //Clear any search categories
    document.mapForm.searchCategory.value = ''; 
    document.mapForm.searchSubCategory.value = '';
    //Update active from advanced
    
    document.mapForm.fromTown.value = document.mapForm.advancedFromTownTop.value;
    document.mapForm.fromState.value = document.mapForm.advancedFromStateTop.value; //added for Revamp
    document.mapForm.toTown.value = document.mapForm.advancedToTownTop.value;
    document.mapForm.toState.value = document.mapForm.advancedToStateTop.value; //added for Revamp
    
	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()
	{
            CLUBURL = clubswitch()
            document.getElementById('zoom-in').style.backgroundImage = "url(images/clubs/"+ CLUBURL +"/buttons/zoom_plus.gif)";
            document.getElementById('zoom-out').style.backgroundImage = "url(images/clubs/"+ CLUBURL +"/buttons/zoom_minus.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 returns set in url RACQ||NRMA||RACT||RAA||RAC||AANT||TW ...Default: RACQ
	function clubswitch()
	{        
      if (document.mapForm.pageOrg.value == '')
      {
           document.mapForm.pageOrg.value = "RACQ" //sets default pageorg to racq
           return document.mapForm.pageOrg.value
      }
      else
          return document.mapForm.pageOrg.value
	}
	
	
  	function setModeRectZoom(oImg)
    	{
    	   // document.mapForm.pageMode.value = PM;
			setButtonsOff();
			//Set image on

            CLUBURL = clubswitch()
            document.getElementById(oImg.id).style.backgroundImage = "url(images/clubs/"+ CLUBURL +"/buttons/zoom_plus_in.gif)";
		    document.mapForm.mapClickMode.value ='9';
			zoomBoxOn=true;
	}
	
	function initialiseTools()
	{   
	
	    if (document.mapForm.mapClickMode.value =='9') 
	    {
                CLUBURL = clubswitch()           
                document.getElementById("zoom-in").style.backgroundImage = "url(images/clubs/"+ CLUBURL +"/buttons/zoom_plus_in.gif)"
        }
               
	    if (document.mapForm.mapClickMode.value =='10') 
	    {
	    	    CLUBURL = clubswitch()
                document.getElementById("zoom-out").style.backgroundImage = "url(images/clubs/"+ CLUBURL +"/buttons/zoom_minus_in.gif)"
        }    
	    zoomBoxOn = ((document.mapForm.mapClickMode.value =='9') || (document.mapForm.mapClickMode.value =='10'));	
	    
//	   Initialises map border navigation images - Added SA -190106
//	    CLUBURL = clubswitch()  
//        document.getElementById("ne").src = "images/clubs/"+ CLUBURL +"/borders/border_ne.gif";
//        document.getElementById("se").src = "images/clubs/"+ CLUBURL +"/borders/border_se.gif";
//        document.getElementById("e").src = "images/clubs/"+ CLUBURL +"/borders/border_e.gif";
//        document.getElementById("s").src = "images/clubs/"+ CLUBURL +"/borders/border_s.gif";
//        document.getElementById("sw").src = "images/clubs/"+ CLUBURL +"/borders/border_sw.gif";
//        document.getElementById("w").src = "images/clubs/"+ CLUBURL +"/borders/border_w.gif";
//        document.getElementById("nw").src = "images/clubs/"+ CLUBURL +"/borders/border_nw.gif";
//        document.getElementById("n").src = "images/clubs/"+ CLUBURL +"/borders/border_n.gif"; */
	    
	     if ((document.mapForm.prevPageMode.value = 'PLACESTOSTAY') && (document.mapForm.pageMode.value = 'INFODETAILS'))
	         {
              resetSubPage()  
	       }
	   }
	
  	function setModeRectZoomOut(oImg)
    	{
    	    //document.mapForm.pageMode.value = PM;
			setButtonsOff();
            CLUBURL = clubswitch()                    
            document.getElementById(oImg.id).style.backgroundImage = "url(images/clubs/"+ CLUBURL +"/buttons/zoom_minus_in.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.FromStreet.value = '';
	    document.mapForm.ToStreet.value = '';
        //document.mapForm.searchCategory.value = 'PLACESTOSTAY' ;
	    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; 
	    setAdvancedDriveSearch(); //Rerun search after resetting the controls
    }

	
    
    function clearAdvancedSearch(type)
    {
		document.mapForm.pageAction.value='CLEAR_ADVANCED_SEARCH';
	    document.mapForm.submit();
	}
	
    function setAdvancedSearch()
    
    {
    
       try{
        if (document.mapForm.findTownAccom.value == '') {
            document.mapForm.propertyNameFilter.value = '';
        }
        }
        catch(e){
         document.mapForm.propertyNameFilter.value = '';
        }
        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(sTown,sState)
    {   
      if (sTown=='')
       {
        alert('Please enter a value to Find A Town') 
       } else {
        var catStr = document.mapForm.searchCategory.value;
        if (catStr == '') 
        {
            catStr = 'TOWNINFO'; //force a mode to show lower menu bar
            document.mapForm.searchCategory.value = catStr;
        }    
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.searchScope.value='MAP';  //Force a search in the map  
        document.mapForm.pageMode.value=catStr.toUpperCase()
        zoomToTown(sTown,sState,'');    
        }
    }
    
    
    function findAttrTown(sAttrTown,sState)
    {
        var catStr = document.mapForm.searchCategory.value;
        if (document.mapForm.findTownAccom.value == '') {
        document.mapForm.propertyNameFilter.value = '';}
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button click
        document.mapForm.searchScope.value='MAP';  //Force to search the map  
        document.mapForm.pageMode.value=catStr.toUpperCase()
		document.mapForm.showAttrTown.value = 'NEW';//Test Attractions before finding and zooming to town
		document.mapForm.townName.value = sAttrTown;
		document.mapForm.townState.value = sState;
		document.mapForm.townPCode.value = '';
		document.mapForm.submit();
	}

    
    function menuFindTown(sTown,sState)
    {
      if (sTown=='')
       {
        alert('Please enter a value to Find A Town') 
       } else {
        var catStr = document.mapForm.searchCategory.value;
        if (catStr == '') 
        {
            catStr = 'TOWNINFO'; //force a mode to show lower menu bar
            document.mapForm.searchCategory.value = catStr;
        }    
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.searchScope.value='MAP';  //Force a search in the map  
        document.mapForm.pageMode.value=catStr.toUpperCase()
        zoomToTown(sTown,sState,'');    
        }
    }
    
    
        
    function findProduct(sProperty)
    {
        //alert('Find ' + sProperty) 
        var catStr = document.mapForm.searchCategory.value;
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.searchScope.value='MAP';  //Force a search in the map  
        document.mapForm.pageMode.value=catStr.toUpperCase();
        document.mapForm.propertyNameFilter.value = sProperty;
        document.mapForm.searchAdvCategory.value = 'ON';
		document.mapForm.submit();
    }
    
    
    
    
    function displayProductByName(productName)
    {
        alert('displayProductByName ' + productName)        
    }
    
    
    function findAttraction(featureName)
    {
        var catStr = document.mapForm.searchCategory.value;
		document.mapForm.pageAction.value='BAR_CLICK';	//Simulate a bar button
        document.mapForm.pageMode.value=catStr.toUpperCase()
		document.mapForm.showFeature.value = featureName;
		document.mapForm.featureType.value = 'ATTRACTION';
		document.mapForm.featureX.value = 150;
		document.mapForm.featureY.value = -33;
		document.mapForm.zoomToFeature.value='YES'
		document.mapForm.submit();        
    }
    
	
    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;
 }
}


    function enterFind(sControl,event)
    {
        var bolOldBrowser = (document.layers) ? true : false;
        var intKeyCode = 0;
        if (bolOldBrowser)
            intKeyCode = event.which;
        else
            intKeyCode = event.keyCode;
        if (intKeyCode == 13)
        {
           switch (sControl.name) 
           {
                case 'findTownAttr' : findtown(document.mapForm.findTownAttr.value,document.mapForm.findStateAttr.value); break;
                case 'findStateAttr' : findtown(document.mapForm.findTownAttr.value,document.mapForm.findStateAttr.value); break;
                case 'entry_FindTownAttr' : findtown(document.mapForm.entry_FindTownAttr.value,document.mapForm.entry_FindStateAttr.value); break;
                case 'entry_FindStateAttr' : findtown(document.mapForm.entry_FindTownAttr.value,document.mapForm.entry_FindStateAttr.value); break;
                case 'entry_FindAttr' : findProduct(sControl.value); break;
                case 'findTownAccom' : findAttrTown(document.mapForm.findTownAccom.value,document.mapForm.findStateAccom.value); break;
                case 'findStateAccom' : findAttrTown(document.mapForm.findTownAccom.value,document.mapForm.findStateAccom.value); break;
                case 'findTownInfo' : findtown(document.mapForm.findTownInfo.value,document.mapForm.findStateTownInfo.value); break;
                case 'entry_FindTownAccom' : findtown(document.mapForm.entry_FindTownAccom.value,document.mapForm.entry_FindStateAccom.value); break;
                case 'entry_FindStateAccom' : findtown(document.mapForm.entry_FindTownAccom.value,document.mapForm.entry_FindStateAccom.value); break;
                case 'entry_FindProperty' : findProduct(sControl.value); break;
                case 'findStateTownInfo' : findtown(document.mapForm.findTownInfo.value,document.mapForm.findStateTownInfo.value); break;
                case 'findStateTown' : findtown(document.mapForm.rightMenufindTownName.value,document.mapForm.findStateTown.value); break;
                case 'findTownTDrive' : findtown(document.mapForm.findTownTDrive.value,document.mapForm.findStateTDrive.value); break;
                case 'findStateTDrive' : findtown(document.mapForm.findTownTDrive.value,document.mapForm.findStateTDrive.value); break;
                case 'rightMenufindTownName' :findtown(document.mapForm.rightMenufindTownName.value,''); break;
                case 'routefindStateTown' :findtown(document.mapForm.routefindTownName.value,document.mapForm.routefindStateTown.value); break;
                case 'routefindTownName' :findtown(document.mapForm.routefindTownName.value,document.mapForm.routefindStateTown.value); break;
                case 'findProperty' : findProduct(sControl.value); break;
                case 'findAttr' : findProduct(sControl.value); break;
                default: alert('GeneralJS:EnterFind: Could not find function for ' + sControl.name);
           }
        }    
    }
    
    function enterSimpleMap(Event)
    {
        var bolOldBrowser = (document.layers) ? true : false;
        var intKeyCode = 0;
        if (bolOldBrowser)
            intKeyCode = event.which;
        else
            intKeyCode = event.keyCode;
        if (intKeyCode == 13)
            goSimpleMap();
    }
   
   function enterGoMap(Event)
    {
        var bolOldBrowser = (document.layers) ? true : false;
        var intKeyCode = 0;
        if (bolOldBrowser)
            intKeyCode = event.which;
        else
            intKeyCode = event.keyCode;
        if (intKeyCode == 13)
            goMap();
    }
    
    
    function showWait()
    {
        var img = document.mapForm.mapImage;
        if (img != null)
            img.src = 'images/searching3.gif';
    }
    
    function switchToMapMode()
    {        
        document.mapForm.pageAction.value="BAR_CLICK" //Simulate a click on the mode bar
        document.mapForm.searchScope.value = "MAP"
		document.mapForm.submit();
    }    

    function viewCategoryForTown(aMode,sTown,sState)
    {				
        document.mapForm.searchCategory.value=aMode;
	    zoomToTown(sTown,sState);    
        backToList(); //Requirement is to go directly to list after advanced search - replace with submit() to return to previous system
	}

	function addRouteIntersectionMap(iIntersectID)
	{
	    document.mapForm.routeIntersectMapList.value = document.mapForm.routeIntersectMapList.value + iIntersectID + ";" 
	    document.mapForm.submit();
	}
	
    function check(Type) 
     {
        switch (Type) 
        {
          case "Accommodation": 
                document.mapForm.accomtypeAll.checked = false; 
          break;
          case "Facilities": 
                document.mapForm.facilitiesAll.checked = false; 
          break;
          case "Stars": 
                document.mapForm.starsAll.checked = false; 
          break;
          case "Chains": 
                document.mapForm.chainsAll.checked = false; 
          break;
        }     
     }   
    
 
    
    function doNotCheck(obj, Type)
    {
        switch (Type) 
        {
            case "Accommodation": //sets Accommodation off {
            document.mapForm.TouristParksCampingAreas.checked  = false
            document.mapForm.HouseboatsCruisers.checked = false
            document.mapForm.HotelsMotelsApartmentHotels.checked = false
            document.mapForm.CottagesCabinsHouses.checked = false
            document.mapForm.BedBreakfastGuestHouse.checked = false
            document.mapForm.BackpackerHostels.checked = false
            document.mapForm.ApartmentsHolidayUnits.checked = false
            break;
            
            case "Facilities": //sets Facilities off {
            document.mapForm.Barbeque.checked  = false
            document.mapForm.CableTV.checked = false
            document.mapForm.ConferenceFacilities.checked = false
            document.mapForm.Cooling.checked = false
            document.mapForm.DisabledAccess.checked = false
            document.mapForm.PetsAllowed.checked = false
            document.mapForm.inHouseMovies.checked = false
            document.mapForm.nonSmoking.checked = false
            document.mapForm.Restaurant.checked = false
            document.mapForm.SwimmingPool.checked = false
            document.mapForm.CookingFacilities.checked = false
            document.mapForm.Cots.checked = false
            document.mapForm.OpenFireplace.checked = false     
            document.mapForm.Playground.checked = false
            document.mapForm.Spa.checked = false
            document.mapForm.Video.checked = false
            break;

            case "Stars": //sets Stars off {
            document.mapForm.fiveStar.checked  = false
            document.mapForm.fourStar.checked = false
            document.mapForm.threeStar.checked = false
            document.mapForm.twoStar.checked = false
            break;
            
            case "Chains": //sets Chains off {
            document.mapForm.Comfort.checked = false
            document.mapForm.quality.checked = false
            document.mapForm.clarion.checked = false
            document.mapForm.bestWestern.checked = false  
            
            document.mapForm.aspenPark.checked = false 
            document.mapForm.aspenResorts.checked = false 
            document.mapForm.medina.checked = false 
            document.mapForm.vibe.checked = false 
            document.mapForm.discoveryPark.checked = false 
            document.mapForm.grandMercure.checked = false 
            document.mapForm.mercure.checked = false 
            document.mapForm.novotelHotels.checked = false 
            document.mapForm.novotelResorts.checked = false 
            document.mapForm.familyParks.checked = false 
            document.mapForm.holidayHaven.checked = false 
            document.mapForm.econoLodge.checked = false                                                        
            break;
        }
    
       //keeps ALL checkbox checked
     obj.checked = true; 
    }
    
    
     function resetSubPage()
        {
                document.mapForm.showFeature.value = '';
                document.mapForm.featureType.value = '';
		        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 
            // backToPreviousList()
        }	
        
        
        function setPM(){
             document.mapForm.pageMode.value = PM;
        }