﻿//// This file is used for the map results map to for Multimap
var count, breadCrumContainer, pageHeaderTitle;
var propertyResultsStatus = true,isMsgAlreadyShown = false;
var readyToLoadSecondaryOptions = false;

// This is used to draw the map in the property details page 
var lat, lon, constituencyNewLayer,errorMsgDiv, errorImage;
var mapviewerId = 'dvMapViewer',currentOverlay = "crime";

//method pointer reference for performance enhauncement
var showErrorMessage = displayError;
var errorMsgDetails,previousMapPosition;
var popupclass = "showpopup leftpeakpopup";

/* Method used first time to load the map */
function loadMap() {
    if (!document.getElementById(mapviewerId)) {
        return false;
    }
    addCustomTilesOverlay();
    if (checkIsNullOrEmpty(queryStringSchools) && searchType == 2 && !checkIsNullOrEmpty(previousMapPosition) ) {
       mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
    } else if(checkIsNullOrEmpty(queryStringPoi) && searchType == 1 && !checkIsNullOrEmpty(previousMapPosition))  {
       mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
    } else if(checkIsNullOrEmpty(previousMapPosition) && window.location.search.indexOf('Puid')== -1) {
         // Show the title of the search for the multimap
         if(!checkIsNullOrEmpty(searchType)) {
              if (rentbuyOption) {
                    var prop_type = "sale";
                    if (rentbuyOption == "lease") {
                        prop_type = "rent";
                    }
                   pageHeaderTitle.innerHTML  = "Properties for " + prop_type + " in "
                                                                     + searchLocation;
               } else {
                   pageHeaderTitle.innerHTML  = "Properties for sale in " + searchLocation;
               }
         }  else {
         
             switch(searchType) {
              case "1":
                 pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
                 break;
              case "2":
                 pageHeaderTitle.innerHTML  = "Schools  in "+ searchLocation;
                 break;
              case "3":   
                 pageHeaderTitle.innerHTML  = "Local Information for "+ searchLocation;
                 break;
              case "6": {
                     var schoolId = getQueryStringValue("schoolid");
                     if (checkIsNullOrEmpty(schoolId) ) {
                         pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
                     } else {
                        pageHeaderTitle.innerHTML  = "Search for amenities with MSN Local";
                     }
              break;       
              }
              default:
                 pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
                 showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                               + "and transport links in your area.", true);
            }
         }
          
         var mapProperties = previousMapPosition.split('|')
         if(mapProperties.length > 0) {
              //not to get results on map coverage event
              readyToLoadSecondaryOptions = true;
               //set the map type
               var latlon= mapProperties[0].split(',');
               var latitude = parseFloat(latlon[0]) ;  
               var longitude = parseFloat(latlon[1]);
               if(checkIsNullOrEmpty(latitude)&& !isNaN(latitude) && checkIsNullOrEmpty(longitude) && !isNaN(longitude)) {
                 var zoomLevel = parseInt(mapProperties[1]);
                 mapviewer.setMapType( Number(mapProperties[2]));
                 mapviewer.goToPosition(new MMLocation(new MMLatLon(latitude,longitude),zoomLevel));
               }  else {
                   mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
               }  
         }   
    } else {
      readyToLoadSecondaryOptions = true;
      ShowResultsOnMap();
    }
    
    mapResultDiv.className = "mapwrapper mapwrapper_border";
    
    //Add partcular event handlers for the multimap
    addEventHandlers();
    
    //add various map types
    addMapTypes();
    mapviewer.setOption ('mousewheel:wheelup', 'zoomin' );
    mapviewer.setOption ('mousewheel:wheeldown', 'zoomout' );
}

/* Function used to get the querystring values */
function SetQueryStringValues() {
   searchLocation = getQueryStringValue("loc");
   puid = getQueryStringValue("Puid");
   rentbuyOption = getQueryStringValue("rntorbuy");
   previousMapPosition = getQueryStringValue("map");
   mapviewer = MMFactory.createViewer(document.getElementById(mapviewerId));
   breadCrumContainer = document.getElementById("dvBreadCrum");
   
}

/* Method used to attach the event handlers for the multimap */
function addEventHandlers() {
    addCommonEventHandlers();
    //only for schools
    if (readyToLoadSecondaryOptions == false )  {
      mapviewer.addEventHandler( 'coverageUpdated', mapCoverageLoaded ) ;
    } 
}


