


var searchResultsPropertyMap = {
    mapContainerID:null,
    mapID:null,
    map:null,
    pushPinLatLong:null,
    propId:SW.tools.Url.getParameter(document.location.href,"propertyID"),
    localeCode:null,
    propertyName:null,
    latitude:null,
    longitude:null,
    streetAddress1:null,
    city:null,
    stateName:null,
    stateCode:null,
    countryName:null,
    countryCode:null,
    zipCode:null,
    isChineseMap:null,
    thumbnailURL:null,
    propertyZoom:null,
    initialize:function(){
        this.mapHelper = SW.widget.virtualEarth.initializeMap(this.mapID);
        this.mapHelper.setLabels({
            road:'Road',
            aerial:'Aerial',
            traffic:'Traffic',
            label:'Labels',
            birdsEye:"Bird's Eye",
            street:'Street',
            hideControls:'Hide the view control',
            trafficLegend:"Traffic isn't available in bird's eye view",
             showControls:'Show the view control',
            zoomInForTraffic:"Zoom in for Traffic",
            zoomOutForTraffic:"Zoom out for Traffic"

        });
        <!--this.mapHelper.map.LoadMap();-->
        <!--this.loadMap();-->
    },

    addPushPin:  function(htmlBlock) {
        var that = searchResultsPropertyMap;
        pushPin = new VEShape(VEShapeType.Pushpin, pushPinLatLong);
        pushPin.SetTitle("<a href=\'/" + that.URLSkinName +  "/property/overview/index.html?propertyID=" + this.propId + "\'>" + this.propertyName + "</a>");
        pushPin.SetCustomIcon("<div class='pushPin'></div>");
        pushPin.SetLineColor(new VEColor(0,150,100,1.0));
        pushPin.SetFillColor(new VEColor(0,100,150,0.5));
        pushPin.SetDescription(htmlBlock);
        pushPin.SetPoints(pushPinLatLong);
        pushPin.Show();
        this.mapHelper.map.AddShape(pushPin);
    },

    loadMap:function(mapid){
        var that = searchResultsPropertyMap;
        if(SW.tools.getSkinName() == 'preferredguest') {
            that.URLSkinName = SW.tools.getSkinName();
        } else {
            that.URLSkinName = that.brandName;
        }
        if(yuiDom.getChildren(yuiDom.get('map'+ mapid)).length == '0') {
            pushPinLatLong = new VELatLong(this.latitude,this.longitude);
            this.mapHelper.setLatLong(pushPinLatLong);
            this.mapHelper.map.HideDashboard();
            this.mapHelper.isChineseMap = this.isChineseMap;
            if (this.propertyZoom == null) {
                this.propertyZoom = 15;
            }
            this.mapHelper.countryCode = this.countryCode;
            this.mapHelper.map.LoadMap(pushPinLatLong,this.mapHelper.getMicrosoftZoom(this.propertyZoom) ,VEMapStyle.Road ,false);
            if (this.localeCode != 'en_US') {
                this.mapHelper.map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
            }
            var mapContainer = document.getElementById(this.mapContainerID);
            var dashboard = this.mapHelper.createCustomDashboard('dashboard' + this.mapID);
            // This is coz map controls are by default minimized in property maps in SPG search results page

            mapContainer.appendChild(dashboard);
//            Initialize rotate was throwing a javascript errors in IE7 for property ditu maps, so added this condition, this is a temporary solution
            if(this.localeCode != 'zh_CN' && this.countryCode != 'CN') {
                this.mapHelper.initializeRotate();
            }
            yuiDom.replaceClass(dashboard,"road","collapse");
            this.mapHelper.labelsChecked = 'true';
            var str = "<div class=\"thumbnailImg\"><img src=\"" + this.thumbnailURL +  "\"/></div><div class=\"address\">" + this.streetAddress1 + ', ' + this.city + ', ' + this.stateCode + ' ' + this.zipCode + ' ' + this.countryName;
            if(this.roomsFrom != null) {
                str += "<div class=\"roomsFrom\">" + this.roomsFrom + "</div>" + "<br/>";
            }
            <!--Add Book Now Link only for Active Properties-->
            if (this.propertyStatus == 'Active') {
                str += "<div class=\"bookNow\"><a href=\"/" +  that.URLSkinName + "/search/preDecider.html?propertyID=" + this.propId + "\">Book Now &gt;</a></div>";
            }
            str += "</div>";
            str += "<div class=\"clearDiv\"></div></div>";
            str += "<div class=\"bottomArea\">";
            str += "<a href=\"/" +  that.URLSkinName + "/property/area/directions.html?propertyID=" + this.propId + "\">Directions</a><br/>";
            str += "Zoom to: <a class=\"zoomInType\" onclick=\"SW.widget.virtualEarth.getMap('"+ this.mapID + "').setZoomtoLinks('" + this.latitude + "','" + this.longitude + "','16')\";>Street</a> | <a class=\"zoomInType\" onclick=\"SW.widget.virtualEarth.getMap('"+ this.mapID + "').setZoomtoLinks('" + this.latitude + "','" + this.longitude + "','11');\">City</a> | <a class=\"zoomInType\" onclick=\"SW.widget.virtualEarth.getMap('"+ this.mapID + "').setZoomtoLinks('" + this.latitude + "','" + this.longitude + "','6');\">Region</a></div>";

            this.addPushPin(str);
       }
    }
};

