function ChangeSearchState(KWS, CID)
    {
        var bHaveQS, sReDir;
        
        bHaveQS = false;
        sReDir = '/CatListing.asp'
        
        if (KWS != '')
            {
                sReDir += (bHaveQS) ? '&' : '?';
                sReDir += 'KWS=' + KWS;
                bHaveQS = true;
            }
            
        if (CID != '')
            {
                sReDir += (bHaveQS) ? '&' : '?';
                sReDir += 'CID=' + CID;
                bHaveQS = true;
            }

        // Add on the new state //
        sReDir += (bHaveQS) ? '&' : '?';
        sReDir += 'SID=' + document.frmMain.cmbStateID[document.frmMain.cmbStateID.selectedIndex].value;
        bHaveQS = true;


        document.location.href = sReDir;
    }
    
function SaveCurrentSearch()
    {
    
        if (document.frmMain.hidUID.value == '')
            {
                // We need to register first //
                window.location.href = '/UserRegistration.asp'; 
            }
        else
            {
                // We are logged in, so show the save search dialog //
                if (document.getElementById('SearchNameField')) 
                    {
                        document.getElementById('SearchNameField').style.display = 'block';
                    }
            }
    }    
    
function DoSaveSearch()
    {
    
        if (document.frmMain.txtSearchName.value == '')
            {
                alert('You must enter a name to save this search under.');
            }
        else
            {
                if (document.getElementById('SaveSearchProgress'))
                    {
                        document.getElementById('SaveSearchProgress').innerHTML = 'Saving search, please wait ...';
                    }
                    
                // There is a user ID, so we can just do the job //
                var xmlHttp;
                try
                    {    // Firefox, Opera 8.0+, Safari    
                         xmlHttp=new XMLHttpRequest();    
                    }
                catch (e)
                    {    
                         // Internet Explorer    
                         try
                            {      
                                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
                            }
                        catch (e)
                            {      
                                try
                                    {        
                                        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
                                    }
                                catch (e)
                                    {        
                                        alert("Your browser does not support AJAX!");        
                                        return false;        
                                    }      
                             }    
                     }

                xmlHttp.onreadystatechange=function()
                    {
     
                        if(xmlHttp.readyState==4)
                            {
     
                                // Process the results that we get from our call
                                var sResultText = xmlHttp.responseText;

                                // Trim off the spurious script block from the reply
                                if (sResultText.indexOf("/script")  > -1)
                                    {
                                        sResultText = sResultText.substr(sResultText.indexOf("/script") + 8);
                                    }
                                    
                                // Trim off the spaces and things
                                var sResultText = sResultText.replace(/^\s+|\s+$/g, '')

                                // Close the search box and things //
                                if (document.getElementById('SaveSearchProgress'))
                                    {
                                        document.getElementById('SaveSearchProgress').innerHTML = 'Save complete';
                                    }

                                if (document.getElementById('SearchNameField'))
                                    {
                                        document.getElementById('SearchNameField').style.display = 'none';
                                    }
                                
                                alert('Your search criteria has been stored and will now be available from the My OzLeisure page (linked on the left hand side) and from all saved searched drop-down lists.'); 
                            }
                    }

                    // Make the main request - pass the map bounds (split out) to the read page
// alert('/ModifySavedSearch.asp?UserID=' + document.frmMain.hidUID.value + '&SearchName=' + document.frmMain.txtSearchName.value + '&Keywords=' + document.frmMain.hidSearchCriteriaKW.value + '&KWType=' + document.frmMain.hidSearchCriteriaKWType.value + '&CID=' + document.frmMain.hidSearchCriteriaCID.value + '&SID=' + document.frmMain.hidSearchCriteriaSID.value + '&CBD=' + document.frmMain.hidSearchCriteriaCBD.value + '&Reg=' + document.frmMain.hidSearchCriteriaREG.value + '&UseRadius=' + document.frmMain.hidSearchUseRadius.value + '&RadiusType=' + document.frmMain.hidSearchRadiusType.value + '&RadiusDistance=' + document.frmMain.hidSearchRadiusDistance.value + '&Postcode=' + document.frmMain.hidSearchStartPostcode.value + '&SuburbID=' + document.frmMain.hidSearchStartSuburbID.value + '&ms=' + new Date().getTime());

                    xmlHttp.open('GET','/ModifySavedSearch.asp?UserID=' + document.frmMain.hidUID.value + '&SearchName=' + document.frmMain.txtSearchName.value + '&Keywords=' + document.frmMain.hidSearchCriteriaKW.value + '&KWType=' + document.frmMain.hidSearchCriteriaKWType.value + '&CID=' + document.frmMain.hidSearchCriteriaCID.value + '&SID=' + document.frmMain.hidSearchCriteriaSID.value + '&CBD=' + document.frmMain.hidSearchCriteriaCBD.value + '&Reg=' + document.frmMain.hidSearchCriteriaREG.value + '&UseRadius=' + document.frmMain.hidSearchUseRadius.value + '&RadiusType=' + document.frmMain.hidSearchRadiusType.value + '&RadiusDistance=' + document.frmMain.hidSearchRadiusDistance.value + '&Postcode=' + document.frmMain.hidSearchStartPostcode.value + '&SuburbID=' + document.frmMain.hidSearchStartSuburbID.value + '&ms=' + new Date().getTime(),true);
                    xmlHttp.send(null);                  
            }            
    }    