/**
* Function used to load the amenities and local information after 
* loading the properties within map boundaries
*/
function mapLoaded(eventType, eventTarget, startPosition, endPosition, reason) { 

 if(checkIsNullOrEmpty(previousMapPosition))  {
       mapviewer.removeEventHandler( 'tilesLoaded', mapLoaded );
       dragSearch = true;
       if(checkIsNullOrEmpty(queryStringOverlays )) {    
          isMapChanged = true;   
          displayConstituencyOverlay(queryStringOverlays);
       }
       searchNewRecordsOnMapChanges();
       if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch) ||isPTrendsVisible == "1") {
            searchTrendsDataWithinMapBoundaries();
       }
        //to show heatmaps, if heatmaps were present on map in the previous page
       if(currentHeatMap != null){
            showHeatMapTypeMsg(currentHeatMap,true);
            displayPricesAndTrendsOverlays();
            showHideTrendHeatmapsLegend(currentHeatMap);
       } 
       hideErrorMsg();
   
 } else {
    if (readyToLoadSecondaryOptions == true ) {  
        mapviewer.removeEventHandler( 'tilesLoaded', mapLoaded );
        if(!searchType) {
            //check properties result set status
            if (propertyResultsStatus == false)  {
                    if(IsMapVisible() == false) {
                           showMap(true);
                           if (checkIsNullOrEmpty(queryStringBusinessCategory) ) {
                             searchBusinessResultsWithVE();
                           } else if (checkIsNullOrEmpty(queryStringPoi)) {
                             searchAmenitiesWithMultimap();
                             searchAmenitiesWithVE();
                           } else if(checkIsNullOrEmpty(queryStringSchools)) {
                             searchSchoolsWithMsnLocal();
                           } else if(checkIsNullOrEmpty(queryStringLocalInfo)){
                             searchLocalInformation();            
                           } else if(checkIsNullOrEmpty(queryStringOverlays)){           
                             showLocalInformationHeatMaps(queryStringOverlays);
                           } else if(checkIsNullOrEmpty(queryStringBusinessCategory)) {
                             searchBusinessResultsWithVE();
                           }  
                    } else {
                       if(checkIsNullOrEmpty(queryStringPoi)){
                         getAmenitiesOnMapDragged();
                         searchAmenitiesWithVE();
                       }
                       if(checkIsNullOrEmpty(queryStringLocalInfo )){
                         searchLocalInformationWithinMapBounds();             
                       }
                       if(checkIsNullOrEmpty(queryStringSchools)){
                         getSchoolResultsOnMapDragged();
                       }
                       if(checkIsNullOrEmpty(queryStringOverlays )){    
                          isMapChanged = true;   
                          displayConstituencyOverlay(queryStringOverlays);
                       }
                        if (checkIsNullOrEmpty(queryStringBusinessCategory) ) {
                        searchBusinessResultsWithVE();
                       }
                       
                       if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch) || isPTrendsVisible == "1") {
                        searchTrendsDataWithinMapBoundaries();
                       }
                       //to show heatmaps, if heatmaps were present on map in the previous page
                        if(currentHeatMap != null){
                        showHeatMapTypeMsg(currentHeatMap,true);
                        displayPricesAndTrendsOverlays();
                        showHideTrendHeatmapsLegend(currentHeatMap);
                      }
                   }
                  
            } else {
               if(checkIsNullOrEmpty(queryStringPoi)) {
                 getAmenitiesOnMapDragged();
                 searchAmenitiesWithVE();
               }
               if(checkIsNullOrEmpty(queryStringLocalInfo)) {
                 searchLocalInformationWithinMapBounds();             
               }
               if(checkIsNullOrEmpty(queryStringSchools)){
                 getSchoolResultsOnMapDragged();
               }
               if(checkIsNullOrEmpty(queryStringOverlays)){    
                  isMapChanged = true;   
                  displayConstituencyOverlay(queryStringOverlays);
               }
               if (checkIsNullOrEmpty(queryStringBusinessCategory) ) {
                    searchBusinessResultsWithVE();
                   }
                   
               if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch) ||isPTrendsVisible == "1") {
                    searchTrendsDataWithinMapBoundaries();
                   }
                //to show heatmaps, if heatmaps were present on map in the previous page
                if(currentHeatMap != null){
                showHeatMapTypeMsg(currentHeatMap,true);
                displayPricesAndTrendsOverlays();
                showHideTrendHeatmapsLegend(currentHeatMap);
              }   
          }
       } else  { //if primary search is amenities or others
         if(CheckZoomFactor()) {
         
          switch(searchType) {
            case "1": {
                 if(checkIsNullOrEmpty(queryStringSchools)) {
                    getSchoolResultsOnMapDragged();
                  }
                 if(checkIsNullOrEmpty(queryStringLocalInfo)){
                     searchLocalInformationWithinMapBounds();                 
                   }
                  if(checkIsNullOrEmpty(queryStringOverlays)) {                 
                     searchCustomOverlaysWithinMapBounds();
                   }
                   if (checkIsNullOrEmpty(queryStringBusinessCategory) && checkIsNullOrEmpty(queryStringPoi)) {
                     searchBusinessResultsWithVE();
                   }
                   if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch)|| isPTrendsVisible == "1" ) {
                    searchTrendsDataWithinMapBoundaries();
                   }
                    //to show heatmaps, if heatmaps were present on map in the previous page
                if(currentHeatMap != null){
                    showHeatMapTypeMsg(currentHeatMap,true);
                    displayPricesAndTrendsOverlays();
                    showHideTrendHeatmapsLegend(currentHeatMap);
                  } 
                  
             break;     
            }
            case "2": {
                   if(checkIsNullOrEmpty(queryStringPoi)){
                     getAmenitiesOnMapDragged();
                     searchAmenitiesWithVE();
                   }
                   if(checkIsNullOrEmpty(queryStringLocalInfo)){
                     searchLocalInformationWithinMapBounds();                 
                   }
                   if(checkIsNullOrEmpty(queryStringOverlays)){                 
                     searchCustomOverlaysWithinMapBounds();
                   }
                   if (checkIsNullOrEmpty(queryStringBusinessCategory) ) {
                    SearchBusinessResultsWithinMapbounds();
                   }
                   
                   if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch) || isPTrendsVisible == "1") {
                    searchTrendsDataWithinMapBoundaries();
                   }
                    //to show heatmaps, if heatmaps were present on map in the previous page
                   if(currentHeatMap != null){
                        showHeatMapTypeMsg(currentHeatMap,true);
                        displayPricesAndTrendsOverlays();
                        showHideTrendHeatmapsLegend(currentHeatMap);
                   }  
             break;     
            }
            case "3": {
            
                 if(checkIsNullOrEmpty(queryStringSchools)){
                    getSchoolResultsOnMapDragged();
                  }
                 if(checkIsNullOrEmpty(queryStringPoi)){
                    getAmenitiesOnMapDragged();
                  } 
                 if(checkIsNullOrEmpty(queryStringLocalInfo)&& checkIsNullOrEmpty(queryStringOverlays)){
                     searchLocalInformationWithinMapBounds();             
                   }
                 if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch) || isPTrendsVisible == "1") {
                    searchTrendsDataWithinMapBoundaries();
                 }
                 //to show heatmaps, if heatmaps were present on map in the previous page
                 if(currentHeatMap != null){
                    showHeatMapTypeMsg(currentHeatMap,true);
                    displayPricesAndTrendsOverlays();
                    showHideTrendHeatmapsLegend(currentHeatMap);
                 } 
                 //added to implement the QFE
                 if(rentbuyOption || isPropertyVisible == "1")  {
                        SearchPropertiesInBoundaries();
                 }
                 
            break;     
            }
            case "6": {
                
                //This is required when we need not to show message if no results come
                dragSearch = true;
                //added to implement the QFE
                if(rentbuyOption || isPropertyVisible == "1")  {
                        SearchPropertiesInBoundaries();
                }
                
                var schoolId = getQueryStringValue("schoolid");
                if (checkIsNullOrEmpty(schoolId) ) {
                      if(checkIsNullOrEmpty(queryStringPoi)){
                         getAmenitiesOnMapDragged();
                         searchAmenitiesWithVE();
                       }
                       if(checkIsNullOrEmpty(queryStringLocalInfo)){
                         searchLocalInformationWithinMapBounds();                 
                       }
                       if(checkIsNullOrEmpty(queryStringOverlays)){                 
                         searchCustomOverlaysWithinMapBounds();
                       }
                       if (checkIsNullOrEmpty(queryStringBusinessCategory) ) {
                        SearchBusinessResultsWithinMapbounds();
                       }
                       
                       if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch) || isPTrendsVisible == "1") {
                        searchTrendsDataWithinMapBoundaries();
                       }
                        //to show heatmaps, if heatmaps were present on map in the previous page
                       if(currentHeatMap != null){
                            showHeatMapTypeMsg(currentHeatMap,true);
                            displayPricesAndTrendsOverlays();
                            showHideTrendHeatmapsLegend(currentHeatMap);
                       } 
                         
                } else {
                  
                     if(checkIsNullOrEmpty(queryStringSchools)) {
                        getSchoolResultsOnMapDragged();
                      }
                     if(checkIsNullOrEmpty(queryStringLocalInfo)){
                         searchLocalInformationWithinMapBounds();                 
                       }
                      if(checkIsNullOrEmpty(queryStringOverlays)) {                 
                         searchCustomOverlaysWithinMapBounds();
                       }
                       if (checkIsNullOrEmpty(queryStringBusinessCategory) && checkIsNullOrEmpty(queryStringPoi)) {
                         searchBusinessResultsWithVE();
                       }
                       if (checkIsNullOrEmpty(qStringPricesAndTrendsSearch)|| isPTrendsVisible == "1" ) {
                        searchTrendsDataWithinMapBoundaries();
                       }
                        //to show heatmaps, if heatmaps were present on map in the previous page
                       if(currentHeatMap != null){
                        showHeatMapTypeMsg(currentHeatMap,true);
                        displayPricesAndTrendsOverlays();
                        showHideTrendHeatmapsLegend(currentHeatMap);
                       } 
                }
                break;     
            }
            
        }//end of switch statement
      
      }//end of zoom factor check
     }//end of else if primary search is amenities
    } //end main if statement
}