var searchResultsMap = {
    page:SW.tools.Url.getParameter(document.location.href,"propertyID"),
    mapContainerID:null,
    latLongArray:null,
    VEArray:null,
    mapID:null,
    map:null,
    mapHelper:null,
    isMapLoaded:false,
    localeCode:null,
    propertyName:null,
    latitude:null,
    longitude:null,
    streetAddress1:null,
    streetAddress2:null,
    city:null,
    stateName:null,
    stateCode:null,
    countryName:null,
    countryCode:null,
    zipCode:null,
    isChineseMap:null,
    thumbnailURL:null,
    propertyZoom:null,
    baseLayer:new VEShapeLayer(),
    clusterLayer:new VEShapeLayer(),
    VEArray:new Array(),
    zoomLimit:'15',
    gridSizeLimit:'80',
    maxDiscription:'100',
    initialize:function(){
        var that = searchResultsMap;

        that.mapHelper = SW.widget.virtualEarth.initializeMap(this.mapID);
        that.mapHelper.setLabels({
            road:'Road',
            aerial:'Aerial',
            traffic:'Traffic',
            label:'Labels',
            birdsEye:"Bird's Eye",
            street:'Street',
            trafficLegend:"Traffic isn't available in bird's eye view",
             hideControls:'Hide the view control',
            trafficLegend:"Traffic isn't available in bird's eye view",
             showControls:'Show the view control',
            zoomInForTraffic:"Zoom in for Traffic",
            zoomOutForTraffic:"Zoom out for Traffic"
        });
        // Checking the country code from both requests as SPG has countryCode and other brands have country as URL param for search results page
        if(SW.tools.Url.getParameter(document.location.href,"countryCode") != null) {
            this.mapHelper.countryCode = SW.tools.Url.getParameter(document.location.href,"countryCode");
            this.countryCode = SW.tools.Url.getParameter(document.location.href,"countryCode");
        } else if(SW.tools.Url.getParameter(document.location.href,"country") != null) {
            this.mapHelper.countryCode = SW.tools.Url.getParameter(document.location.href,"country");
            this.countryCode = SW.tools.Url.getParameter(document.location.href,"country");
        }
    },

    addPushPin:  function(htmlBlock,pushPin, layer) {
        pushPin.SetCustomIcon("<div class='pushPin'></div>");
        pushPin.SetLineColor(new VEColor(0,150,100,1.0));
        pushPin.SetFillColor(new VEColor(0,100,150,0.5));
        pushPin.SetDescription(htmlBlock);
        pushPin.Show();
        layer.AddShape(pushPin);
    },

    loadMap:function(mapid){
        var that = searchResultsMap;
        that.mapHelper.map.LoadMap();
        that.isMapLoaded=true;
        that.mapHelper.currentMapObj = searchResultsMap;
        that.mapHelper.map.HideDashboard();
        var mapContainer = document.getElementById(that.mapContainerID);
        var dashboard = that.mapHelper.createCustomDashboard('dashboard' + that.mapID);
        mapContainer.appendChild(dashboard);
        that.mapHelper.initializeRotate();
        that.mapHelper.labelsChecked = 'true';
        that.plotPushPins();
        that.baseLayer.Hide();
        that.mapHelper.map.AddShapeLayer(that.clusterLayer);
        that.mapHelper.map.AttachEvent("onclick",that.breakCluster);
        that.mapHelper.map.AttachEvent("onchangeview", that.cluster);
        that.mapHelper.map.AttachEvent("onchangemapstyle", that.cluster);
        yuiEvent.addListener(that.mapHelper.birdsEyeTabObj,"click", function() {
            yuiDom.addClass(yuiDom.get('birdsEyeNote'),'show');
        });
        yuiEvent.addListener(that.mapHelper.roadTab,"click", function() {
            yuiDom.removeClass(yuiDom.get('birdsEyeNote'),'show');
        });
        yuiEvent.addListener(that.mapHelper.aerialTab,"click", function() {
            yuiDom.removeClass(yuiDom.get('birdsEyeNote'),'show');
        });
    },
    // This method is created for resetting propertyContentObject sorting for westin and SPG new sorting mechanisms.
    resetPropertyContentArray: function() {
        var that = searchResultsMap;
        var activePropertiesArray = new Array();
        var tempArray = new Array();
        if(SW.tools.getSkinName() == 'westin' || SW.tools.getSkinName() == 'preferredguest') {
            activePropertiesArray = SW.widget.SearchResults.PropertyManager.getActiveProperties();
            activePropertiesArray.forEach(function(property) {
                tempArray.push(that.getPropertyContentObj(property.propertyId));
             });
             that.propertyContentArray = tempArray;
             if(that.isMapLoaded) {
                that.plotPushPins();
                that.cluster();
            }
        }
    },
    plotPushPins:function() {
          var that =searchResultsMap;
          that.VEArray = new Array();
          that.baseLayer.DeleteAllShapes();
          that.clusterLayer.DeleteAllShapes();
          this.URLSkinName = null;
        for (i = 0; i < that.propertyContentArray.length; i++) {
            if(SW.tools.getSkinName() == 'preferredguest') {
                this.URLSkinName =  SW.tools.getSkinName();
            } else {
                this.URLSkinName = that.propertyContentArray[i].brandName;
            }
            this.localeCode = that.propertyContentArray[i].localeCode;
            that.propertyLatLong = new VELatLong(that.propertyContentArray[i].latitude,that.propertyContentArray[i].longitude);
            that.VEArray.push(that.propertyLatLong);
            pushPin = new VEShape(VEShapeType.Pushpin, that.propertyLatLong);
            var str = "<div class=\"thumbnailImg\"><img src=\"" + that.propertyContentArray[i].thumbnailURL +  "\"/></div><div class=\"address\">" + that.propertyContentArray[i].streetAddress1 + ', ' + that.propertyContentArray[i].city + ', ' + that.propertyContentArray[i].stateCode + ' ' + that.propertyContentArray[i].zipCode + ' ' + that.propertyContentArray[i].countryName;
            if(this.localeCode == 'zh_CN'){
                str = "<div class=\"thumbnailImg\"><img src=\"" + that.propertyContentArray[i].thumbnailURL +  "\"/></div><div class=\"address\">" +that.propertyContentArray[i].countryName +', '+ that.propertyContentArray[i].stateName + ', '+ that.propertyContentArray[i].city;
                if(that.propertyContentArray[i].streetAddress1 !=null && that.propertyContentArray[i].streetAddress1 != '')
                    str+=', '+ that.propertyContentArray[i].streetAddress1;
                if(that.propertyContentArray[i].streetAddress2 !=null && that.propertyContentArray[i].streetAddress2 != '')
                   str+=', '+ that.propertyContentArray[i].streetAddress2 ;
               if(that.propertyContentArray[i].zipCode!=null && that.propertyContentArray[i].zipCode != '')           
                str+=', '  + "Postal Code " +that.propertyContentArray[i].zipCode + ' '  ;
            }
            if (this.localeCode == 'ja_JP'){
                str = "<div class=\"thumbnailImg123\"><img src=\"" + that.propertyContentArray[i].thumbnailURL +  "\"/></div><div class=\"address\">" + that.propertyContentArray[i].countryName ;
                if(that.propertyContentArray[i].zipCode!=null &&that.propertyContentArray[i].zipCode!="")
                   str+=', ' + that.propertyContentArray[i].zipCode;
                str+=', ' + that.propertyContentArray[i].stateName +', ' + that.propertyContentArray[i].city   ;
                if(that.propertyContentArray[i].streetAddress1 !=null && that.propertyContentArray[i].streetAddress1 != '')
                    str+=', '+ that.propertyContentArray[i].streetAddress1+ ' ';
                if(that.propertyContentArray[i].streetAddress2 !=null && that.propertyContentArray[i].streetAddress2 != '')
                   str+=', '+ that.propertyContentArray[i].streetAddress2+ ' ' ;
           }
            // Adding Rooms From Average Rate
//            if(Math.round(that.propertyContentArray[i].averageRate) > 0) {
            if(that.propertyContentArray[i].roomsFrom != null) {
                str += "<div class=\"roomsFrom\">" + that.propertyContentArray[i].roomsFrom + "</div>" + "<br/>";
            }
//            }
            <!--Add Book Now Link only for Active Properties-->
            if (that.propertyContentArray[i].propertyStatus == 'Active' &&  that.propertyContentArray[i].bookNowURL != null) {
                str += "<div class=\"bookNow\"><a href=\"" + that.propertyContentArray[i].bookNowURL +  "\">Book Now &gt;</a></div>";
            }

            str += "</div>";
            str += "<div class=\"clearDiv\"></div></div>";
            str += "<div class=\"bottomArea\">";
            str += "<a href=\"/" + this.URLSkinName + "/property/area/directions.html?propertyID=" + that.propertyContentArray[i].propId + "\">Directions</a><br/>";
            str += "<span class='zoomToLinks'>Zoom to: <a class=\"zoomInType\" href=\"javascript:SW.widget.virtualEarth.getMap('searchResultsMap').setZoomtoLinks('" + that.propertyContentArray[i].latitude + "','" + that.propertyContentArray[i].longitude + "','16')\";>Street</a> | <a class=\"zoomInType\" href=\"javascript:SW.widget.virtualEarth.getMap('searchResultsMap').setZoomtoLinks('" + that.propertyContentArray[i].latitude + "','" + that.propertyContentArray[i].longitude + "','11');\">City</a> | <a class=\"zoomInType\" href=\"javascript:SW.widget.virtualEarth.getMap('searchResultsMap').setZoomtoLinks('" + that.propertyContentArray[i].latitude + "','" + that.propertyContentArray[i].longitude + "','6');\">Region</a></div></span>";
            if(SW.tools.getSkinName() != 'corporate') {
                pushPin.SetTitle("<a href=\'/" + this.URLSkinName +  "/property/overview/index.html?propertyID=" + that.propertyContentArray[i].propId + "\'>" + that.propertyContentArray[i].propertyName + "</a>");
            } else {
                pushPin.SetTitle("<a href=\'/" + that.propertyContentArray[i].brandName +  "/property/overview/index.html?propertyID=" + that.propertyContentArray[i].propId + "\'>" + that.propertyContentArray[i].propertyName + "</a>");
            }
            that.addPushPin(str, pushPin, that.baseLayer);
        }
        // Store mapStyle to not reload the data when style changes
        that.mapStyle = that.mapHelper.map.GetMapStyle();
        that.mapHelper.map.SetMapView(that.VEArray);

        // Events caught from map changes
        that.cluster();
    },
   cluster:function()  {
         var that = searchResultsMap;

        // Change gridSize based on the zoom level
        if(that.mapHelper.map.GetZoomLevel() > 12) {
            that.gridSize = that.gridSizeLimit - (4*(that.mapHelper.map.GetZoomLevel()/2));
        } else {
            that.gridSize = "80";
        }

    // Check to see whether event is due to map style change
            if(that.mapStyle != that.mapHelper.map.GetMapStyle())
            {
               // Store the current map style
               that.mapStyle = that.mapHelper.map.GetMapStyle();
               return true;
            }

            // Remove all pins from the cluster layer
            that.clusterLayer.DeleteAllShapes();

            // Calculate the size, in pixels, of the map
            var mapView = that.mapHelper.map.GetMapView();
            var bottomRight = that.mapHelper.map.LatLongToPixel(mapView.BottomRightLatLong);
            that.mapWidth = parseInt(Math.ceil(bottomRight.x));
            that.mapHeight = parseInt(Math.ceil(bottomRight.y));

            // Break the map up into a grid
            that.numXCells = parseInt(Math.ceil(that.mapWidth / that.gridSize));
            that.numYCells = parseInt(Math.ceil(that.mapHeight / that.gridSize));

            // Create an array to store all the grid data
            that.gridCells = new Array(that.numXCells*that.numYCells);

            // Initialize the grid array with a structure to store all the data
            for(var i = 0; i < that.numXCells; i++)
            {
               for(var j = 0; j < that.numYCells;j++)
               {
                  that.gridCells[i+j*that.numXCells]={pushPinsArray:new Array(), title:"", description:"", length:0};
               }
            }

            // Iterate through the shapes in the base layer
            for(var cnt = 0; cnt < that.baseLayer.GetShapeCount(); cnt++)
            {
               // Convert the shapes latlong to a pixel location
               var shape = that.baseLayer.GetShapeByIndex(cnt);

               var latLong = (shape.GetPoints())[0];
               var pixel = that.mapHelper.map.LatLongToPixel(latLong);
               var xPixel = pixel.x;
               var yPixel = pixel.y;

               // Check to see whether the shape is within the bounds of the viewable map                                 i
               if(that.mapWidth >= xPixel && that.mapHeight >= yPixel && xPixel >= 0 && yPixel >= 0)
               {
                  // Calculate the grid position on the map of where the shape is located
                  var i = Math.floor(xPixel/that.gridSize);
                  var j = Math.floor(yPixel/that.gridSize);

                  // Calculate the grid location in the array
                  var key = i+j*that.numXCells;

                  if(SW.tools.Url.getParameter(document.location.href,"page") != null) {
                         that.shapeIndex = parseInt(SW.tools.Url.getParameter(document.location.href,"page")) * 10 -9 + cnt ;
                    } else {
                        that.shapeIndex = cnt +1;
                    }


                  var shapesObj = {shapeID:shape.GetID(),shapeTitle:shape.GetTitle(),latitude:shape.GetPoints()[0].Latitude,longitude:shape.GetPoints()[0].Longitude,shapeIndex:that.shapeIndex };
                  // Define a standard way to display an individual shape
                  if(that.gridCells[key].length == 0)
                  {
                     that.gridCells[key].latlong = latLong;
                     that.gridCells[key].title = shape.GetTitle();
                     if(that.mapHelper.map.GetMapStyle() != 'b') {
                        that.gridCells[key].description = shape.GetDescription() + '<style type="text/css">.zoomToLinks {display:block;}</style>';
                     } else {
                        that.gridCells[key].description = shape.GetDescription() + '<style type="text/css">.zoomToLinks {display:none;}</style>';
                     }
                  }
                  that.gridCells[key].pushPinsArray.push(shapesObj);
                  that.gridCells[key].length++;

                  // Allow the contents of all the points in a grid to be
                  // displayed in the infobox of the shape if the user is zoomed
                  // into a predefined limt. This is done to prevent massive
                  // amounts of data from being displayed inside of the infobox.
                  if(that.gridCells[key].length > 1)
                  {
                     if(that.gridCells[key].length == 2)
                     {
                        that.gridCells[key].description = "<br /><b>" + that.gridCells[key].title +
                           "</b><br />" + that.gridCells[key].description + "<br /><hr />";
                     }

                     that.gridCells[key].title = that.gridCells[key].length + " " + 'results were found. Click to zoom.';
                     that.gridCells[key].description = that.gridCells[key].description +
                        "<b>" + shape.GetTitle() + "</b><br />" + shape.GetDescription() + "<br /><hr />";
                    }


                 }
                }
 // Iterate through the clustered data in the grid array
            for(var key = 0; key < that.gridCells.length; key++)
            {
               that.gridCells[key] = that.gridCells[key];

               // Set the default infobox message for clustered points that are zoomed out
               if(that.gridCells[key].length > 1)

               {
                  that.gridCells[key].title = that.gridCells[key].length + " " + 'results were found. Click to zoom.';
                  that.gridCells[key].description = "";
               }

               // Add a shape to the cluster layer
               if(that.gridCells[key].length > 0)
               {
                  var clusterShape = new VEShape(VEShapeType.Pushpin, that.gridCells[key].latlong);
                  clusterShape.SetTitle(that.gridCells[key].title);
                  clusterShape.SetDescription(that.gridCells[key].description);

                  if(that.gridCells[key].length > 5) {
                     clusterShape.SetCustomIcon("<span class='clusterPushPin5'>" +  that.gridCells[key].pushPinsArray[0].shapeIndex + "</span>");
                 } else {
//                         clusterShape.SetCustomIcon("<div class='clusterPushPin" +that.gridCells[key].length + "'><div class='pushPinIndex'>" +  that.gridCells[key].pushPinsArray[0].shapeIndex + "</div></div>");
                            clusterShape.SetCustomIcon("<span class='clusterPushPin" +that.gridCells[key].length + "'>"  +  that.gridCells[key].pushPinsArray[0].shapeIndex + "</span>");
                 }
                  that.clusterLayer.AddShape(clusterShape);
               }
            }
            },
            breakCluster:function(e) {
                var that = searchResultsMap;
                var clickedShape = that.mapHelper.map.GetShapeByID(e.elementID);
                if(clickedShape != null) {
                    var clickedLatLong = (clickedShape.GetPoints())[0];
                    var clickedPixel = that.mapHelper.map.LatLongToPixel(clickedLatLong);
                    clickedxPixel = clickedPixel.x;
                    clickedyPixel = clickedPixel.y;
                    if(that.mapWidth >= clickedxPixel && that.mapHeight >= clickedyPixel && clickedxPixel >= 0 && clickedyPixel >= 0) {
                            var i = Math.floor(clickedxPixel/that.gridSize);
                            var j = Math.floor(clickedyPixel/that.gridSize);

                            // Calculate the grid location in the array
                            var key = i+j*that.numXCells;
                            var GridPushPins = that.gridCells[key].pushPinsArray;

                            var clusteredPushPins = new Array();
                            if(GridPushPins.length > 1 ) {
                                for(i =0; i< GridPushPins.length;i++) {
                                    clusteredPushPins.push(new VELatLong(GridPushPins[i].latitude,GridPushPins[i].longitude));
                                }
                                that.mapHelper.map.SetMapView(clusteredPushPins);
                            }
                    }
                }
            },
            findALocation:function() {
                var that = searchResultsMap;
                SW.domWidget.inputLabels.removeLabel(yuiDom.get("customAddress"));
                if(yuiDom.get('addLocationForm').customAddress.value  != '') {
                    searchResultsMap.mapHelper.map.Find(null,yuiDom.get('addLocationForm').customAddress.value, null, null, null, null, null, null, false, false, searchResultsMap.addCustomAddress);
                } else {
                 yuiDom.get('addLocationError').innerHTML  ="Please submit an airport code, address or zip code.";
                 yuiDom.get('addLocationError').style.display="block";
                }
               return false;
            },
             addCustomAddress:function (veShapeLayer, veFindResult, vePlace, moreResults, errorMsg) {
                var that = searchResultsMap;
                document.getElementById('addLocationError').style.display = "none";
                if (vePlace != null) {
                    var customPlace = null;
                    if (vePlace.length > 1) {
                        var results = "More than one location was found. Please select the location you were looking for:<br/>";
                        var highConfidenceMatches = new Array();
                        for (x = 0; x < vePlace.length; x++) {
                            if (vePlace[x].MatchConfidence == VEMatchConfidence.High) highConfidenceMatches.push(vePlace[x]);
                            else results += "<a href=\"javascript:searchResultsMap.mapHelper.map.Find(null,'" + vePlace[x].Name + "', null, null, null, null, null, null, false, false, searchResultsMap.addCustomAddress)\">" + vePlace[x].Name + "</a><br/>";
                        }
                        if (highConfidenceMatches.length == 0) {
                            document.getElementById('addLocationError').innerHTML = results;
                            document.getElementById('addLocationError').style.display = "block";
                        } else if (highConfidenceMatches.length == 1) {
                            customPlace = highConfidenceMatches[0];
                        }
                    } else if (vePlace.length == 1) {
                        customPlace = vePlace[0];
                    }
                    if (customPlace != null) {
                        var shape = new VEShape(VEShapeType.Pushpin, customPlace.LatLong);
                        shape.SetTitle(customPlace.Name);
                        shape.SetCustomIcon("<div class='pushPinCustom'></div>");
                        searchResultsMap.mapHelper.map.AddShape(shape);
                        searchResultsMap.VEArray.push(customPlace.LatLong);
                        if(that.mapHelper.map.GetMapStyle() != 'b') {
                            searchResultsMap.mapHelper.map.SetMapView(searchResultsMap.VEArray);
                        }
                    }
                } else {
                    yuiDom.get('addLocationError').innerHTML = "We’re sorry. We are unable to find the address you entered. Please revise the address and search again.";
                    yuiDom.get('addLocationError').style.display='block';
                    yuiDom.get('addLocationError').style.color='red';
                }
            },
            getPropertyContentObj:function(propID) {
                var that = searchResultsMap;
                this.foundProp = "false";
                for(index =0;index<propertyContentArray.length;index++) {

                    if(propID == propertyContentArray[index].propId) {
                        return propertyContentArray[index];
                        break;
                    }
                }
//                });
            }
        };

        SW.widget.virtualEarth.searchResultsMap = this.searchResultsMap;