setMapType();

}

/* Method used to set the zoom factor based on the map type*/
function setMapType() {
  var mapType = mapviewer.getMapType();
  if(mapType == 256 || mapType == 64)   {
       mapviewer.setAllowedZoomFactors(19, 20); 
  } else  {
        if(queryString.indexOf('Puid')>-1) {
            mapviewer.setAllowedZoomFactors(6, 18); 
        } else {
            mapviewer.setAllowedZoomFactors(7, 18); 
        }    
  }
}

/* Method used in case of radius search */
function mapCoverageLoaded(type,target ) {

 if(readyToLoadSecondaryOptions == false) {
      if(rentbuyOption)  {
            SearchPropertiesInBoundaries();
      } else if(checkIsNullOrEmpty(queryStringPoi) && searchType == 1)   {
            if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " "){
                pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
            }  
            getAmenitiesOnMapDragged();
            searchAmenitiesWithVE();
      } else {
           if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " " )  {
                 pageHeaderTitle.innerHTML  = "Schools  in "+ searchLocation; 
            }
       getSchoolResultsOnMapDragged();
     }  
  mapviewer.removeEventHandler( 'coverageUpdated', mapCoverageLoaded );
  readyToLoadSecondaryOptions = true;
  }  
} 

/** Function used for searching the properties  after map has been loaded **/
function ShowResultsOnMap() {
 if (checkIsNullOrEmpty(searchType)) {
    switch(searchType) {
        case "1": { //for  amenities and transport links main search
            if(checkIsNullOrEmpty(queryStringBusinessCategory)) {
                 if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " "){
                      pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
                 }  
                 searchBusinessResultsWithVE();
            } else {
                searchAmenitiesWithMultimap();
            }
            break;
        }
        case "2": { // for schools main search
            if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " " )  {
             pageHeaderTitle.innerHTML  = "Schools  in "+ searchLocation; 
            }
            
            getSchoolResultsOnMapDragged();
            break;
        }
        case "3": { // for local information main search
            if(checkIsNullOrEmpty(queryStringOverlays)) {
                  showLocalInformationHeatMaps(queryStringOverlays);
                  showShootHillLogo();
            } else if(checkIsNullOrEmpty(queryStringLocalInfo)){
                  searchLocalInformation();
            } 
            break;
        }
        case "6": { // request from property details page
            var schoolId = getQueryStringValue("schoolid");
            if (checkIsNullOrEmpty(schoolId) ) {
               if(isNumeric(schoolId)){
                 GetSchoolDetailsById(schoolId);
               } else {
                 pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
                 showErrorMessage("Please try changing your search to include a larger area.", true);
                 showMap(false);
               }
            } else {
               SearchAmenitiesByLatLon();
            }
            break;
        }
    }//end of switch statement
  } else { //end of search type
    SearchPropertiesForMap();
  }
}

/* Method used to search the properties based on location */
function SearchPropertiesForMap(){
    // Show the title of the search for the multimap
    if (checkIsNullOrEmpty(searchLocation) ) {
        if (rentbuyOption) {
            var prop_type = "sale";
            if (rentbuyOption == "lease") {
                prop_type = "rent";
            }
           pageHeaderTitle.innerHTML  = "Properties for " + prop_type + " in "
                                                             + searchLocation;
        } else {
           pageHeaderTitle.innerHTML  = "Properties for sale in " + searchLocation;
        }
    } else if(puid){
        pageHeaderTitle.innerHTML  = "Properties in watchlist";
   }
    addPropertiesClusterGroup();
    IsPropertiesResultsLoaded = false;
    loadingStatus(true);
    var parameter=unescape(window.location.search);
    if(checkIsNullOrEmpty(parameter))   {
       parameter += "&search=1" 
    }
    var ajaxRequest = new ajaxObject(PropertiesServerScriptPageUrl);
    ajaxRequest.callback = function(JsonString)  {
 
        if (checkIsNullOrEmpty(JsonString)) {
          try {
              var Properties = eval('(' + JsonString + ')');
              var total=Properties.Property.length;
              var getPropertyMarkers = CreatePropertyMarkers;             
              for (var i = 0; i < total ; i++) {
                   getPropertyMarkers(Properties.Property[i],i);
              }
                
              if (propertyMarkers.length > 0) {
                   mapviewer.goToPosition(mapviewer.getAutoScaleLocation(propertyMarkers));
                   //show 'view as a list/map' links
                    if(typeof(searchType) == "undefined"){
                        document.getElementById("ViewLink").style.display = "block";
                    }
                    updateHashValueInUrl("prpty","1",true);
              } 
              else { 
                  propertyResultsStatus = false;
                  showMap(false);
                  showErrorMessage("Please try changing your search to include a larger area or a wider price range or "
                                 +"remove some filters to view properties.", true);
                  if((checkIsNullOrEmpty(queryStringPoi))||(checkIsNullOrEmpty(queryStringSchools)) 
                       || (checkIsNullOrEmpty(queryStringLocalInfo )) ||(checkIsNullOrEmpty(queryStringOverlays ))) {
                        mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB'})));
                        showMap(true);
                     }
               }
               
          } catch(error) {
             propertyResultsStatus = false;
             showMap(false);
             showErrorMessage("Please try changing your search to include a larger area or a wider price range or "
                         + "remove some filters to view properties.", true);
             if((checkIsNullOrEmpty(queryStringPoi))||(checkIsNullOrEmpty(queryStringSchools)) 
                ||(checkIsNullOrEmpty(queryStringLocalInfo)) ||(checkIsNullOrEmpty(queryStringOverlays))) {
                mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
                showMap(true);
             }
          }
        } else  {
             propertyResultsStatus = false;
             showMap(false);
             showErrorMessage("Please try changing your search to include a larger area or a wider price range or "
                         + "remove some filters to view properties.", true);
             if((checkIsNullOrEmpty(queryStringPoi))||(checkIsNullOrEmpty(queryStringSchools)) 
                ||(checkIsNullOrEmpty(queryStringLocalInfo)) ||(checkIsNullOrEmpty(queryStringOverlays))) {
                mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
                showMap(true);
             }
        }
        
        IsPropertiesResultsLoaded = true;
        loadingStatus(false);
    }
    
   if(parameter.length > 0 ) {
     ajaxRequest.update(parameter.substring(1));
   } else  {
      ajaxRequest.update(parameter);
   }
}

/* Function used for the free search text for the amenities */
function searchAmenitiesWithMultimap() {
    
    var dataSource = '';
    var counter = 0;
    if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " ") {
      pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
    }  
    //get the datasource for the search from the querystring  
    for (var key in overlays) {
        var el = document.getElementById('show_' + key);
        if (el) {
            if (el.checked) {
                dataSource += overlays[key].dataSource + ','
                counter++;
            }
        }
    }
    
    if (dataSource != '') {
        //remove the last comma from the string
        dataSource = dataSource.substring(0, dataSource.length - 1); 
        searcher = MMFactory.createSearchRequester(searchAmenitiesCallback);
        search = new MMSearch();
        search.address = new MMAddress({ qs: searchLocation, country_code: 'GB' });
        search.data_source = dataSource;
        search.radius_units = 'miles';
        search.route_modes = 'walking,driving';
        search.count = 500;
        
        //Set the maximum distance to search from the central point
        // of the search
        if (counter < 3) {
            search.max_distance = Number(0.5);
        } else {
            search.max_distance = Number(0.8);
        }
        
        IsMultimapAmenitiesResultsLoaded = false;
        loadingAmenitiesStatus(true);
        showMap(true);
        loadingStatus(true);
        searcher.search(search);
    } else { //if there is no location
        if (checkIsNullOrEmpty(searchLocation)) {
            if (checkIsNullOrEmpty(searchType)) {
                showMap(false);
                showErrorMessage("Please use the search box on the left hand side of the page to search for "
                             +"amenities and local information in your area.", true);
                errorMsgDiv.className = "defaultmsgdetails";
                errorMsgDetails.className = "defaultmsg";
                errorImage.style.display = "none";
                pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
            }
        }
    }
    return false;
}

/* Callback function for the free search text of amenities */
function searchAmenitiesCallback() {
    if (searcher.error_code) {
        IsMultimapAmenitiesResultsLoaded = true;
        loadingAmenitiesStatus(false);
        loadingStatus(false);
        showMap(false);
        showErrorMessage("Please try changing your search to include a larger area.", true);
        return;
    }
    for (var count = 0, l = searcher.record_sets.length; count < l; count++) {
    if (searcher.record_sets[count].records) {
        for (var key in overlays) {
            if (overlays[key].dataSource == searcher.record_sets[count].dataSource) {
                currentKey = key;
                break;
            }
        }
        newResults = [];
        key = currentKey;
        var createPoiHtml = getPoiHtml;
        for (var record_count = 0, rl = searcher.record_sets[count].records.length; record_count < rl; record_count++) {
            var record = searcher.record_sets[count].records[record_count];
            if (record) {
                var html = createPoiHtml(record, key);
                var point = record.point;
                var marker = mapviewer.createMarker(point, { 'icon': overlays[key].icon });
                if (key != "wikipedia") {
                    marker.setInfoBoxContent('<p>' + html + '<' + '/p>', { className: 'popupInfobox' });
                } else {
                   marker.setInfoBoxContent('<p>' + html + '<' + '/p>', { className: 'wikipediaInfobox' });
                }
                newResults.push(marker);
            } //end of record
        } //end of the for loop
        overlays[key].results = newResults;
        }  //end of the outer if loop  
    } //end of the outer for loop
    if (newResults.length > 0) {
        mapviewer.goToPosition(mapviewer.getAutoScaleLocation(newResults));
    } else {
        mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
          if(!isMsgAlreadyShown){
            showErrorMessage("Please try changing your search to include a larger area.", true);
          }
    }
    if (propertyResultsStatus == false) {
        if(checkIsNullOrEmpty(queryStringSchools)) {
            getSchoolResultsOnMapDragged();
        }
    }
    IsMultimapAmenitiesResultsLoaded = true;
    loadingStatus(false)
    loadingAmenitiesStatus(false);
} //end of main loop

/*************  School Information ***************************************/
/** Method used to search the schools with msn local */
function searchSchoolsWithMsnLocal() {
   addSchoolsClusterGroup();
   IsSchoolsResultsLoaded = false;
   loadingStatus(true);
   schoolLoadingStatus(true);
   if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " ")  {
     pageHeaderTitle.innerHTML  = "Schools  in "+ searchLocation; 
   }
   var newrecords =  { 
        primary: [],selective: [],modern: [],comprehensive: [],colleges: [],further: [],special: [],welsh:[] 
   };
   var schoolType = "";
   var schoolOptions = getQueryStringValue("schools");
   if ( checkIsNullOrEmpty( schoolOptions)) {
        if (schoolOptions.indexOf("all") > -1) {
            schoolType = allSchoolTypes;
        } else {
             for (var key in schoolOverlayKeys) {
                 var el = document.getElementById('show_' + key);
                 if (el){
                      if (el.checked) {
                           schoolType += schoolOverlayKeys[key].type + '|'
                       }
                   }
                   
            }
            if (schoolType != "") {
              schoolType = schoolType.substring(0, schoolType.length - 1);
            }  
        }
    }
   
    var markers = [];
    var parameters = "search=1&loc=" + searchLocation + "&type=" + schoolType;
    var ajaxRequest = new ajaxObject(SchoolsServerScriptPageUrl);
    ajaxRequest.callback = function(JsonString) {
        if (checkIsNullOrEmpty(JsonString)) {
        
            var Schools = eval('(' + JsonString + ')');
            var totalSchoolsCount = Schools.School.length;
            var createSchoolHtml =  getSchoolDetailsHtml;
            var drawSchoolMarkers = createSchoolMarker;
            
            var html, key, point, marker;
            for (var i = 0; i < totalSchoolsCount; i++) {
                html = createSchoolHtml(Schools.School[i]);
                key = Schools.School[i].SchoolType.toLowerCase();
                if(key != "secondary"){
                 key = key.replace("secondary","").replace("education","");
                 key = key.split(' ').join('');
                } else {
                    key = "welsh";
                }
                point = new MMLocation(new MMLatLon(Schools.School[i].Latitude, Schools.School[i].Longitude));
                marker = drawSchoolMarkers(point, html, key);
                newrecords[key].push(marker);
                markers.push(marker);
            }
            for (var key in newrecords) {
                schoolOverlayKeys[key].results = newrecords[key];
            }
            if (markers.length > 0) {
                mapviewer.goToPosition(mapviewer.getAutoScaleLocation(markers));
            }
        } else {
            mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
            if(!isMsgAlreadyShown) {
              showMap(false);
              showErrorMessage("Please try changing your search to include a larger area.", true);
            } 
        }
        if (propertyResultsStatus == false)  {
            if(checkIsNullOrEmpty(queryStringPoi )){
                getAmenitiesOnMapDragged();
            }
            if(checkIsNullOrEmpty(queryStringLocalInfo)){
                searchLocalInformationWithinMapBounds();
            }
        }
        IsSchoolsResultsLoaded = true;
        loadingStatus(false);
        schoolLoadingStatus(false);

    }
    ajaxRequest.update(parameters);
}

/*Function used for getting the school details by id */
function GetSchoolDetailsById(id) {
    pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
    loadingStatus(true);
    schoolLoadingStatus(true);
    var key;
    var parameters = "search=3&schoolid=" + id;
    var ajaxRequest = new ajaxObject(SchoolsServerScriptPageUrl);
    var marker ;
    ajaxRequest.callback = function(JsonString) {
        if (checkIsNullOrEmpty(JsonString)) {
         
            var Schools = eval('(' + JsonString + ')');
            //for showing the school pop up 
            isBackButtonRequired=true;
            var html = getSchoolDetailsHtml(Schools.School[0]);
            key = Schools.School[0].SchoolType.toLowerCase();
            if(key !="secondary"){
              key = key.replace("secondary","").replace("education","");
              key = key.split(' ').join('');
            } else {
                key="welsh";
            }
            var point = new MMLocation(new MMLatLon(Schools.School[0].Latitude, Schools.School[0].Longitude));
            marker = createSchoolMarker(point, html, key);
            markers.push(marker);
            schoolOverlayKeys[key].results = markers;
            if (marker) {
                mapviewer.goToPosition(mapviewer.getAutoScaleLocation(marker));
                marker.openInfoBox();
            } else {
                if(!isMsgAlreadyShown) {
                  showErrorMessage("Please try changing your search to include a larger area.", true);
                  
                } 
            }

        } else { //end of the if statement
                if(!isMsgAlreadyShown) {
                  showErrorMessage("Please try changing your search to include a larger area.", true);
                  showMap(false);
                } 
            }
        loadingStatus(false);
        schoolLoadingStatus(false);
    }
    ajaxRequest.update(parameters);
}

/* Function used for searching the local information */
function searchLocalInformation() {
    if(pageHeaderTitle.innerHTML == "" || pageHeaderTitle.innerHTML == " ") {
      pageHeaderTitle.innerHTML  = "Local Information for "+ searchLocation;
    } 
    searcher = MMFactory.createSearchRequester(localInformationCallback);
    search = new MMSearch();
    search.address = new MMAddress({ qs: searchLocation, country_code: 'GB' });
    search.data_source = localInformationOverlayKeys["wikipedia"].dataSource ;
    search.count = 100;
    showMap(true);
    IsWikipediaResultsLoaded = false;
    loadingStatus(true);
    searcher.search(search);
    return false;
}

/* Callback function for the free search text of amenities */
function localInformationCallback() {
    if (searcher.error_code) {
        IsWikipediaResultsLoaded = true;
        loadingAmenitiesStatus(false);
        loadingStatus(false);
        showMap(false);
        showErrorMessage("Please try changing your search to include a larger area.", true);
        return;
    }
    for (var count = 0, l = searcher.record_sets.length; count < l; count++) {
        if (searcher.record_sets[count].records) {
            newResults = [];
            key = "wikipedia";
            var createPoiHtml = getPoiHtml;
            for (var record_count = 0, rl = searcher.record_sets[count].records.length; record_count < rl; record_count++) {
                var record = searcher.record_sets[count].records[record_count];
                if (record) {
                    var html = createPoiHtml(record, key);
                    var point = record.point;
                    var marker = mapviewer.createMarker(point, { 'icon': localInformationOverlayKeys[key].icon });
                    //marker.setInfoBoxContent(html);
                    marker.setInfoBoxContent('<p>' + html + '<' + '/p>', { className: 'wikipediaInfobox' });
                    newResults.push(marker);
                } //end of record
            } //end of the for loop
            localInformationOverlayKeys[key].results = newResults;
        }  //end of the outer if loop  
    } //end of the outer for loop
    if (newResults.length > 0) {
        mapviewer.goToPosition(mapviewer.getAutoScaleLocation(newResults));
    } else {
        mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' })));
        if(!isMsgAlreadyShown) {
          showErrorMessage("Please try changing your search to include a larger area.", true);
        }
    }
    IsWikipediaResultsLoaded = true;
    loadingStatus(false)
} //end of main loop

/*Method used to get the overlay images in map bounding boxes*/
function searchCustomOverlaysWithinMapBounds() {
    var overlayType='';
    for (var key in polygonOverlayKeys) {
        var el = document.getElementById('show_' + key);
        if (el) {
            if (el.checked) {
                overlayType = key ;
                break;
            }
        }
    }
    isMapChanged = true; 
    displayConstituencyOverlay(overlayType); 
}

/* Method used for searching the location information */
 function showLocalInformationHeatMaps(overlayType) {
 currentOverlay = overlayType;
      switch(overlayType) {
         case "none" : {
            showOverlayMsg(1,false);
             clearLocalInfoOverlay();
           } 
           break;
         case "constituencies" : {
             showOverlayMsg(2,true);
             ShowCrimeDataOverlay();
             break;
           }  
         case "crime" : {
             showOverlayMsg(1,true);
             ShowCrimeDataOverlay();
             break;
          }  
      }  
 }
 
/* Method used for the custom overlay for the crime data */
 function ShowCrimeDataOverlay() {
   mapviewer.goToPosition(new MMLocation(new MMAddress({ qs: searchLocation, country_code: 'GB' }),13));
   if( currentOverlay == "crime") {
       mapviewer.addOverlay(crimeNewLayer);
       if(version < 7) {
          window.tile = new IETileLayerFix( mapviewer, 'MMTileLayerOverlay1' );
       }
   } else  {
        mapviewer.addOverlay(constituencyNewLayer);
   }    
   pageHeaderTitle.innerHTML  = "Local Information for "+ searchLocation;
 }

/* This method is used for searching the amenities and the transport links
   basedon Latitude and Longitude values
*/

function SearchAmenitiesByLatLon() {
    pageHeaderTitle.innerHTML  = "Search for amenities with MSN Local";
    key = getQueryStringValue("type");
    switch(key) {
        case 'ls':
            key = 'localShops';
            break;
        case 'pt':
            key = 'publicTransport';
            break;
        case 'rs':
            key = 'railwayStations';
            break;
        case 'ts':
            key = 'underground';
            break;
        case 'pb':
            key = 'pubs';
            break;
    }
        
    var lat = getQueryStringValue("lat");
    var lon = getQueryStringValue("lon");
    searcher = MMFactory.createSearchRequester(resultCallbackByLatLon);
    search = new MMSearch();
    var dataSource  = '';
    switch(key) {
        case 'localShops':
          search.data_source = 'mm.poi.global.general.shopping';
          break;
        case 'pubs':
          search.data_source = 'mm.poi.global.general.nightlife';
          break;
        default:
          search.data_source = overlays[key].dataSource;
    }
    search.point = new MMLatLon(lat, lon);
    search.count = 1;
    showMap(true);
    loadingStatus(true);
    loadingAmenitiesStatus(true);
    searcher.search(search);
}

/* Callback function for retrieving the result set based on the latitude
   and longitude values
*/
function resultCallbackByLatLon() {
 if (searcher.error_code) {
    loadingAmenitiesStatus(false);
    loadingStatus(false);
    showMap(false);
    return;
}
//var key = poikey;
for (var count = 0, l = searcher.record_sets.length; count < l; count++) {
    if (searcher.record_sets[count].records) {
        newResults = [];
        var createPoiHtml = getPoiHtml;
        for (var record_count = 0, rl = searcher.record_sets[count].records.length; record_count < rl; record_count++) {
            var record = searcher.record_sets[count].records[record_count];
            if (record) {
            //put the flag to true that the page comes from the property
            //details page
            isBackButtonRequired=true;
            var html = createPoiHtml(record, key);
            var marker;
            var point = record.point;
            switch(key) {
                case 'localShops':
                  marker = mapviewer.createMarker(point, { 'icon':imgShopping });
                  break;
                case 'pubs':
                  marker = mapviewer.createMarker(point, { 'icon':imgPubs });
                  break;
                default :
                  marker = mapviewer.createMarker(point, { 'icon': overlays[key].icon });
            }
            marker.setInfoBoxContent('<p>' + html + '<' + '/p>', { className: 'popupInfobox' });
            newResults.push(marker);
           }
        }
        switch(key) {
            case 'localShops':
              VEOverlayKeys['localShops'].results = newResults;
              break;
            case 'pubs':
              VEOverlayKeys['pubs'].results = newResults;
              break;
            default:
              overlays[key].results = newResults;
       }
    }
}
if (newResults.length > 0) {
    mapviewer.goToPosition(mapviewer.getAutoScaleLocation(newResults));
    marker.openInfoBox();
}

loadingStatus(false)
loadingAmenitiesStatus(false);
}

/* Method used to check the url values when first time Page is Loaded
  this method returns true/false values
*/
function CheckFirstTimePageLoading() {
showShootHillLogo();  
  //check if location for search is empty
if(!checkIsNullOrEmpty(searchLocation) && !checkIsNullOrEmpty(puid)) { 
      //changes for the font style for error msg
      errorMsgDiv.className = "defaultmsgdetails";
      errorMsgDetails.className = "defaultmsg";
      errorImage.style.display = "none";
      showMap(false);  
      if(!checkIsNullOrEmpty(searchType)) {
          showErrorMessage("Please use the search box on the left hand side of the page to search for " 
                       + "properties in your area.", true);
          pageHeaderTitle.innerHTML  = "Search for properties to buy or rent with MSN Local";
          return false;
      } else { 
       switch(searchType){
          case "1":
              showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                           + "and transport links in your area.", true);
              pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
              break;
          case "2":
               showErrorMessage("Please use the search box on the left hand side of the page to search for schools "
                           + "in your area.", true);
               pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
               break;
          case "3":   
             showErrorMessage("Please use the search box on the left hand side of the page to search for local "
                          + "information in your area.", true);
             pageHeaderTitle.innerHTML  = "Search for local information with MSN Local";
             break;
          case "6": { 
                //in case of search by lat lon value
                //check if school id or lat lon values are there 
                var schoolId = getQueryStringValue("schoolid");
                if ((!checkIsNullOrEmpty(schoolId)) && ( !checkIsNullOrEmpty(queryStringPoi))) {
                   showErrorMessage("Please use the search box on the left hand side of the page to search for "
                                + "amenities and transport links in your area.", true);
                   pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
                   return false;
                }
                showMap(true);  
                return true;
             }
             break;
          default:
              showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                             + "and transport links in your area.", true);
              pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
       }
      return false; 
     }
  } else {
        if (checkIsNullOrEmpty(puid)) {
            return true;
        }
       ////if query string contains search text i.e. location 
       if(searchLocation.length > 30) {
       searchLocation = searchLocation.substring(0,30);
       showMap(false);
       if(!searchType) {
           if (rentbuyOption) {
               var prop_type = "sale";
               if (rentbuyOption == "lease") {
                    prop_type = "rent";
               }
               pageHeaderTitle.innerHTML  = "Properties for " + prop_type + " in "
                                              + searchLocation;
       } else {
           pageHeaderTitle.innerHTML  = "Properties for sale in " + searchLocation;
       }
       showErrorMessage("Please try changing your search to include a larger area or a wider price range or "
                    + "remove some filters.", true);
       return false; 
      } else {
        showErrorMessage("Please try changing your search to include a larger area.", true);
        switch(searchType) {
          case "1":
             pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
             break;
          case "2":
             pageHeaderTitle.innerHTML  = "Schools  in "+ searchLocation;
             break;
          case "3":   
             pageHeaderTitle.innerHTML  = "Local Information for "+ searchLocation;
             break;
          default:
             pageHeaderTitle.innerHTML  = "Amenities and Transport links  for "+ searchLocation;
             showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                           + "and transport links in your area.", true);
        }
       return false; 
      } 
      
     } else {
       
       if (checkIsNullOrEmpty(searchType)) {
       document.getElementById("mapview").style.borderTop = "1px solid #b5b5b5";
       if(isNumeric(searchType) == false) {
           //changes for the font style for error msg
           errorMsgDiv.className = "defaultmsgdetails";
           errorMsgDetails.className = "defaultmsg";
           errorImage.style.display = "none";
           showMap(false);  
           if(checkIsNullOrEmpty(queryStringPoi)) {
              showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                           + "and transport links in your area.", true);
              pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
              return false;
           }  else if(checkIsNullOrEmpty(queryStringSchools)){
              showErrorMessage("Please use the search box on the left hand side of the page to search for schools "
                           + "in your area.", true);
              pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
              return false;
           }  else if(checkIsNullOrEmpty(queryStringLocalInfo)) {
              showErrorMessage("Please use the search box on the left hand side of the page to search for "
                            + "local information in your area.", true);
              pageHeaderTitle.innerHTML  = "Search for local information with MSN Local";
              return false;
           }  else {
              showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                            + "and transport links in your area.", true);
              pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
              return false;
           }
           } else {
                if(searchType == 6) {
                     //changes for the font style for error msg
                     errorMsgDiv.className = "defaultmsgdetails";
                     errorMsgDetails.className = "defaultmsg";
                     errorImage.style.display = "none";
                     showMap(false);  
                     var schoolId = getQueryStringValue("schoolid");
                     if ((!checkIsNullOrEmpty(schoolId)) && ( !checkIsNullOrEmpty(queryStringPoi))) {
                       pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
                       showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                                    + "and transport links in your area.", true);
                       return false;
                     }
                } else if(searchType == 3)  {
                   if(!( checkIsNullOrEmpty(queryStringOverlays) || checkIsNullOrEmpty(queryStringLocalInfo))) {
                       showMap(false);  
                       showErrorMessage("Please use the search box on the left hand side of the page to search for "
                            + "local information in your area.", true);
                       pageHeaderTitle.innerHTML  = "Search for local information with MSN Local";
                       return false;
                   } else if(checkIsNullOrEmpty(queryStringOverlays) ) {
                     if(queryStringOverlays != "crime" && queryStringOverlays !="constituencies") {
                       showMap(false);  
                       showErrorMessage("Please use the search box on the left hand side of the page to search for "
                            + "local information in your area.", true);
                       pageHeaderTitle.innerHTML  = "Search for local information with MSN Local";
                       return false;
                     }
                   }
               }  else if(searchType == 1)  {
                   if(!( checkIsNullOrEmpty(queryStringPoi) || checkIsNullOrEmpty(queryStringBusinessCategory))) {
                       showMap(false);  
                        showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                           + "and transport links in your area.", true);
                        pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
                       return false;
                   }
               }  else if(searchType == 2)  {
                   if(!checkIsNullOrEmpty(queryStringSchools)) {
                       showMap(false);  
                       showErrorMessage("Please use the search box on the left hand side of the page to search for schools "
                           + "in your area.", true);
                       pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
                       return false;
                   }
               } else {
                   //changes for the font style for error msg
                   errorMsgDiv.className = "defaultmsgdetails";
                   errorMsgDetails.className = "defaultmsg";
                   errorImage.style.display = "none";
                   showMap(false);  
                   if(checkIsNullOrEmpty(queryStringPoi)) {
                      showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                                   + "and transport links in your area.", true);
                      pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
                      return false;
                   }  else if(checkIsNullOrEmpty(queryStringSchools)){
                      showErrorMessage("Please use the search box on the left hand side of the page to search for schools "
                                   + "in your area.", true);
                      pageHeaderTitle.innerHTML  = "Search for schools with MSN Local";
                      return false;
                   }  else if(checkIsNullOrEmpty(queryStringLocalInfo)) {
                      showErrorMessage("Please use the search box on the left hand side of the page to search for "
                                    + "local information in your area.", true);
                      pageHeaderTitle.innerHTML  = "Search for local information with MSN Local";
                      return false;
                   }  else {
                      showErrorMessage("Please use the search box on the left hand side of the page to search for amenities "
                                    + "and transport links in your area.", true);
                      pageHeaderTitle.innerHTML  = "Search for amenities and transport links with MSN Local";
                      return false;
                   }
               }  
           }
         }//end of the search type check
     }//end of else
   }//end of outer else statement
   return true;
}

/* Method used for replacing the query string value of map with empty */
 function RemoveQueryStringMapValue(QueryString)  {
   // add the current  map properties in the url
   var newQueryString = '';
   //check if already contains map query string in thr current url
   if (QueryString.indexOf('&map') > -1)  {
       var locArray = new Array();
       locArray = QueryString.split('&');
       var totalValues = locArray.length;
       for (i=0; i < totalValues; i++) {
           if (locArray[i].indexOf('map') > -1) {
            locArray[i] = "";
           } 
            // check to see if this is the start of the QueryString
            if (locArray[i].indexOf('?') == -1) {
              if(locArray[i]!="")
                newQueryString = newQueryString + '&' + locArray[i];
            } else {
                newQueryString = locArray[i];
            }
    }
  }
  return newQueryString;
}  

/* Method used to search the amenities with virtaul earth 
   web services
*/
function searchAmenitiesWithVE() {
    var amenitiesOptions  = '';
     //search for virtual earth pois
     for (var key in VEOverlayKeys) {
        var el = document.getElementById('show_' + key);
        if (el) {
            if (el.checked) {
                amenitiesOptions += key +'|';
                handleClusteringForVEMarkers(VEOverlayKeys[key].groupName);
            }
        }
    }  
    if(amenitiesOptions != '')     {
        amenitiesOptions =  amenitiesOptions.substring(0,amenitiesOptions.length-1);
        IsVEAmenitiesResultLoaded = false;
        loadingStatus(true);
        var qStringValues = "amenities="+escape(amenitiesOptions) +"&location="+ searchLocation +"&search=1";
        var ajaxRequest = new ajaxObject(VEServerScriptPageUrl);
        var individualResultSet = { supermarkets: [],pubs: [],localShops: [],cinemas: [],gyms: [] };
        ajaxRequest.callback = function(JsonString)  {
            if (checkIsNullOrEmpty(JsonString))  {
               try {
                    var results = eval('(' + JsonString + ')');
                    var totalResults = results.BusinessResult.length;
                    
                    //add the pointer reference for the performance tuning
                    var createBusinessSearchMarkers = createLocalAmenitiesMarkers;
                    for(var i=0;i < totalResults; i++) {
                        var html = createBusinessSearchMarkers(results.BusinessResult[i])
                        var point = new MMLocation(new MMLatLon(results.BusinessResult[i].Lat,results.BusinessResult[i].Lon));
                        var key =results.BusinessResult[i].Key;
                        var marker = mapviewer.createMarker(point, { 'icon': VEOverlayKeys[key].icon });
                        marker.setInfoBoxContent('<p>' + html + '<' + '/p>', { className: 'popupInfobox' });
                        individualResultSet[key].push(marker);
                    }
                    for (var key in individualResultSet) {
                        VEOverlayKeys[key].results = individualResultSet[key];
                    }
                   
               }catch(err){} 
            }
            IsVEAmenitiesResultLoaded = true;
            loadingStatus(false);
        }
        ajaxRequest.update(qStringValues);  
    }  
}
