﻿/*
'*********************************************************************************
'   ©2007 CamSoft Data Systems, Inc. (www.camsoftdata.com)
'---------------------------------------------------------------------------------
'   FILE NAME:      RealtyLogic.MapSearch.Map.js
'   DESCRIPTION:    AJAX/Javascript functions that support the rendering of the map 
'                   Reference: http://ajax.asp.net/docs/ClientReference/default.aspx
'---------------------------------------------------------------------------------
'   MODIFICATIONS/NOTES:
'   NAME                DATE            DESCRIPTION
'   Wayne Losavio       07/12/2007      initial development
'*********************************************************************************
*/
Type.registerNamespace("RealtyLogic.MapSearch");

var gridloaded = false;
var htmlgridoutput = '';
var notOver = true;
var boxClicked = false;
var boxClickedID = null;
var boxFeaturedID = null;
var currentmap = null;
var currentmapdata = null;

RealtyLogic.MapSearch.Map = function(service, mapArgs) {
    /// <summary>
    ///   The VE Map.
    ///   Supports load on demand
    /// </summary>
    /// <param name="service">The webservice to call for the map data.</param>
    /// <param name="mapArgs">The map initalization data.</param>

    this._service = service;
    this._mapArgs = mapArgs;
    
    this._map = null;
    this._pinID = 0;
    this._zoomlevel = 0;
    this._layer = null;
    this._poilayer = null;
    
    //popup specific
    this._PopupPrefix = "POPUP";
    this._currentpin = null;
    this._currentindex = 0;   
    
    //Birdseye - fix due to not lat/long data available
    this._MapBEyeCentre;  
    this._latoffset = 0.005;
    this._lonoffset = 0.01;    
    
    this.GetPinDataDelegate = null;
    this.PinHoverDelegate = null;
    
    this._init();
}

RealtyLogic.MapSearch.Map.prototype = {

    _init: function() {
        /// <summary>
        ///   Initializes the Map.
        /// </summary>      
        
        //setup map
        this._map = new VEMap(this._mapArgs.DivID);   
        
        //set the dashboard (navigation control) size
        this._map.SetDashboardSize(VEDashboardSize.Small);
         
        this._map.LoadMap(this._mapArgs.Center,this._mapArgs.Zoomlevel,this._mapArgs.Style,this._mapArgs.Fixed,this._mapArgs.Mode, false); 
        this._map.SetScaleBarDistanceUnit(this._mapArgs.Scale);
        this._poilayer = new VEShapeLayer();
        this._poilayer.SetTitle("POI");
        //this._layer = new VEShapeLayer();         
       // this._map.AddShapeLayer(this._layer);
        
        
       this.GetPinDataDelegate = Function.createDelegate(this, this._GetPinData);
       this._map.AttachEvent("onchangeview", this.GetPinDataDelegate);
            
        currentmap = this._map
                
        //Setup additional storage for shapes
        VEShape.prototype.Bounds = "";  
	    VEShape.prototype.Drawn = false;    
	    VEShape.prototype.Match = false;

        //get the data for the default view
        this._GetPinData();
    },
    
    _mouseOverHandler: function(e){
		    if (e.elementID && this._notOver){
		        mouseOverGridItem(e.elementID)
		        notOver = false;
		    }
		},
		
    _mouseOutHandler: function (e){
        if (e.elementID && !this._notOver){
            mouseOutGridItem(e.elementID)
            notOver = true;
        }
    },
    
    _GetPinData: function() {  
        /// <summary>
        ///   Get the latest map data from the web service.
        /// </summary>
            
        //encode the current map bounds
        var points = new Array();
        var zoom;
        var northwest;
        var southeast;
        
        var ListingType;
        var minSQFT;
        var minPrice;
        var maxPrice;
        var minBedrooms;
        var minBathrooms;
        var bSearchForOffices;
        var types;
        
        var SearchingDiv = $get('divSearching');
        SearchingDiv.style.display = '';
        
        var view = this._map.GetMapView();
        points.push(view.TopLeftLatLong);
        points.push(view.BottomRightLatLong);
            
        //get zoomlevel
        zoom = this._map.GetZoomLevel();
            
        if (this._zoomlevel != zoom) {
            //clear existing pins
            
            this._map.DeleteAllShapes();
            //this._layer.DeleteAllShapes();
            this._zoomlevel = zoom;
        }
        
        /*************************************/
        //assign Lat/Long values to map boundaries
        var view2 = this._map.GetMapView();
        var points2 = new Array();
            points2.push(view.TopLeftLatLong);
            points2.push(view.BottomRightLatLong);
            
        for(i = 0; i < points2.length; ++i) {
            var point1 = points2[0];
            var nwlat = point1.Latitude;
            var nwlng = point1.Longitude;
            
            var point2 = points2[1];
            var selat = point2.Latitude;
            var selng = point2.Longitude;
        } 
        //alert(nwlat + ' ' + nwlng + ' ' + selat + ' ' + selng);
        /*************************************/
        
        //set hidden values
        document.getElementById("hidNWLat").value = nwlat;
        document.getElementById("hidNWLong").value = nwlng;
        document.getElementById("hidSELat").value = selat;
        document.getElementById("hidSELong").value = selng;
        
        
        
        //Set search criteria
                
        ListingType = document.getElementById("hidPropertyType").value;
        minSQFT = document.getElementById("hidMinSquareFoot").value;
        minPrice = document.getElementById("hidMinPrice").value;
        maxPrice = document.getElementById("hidMaxPrice").value;
        minBedrooms = document.getElementById("hidMinBedrooms").value;
        minBathrooms = document.getElementById("hidMinBathrooms").value;
        
        
        //allow the grid to load from the code behind the first time thru
        //if (gridloaded = true) 
       // {
        //   document.getElementById("btnTrigger").click();
       // }
       
       bSearchForOffices = false
       types = "";
       if (document.forms[0].chkAmenities)
       {
        for (i = 0; i < document.forms[0].chkAmenities.length; i++)
        {
            if (document.forms[0].chkAmenities[i].checked) 
            {
                if (types != "")
                {
                    types += ",";
                }
                types += document.forms[0].chkAmenities[i].value;
            }
        }
       }
       if (document.forms[0].chkMapOffices)
       {
        if (document.forms[0].chkMapOffices.checked)
        {
            bSearchForOffices = true
        }
       }
       //chkAmenities
        
        //call Web Service, while passing in the Lat/Long viewable bounds
        this._service.GetMapPointsForSearch(nwlat, nwlng, selat, selng, zoom,ListingType,"", minSQFT, minPrice, maxPrice, minBedrooms, minBathrooms, bSearchForOffices,types,Function.createDelegate(this, this._OnMapDataSucceeded), Utility.OnFailed);

        //the grid loaded successfully; now allow AJAX to kick in
        gridloaded = true;
       
    },

    _OnMapDataSucceeded: function(results) {
        /// <summary>
        ///   Receive data for map.
        /// </summary>  
        /// <param name="result">The web service result object</param>  
        
        var overLimitDiv = $get('divMessage');
        var SearchingDiv = $get('divSearching');
        var countSpan = $get('spanResultCount');
        var count = 0;
        var bdisplaygrid = false
        var bhaspoi = false
        var surroundingprop = false;
        var HTMLoutput;
        var rowclass;
        var devResultGrid = $get('devResultGrid');
        HTMLoutput = "";
        var rowclass = "odd";
        if (document.getElementById("devResultGrid"))
        {
        bdisplaygrid = true;
        devResultGrid.innerText = "";
        devResultGrid.innerHTML = "";
        }
        surroundingprop = true;
        SearchingDiv.style.display = '';

        if (results.substring(0,1) == 'L') //don't let the user go over 500 pins 
        {
            
            SearchingDiv.style.display = 'none';
            overLimitDiv.style.display = '';
            
            //alert(countSpan);
            var resultcount = results.replace("L","")
            count = parseInt(resultcount);
            
            if(isNaN(count))
            {
                count = 0;
                countSpan.innerText = 0;
            }
            else 
            {
                countSpan.innerText = count;
            }
            
        }
        else
        {   
            overLimitDiv.style.display = 'none';
            SearchingDiv.style.display = '';
            
            //create the pushpins
            var mainresult = results.split("|")
            
            //set the count
            for(x = 1; x < 2; x++)
            {
               count = parseInt(mainresult[0]);
               
               //make sure this gets set to zero if necessary
               if(isNaN(count))
                {
                    count = 0;
                    countSpan.innerText = 0;
                }
                else 
                {
                    countSpan.innerText = count;
                }
            }
            
            

             for(x = 2; x < mainresult.length; x++)
             {
                //alert(mainresult[x]);
                
                var pointresult = mainresult[x].split("~")
                
                   /*
                        pointresult[0] = Type
                        pointresult[1] = ID
                        pointresult[2] = Latitude
                        pointresult[3] = Longitude
                   */ 
                    
                   var type = pointresult[0];
                   var intid = pointresult[1]; 
                   var latitude = parseFloat(pointresult[2]);
                   var longitude = parseFloat(pointresult[3]);
                   
                   var location = new VELatLong(latitude, longitude);
                   var newShape = new VEShape(VEShapeType.Pushpin, location);
                   var canprint = document.getElementById("hidPrint").value;
                   var customicon;
                   
                   if (type == 'L') // Listing
                   {
                       var itemindex = pointresult[5];
                       var status = pointresult[6];
                       var multiples = pointresult[7];
                       var mlsid = pointresult[8];
                       var title = pointresult[9];
                       var city = pointresult[10];
                       var bedrooms = pointresult[11];
                       var bathrooms = pointresult[12];
                       var livingarea = pointresult[13]
                       var listingprice = pointresult[14];
                       var closeprice = pointresult[15];
                       var imagepath = pointresult[16];
                       var datasourceid = pointresult[17];
                       var propertycount = pointresult[18];
                       var state = pointresult[19];
                       var zipcode = pointresult[20];
                       var showIdx = pointresult[21];
                       var idxLogo = pointresult[22];
                       var idxMsg = pointresult[23];
                       var pricePerSqFt = pointresult[24];
                       
                       //determine which icon to display, based on Status
                           if (status == 'A')
                           {
                             if (multiples == 'M')
                             {
                                 customicon = "<div class='pinStyleActiveM'><img src='images/house_icon6.gif'/></div>";
                                 newShape.SetTitle(BuildInfoBoxMultiple(intid, title, city, listingprice, imagepath, bedrooms, bathrooms, livingarea, mlsid, datasourceid,propertycount));
                             }
                             else
                             {
                                 customicon = "<div class='pinStyleActive'><img src='images/house_icon5.gif'/></div>";
                                 newShape.SetTitle(BuildInfoBoxSingle(intid, title, city, listingprice, imagepath, bedrooms, bathrooms, livingarea, mlsid, datasourceid));
                             }
                           }
                           else if (status == 'S')
                           {
                                 if (multiples == 'M')
                                 {
                                     customicon = "<div class='pinStyleSoldM'><img src='images/house_icon7.gif'/></div>";
                                     //newShape.SetTitle("<span style='color:red;font-weight:bold;text-align:center;'>**SOLD**</span><br>" + pointresult[3]);
                                     newShape.SetTitle("<table style='width:100%'><tr><td style='color:red;font-weight:bold;text-align:center;'>**SOLD**</td></tr></table>" + BuildInfoBoxMultiple(intid, title, city, closeprice, imagepath, bedrooms, bathrooms, livingarea, mlsid, datasourceid,propertycount));    
                                 }
                                 else
                                 {
                                     customicon = "<div class='pinStyleSold'><img src='images/house_icon_sold.gif'/></div>";
                                     //newShape.SetTitle("<span style='color:red;font-weight:bold;text-align:center;'>**SOLD**</span><br>" + pointresult[3]);
                                     newShape.SetTitle("<table style='width:100%'><tr><td style='color:red;font-weight:bold;text-align:center;'>**SOLD**</td></tr></table>" + BuildInfoBoxSingle(intid, title, city, closeprice, imagepath, bedrooms, bathrooms, livingarea, mlsid, datasourceid));
                                 }
                           }
                      
                                               
                       newShape.SetCustomIcon(customicon); 
                       
                       this._map.AddShape(newShape);
                        
                        
                        if (itemindex == 0) //Store featured property ID for use later
                        {
                            boxFeaturedID = newShape.GetID();
                        }
                        
                       if (bdisplaygrid)
                       {
                         //Add items to resultgrid if surroundingprop is true
                          if (surroundingprop)
                           {
                           if (itemindex > 0)
                           {
                               if (HTMLoutput == "") 
                                {
                                HTMLoutput += "<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"100%\">";
                                HTMLoutput += "<tr style=\"font-weight: bold;\" class=\"headerbox\">";
                                HTMLoutput += "<td align=\"right\" width=\"10\">&nbsp;#</td>";
                                HTMLoutput += "<td width=\"75\">&nbsp;Photo</td>";
                                HTMLoutput += "<td>Street</td>";
                                HTMLoutput += "<td width=\"120\">City</td>";
                                HTMLoutput += "<td width=\"75\">Living<br/>Area</td>";
                                HTMLoutput += "<td width=\"50\">BD/BH</td>";
                                HTMLoutput += "<td width=\"75\">Price</td>";
                                HTMLoutput += "<td width=\"75\">$/Sq Ft</td>";
                                HTMLoutput += "<td width=\"50\">Details</td>";
                                HTMLoutput += "</tr>";
                                }
                                
                                HTMLoutput += "<tr class=\"" + rowclass + "\" onclick=\"ClickGridItem('" + newShape.GetID() + "');\" style=\"cursor:pointer;\"></td>";
                                HTMLoutput += "<td align=\"right\">" + itemindex + "</td>";
                                HTMLoutput += "<td>&nbsp;<img src=\"" + imagepath + "\" border=\"0\" width=\"60\" height=\"40\" onclick=\"ClickGridItem('" + newShape.GetID() + "');\"></td>";
                                HTMLoutput += "<td>" + title + "</td>";
                                HTMLoutput += "<td>" + city + "</td>";
                                HTMLoutput += "<td>" + livingarea + "</td>";
                                HTMLoutput+= "<td>" + bedrooms + "/" + bathrooms + "</td>";
                                if (status == "A")
                                {
                                HTMLoutput += "<td>" + listingprice + "</td>";
                                HTMLoutput += "<td>" + pricePerSqFt + "</td>";
                                }
                                else
                                {
                                HTMLoutput += "<td><font color=\"red\">" + closeprice + "</font></td>";
                                HTMLoutput += "<td><font color=\"red\">" + pricePerSqFt + "</font></td>";
                                }
                                
                                //alert(idxLogo);
                                if (datasourceid == "BRLAMLS")
                                {
                                    HTMLoutput+="<td><a href=\"javascript:popUpFull('http://www.cjbrown.com/" + mlsid + "',800,600)\" title=\"Click to view details for this Listing.\">Details</a>";
                                    if (idxLogo.length > 0)
                                    {
                                    HTMLoutput += "<br/><br/><img src=\"" + idxLogo + "\" border=\"0\" alt=\"" + idxMsg + "\">";
                                    }                                    
                                    HTMLoutput += "</td>";
                                }
                                else
                                {
                                    HTMLoutput +="<td><a href=\"javascript:popUpFull('http://www.latter-blum.com/" + mlsid + "',800,600)\" title=\"Click to view details for this Listing.\">Details</a>";
                                    if (idxLogo.length > 0)
                                    {
                                    HTMLoutput += "<br/><br/><img src=\"" + idxLogo + "\" border=\"0\" alt=\"" + idxMsg + "\">";
                                    }                 
                                    HTMLoutput += "</td>";
                                }
                                HTMLoutput += "</tr>";
                                
                                if (rowclass == "even")
                                    rowclass = "odd";
                                else
                                    rowclass = "even";
                                
                            }
                           }
                           
                     }
                 } //End type == L      
                 
                 if (type == 'O') //Office
                   {
                       
                        var displayname = pointresult[4];
                        var phone = pointresult[5];
                        var fax = pointresult[6];
                        var address1 = pointresult[7] + " " + pointresult[8];
                        var city = pointresult[9];
                        var state = pointresult[10];
                        var zipcode = pointresult[11];
                        var websiteurl = pointresult[12];
                        var contactname = pointresult[13];
                        var contactemail = pointresult[14];
                        bhaspoi = true;
                        customicon = "<div class='pinStyleOffice'><img src='images/office_icon.gif'/></div>";
                        newShape.SetTitle(displayname);
                        newShape.SetTitle(BuildInfoBox(intid, displayname, phone, fax, address1, city, state, zipcode, websiteurl,type,contactname,contactemail));

                        newShape.SetCustomIcon(customicon);
                        //this._poilayer.AddShape(newShape);
                        this._map.AddShape(newShape);
                        
                   }
                   
                   if (type == 'A') //Amenity
                   {
                        var displayname = pointresult[4];
                        var phone = pointresult[5];
                        var fax = pointresult[6];
                        var address1 = pointresult[7];
                        var city = pointresult[8];
                        var state = pointresult[9];
                        var zipcode = pointresult[10];
                        var websiteurl = pointresult[11];
                        var icon = pointresult[12];
                        var type = pointresult[13];
                        var contactname = pointresult[14];
                        var contactemail = pointresult[15];
                        bhaspoi = true;
                       customicon = "<div class='pinStyleAmenity'><img src='images/" + icon + "'/></div>";
                       newShape.SetTitle(BuildInfoBox(intid, displayname, phone, fax, address1, city, state, zipcode, websiteurl,type,contactname,contactemail));
                       newShape.SetCustomIcon(customicon); 
                       this._map.AddShape(newShape);
                       //this._poilayer.AddShape(newShape);
                   }
                       
             } 
             
             if (HTMLoutput != "")
                {
                    HTMLoutput += "</table>";
                    devResultGrid.innerHTML += HTMLoutput;
                }
             
                   
            SearchingDiv.style.display = 'none';          
        }
        
        
    },    
    
    Dispose: function() {
        /// <summary>
        ///   cleans up all objects. Detaches all events.
        /// </summary>
        /*
        if (this._map != null) {
            this._map.DetachEvent("onchangeview", this.GetPinDataDelegate);
            //this._map.DetachEvent("onmouseover", this.PinHoverDelegate);
            this._map.DetachEvent("onclick", this.PinHoverDelegate);                
            this._map.Dispose();
        }    
        this._service = null;
        this._mapArgs = null;
        
        this._map = null;
        this._pinID = null;
        this._zoomlevel = null;
        this._layer = null;
        
        //popup specific
        this._PopupPrefix = null;
        this._currentpin = null;
        this._currentindex = null;   
        
        */ 
    }    
}

//get values from the querystring
function getQueryString(name)
{ 
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp(regexS);  
    var results = regex.exec( window.location.href );  
    if(results == null)    
    return "";  
    else    
    return results[1];
} 

function triggerGrid()
{
     document.getElementById("btnTrigger").click();
}

function PrintMap()
{
     var printMap = new VEPrintableMap("myMap", "printableMap", map);
     printMap.Print();
}
        
        function ClickFeaturedItem(){
            
            if (boxClicked)
            {
                currentShape = currentmap.GetShapeByID(boxClickedID);
                currentmap.HideInfoBox(boxClickedID);
                boxClicked = false;
            }
            
            window.scrollTo(0,0);            
            currentmap.SetCenter(new VELatLong(document.getElementById("hidMainLat").value, document.getElementById("hidMainLong").value));
            currentShape = currentmap.GetShapeByID(boxFeaturedID);
            currentmap.ShowInfoBox(currentShape);
            boxClicked = true;
            boxClickedID = boxFeaturedID
        }
        
        function ClickGridItemSetMapView(markerId){
            
            if (boxClicked)
            {
                currentShape = currentmap.GetShapeByID(boxClickedID);
                currentmap.HideInfoBox(boxClickedID);
                boxClicked = false;
            }
            
            //Update pushpin
            currentShape = currentmap.GetShapeByID(markerId);
            currentmap.ShowInfoBox(currentShape);
            boxClicked = true;
            boxClickedID = markerId
            window.scrollTo(0,0);            
            currentmap.SetMapView(currentShape.GetPoints());
        }

        function ClickGridItem(markerId){
            
            if (boxClicked)
            {
                currentShape = currentmap.GetShapeByID(boxClickedID);
                currentmap.HideInfoBox(boxClickedID);
                boxClicked = false;
            }
            
            //Update pushpin
            currentShape = currentmap.GetShapeByID(markerId);
            //currentIcon = currentShape.GetCustomIcon();
            //currentShape.SetCustomIcon(currentIcon.replace('pinStyle', 'pinHoverStyle'));
            currentmap.ShowInfoBox(currentShape);
            boxClicked = true;
            boxClickedID = markerId
            window.scrollTo(0,0);
            
                      
            //Update side bar icon
            //var sideBarIconId = 'sideBarMarker_' + currentShape.GetID();
            //document.getElementById(sideBarIconId).className = 'pinHoverStyle';
        }
        
        function mouseOverGridItem(markerId){
            //Update pushpin
            currentShape = currentmap.GetShapeByID(markerId);
            //currentIcon = currentShape.GetCustomIcon();
            //currentShape.SetCustomIcon(currentIcon.replace('pinStyle', 'pinHoverStyle'));
            currentmap.ShowInfoBox(currentShape);
            //map.SetCenter(currentShape)
            
            //Update side bar icon
            //var sideBarIconId = 'sideBarMarker_' + currentShape.GetID();
            //document.getElementById(sideBarIconId).className = 'pinHoverStyle';
        }
    
        function mouseOutGridItem(markerId){
            //Update pushpin
            currentShape = currentmap.GetShapeByID(markerId);
            //currentIcon = currentShape.GetCustomIcon();
            //currentShape.SetCustomIcon(currentIcon.replace('pinHoverStyle', 'pinStyle'));
            currentmap.HideInfoBox(currentShape);
            
            //Update side bar icon
            //var sideBarIconId = 'sideBarMarker_' + currentShape.GetID();
            //document.getElementById(sideBarIconId).className = 'pinStyle';
        }  
        
        
function getData()
{
    currentmap.DeleteAllShapes();
    map._GetPinData();
}

function searchMap()
{
    document.getElementById("hidPropertyType").value =document.getElementById("ddlPropertyType").value;
    document.getElementById("hidMinSquareFoot").value =document.getElementById("ddMinSquareFoot").value;
    document.getElementById("hidMinPrice").value =document.getElementById("ddMinPrice").value;
    document.getElementById("hidMaxPrice").value = document.getElementById("ddMaxPrice").value;
    document.getElementById("hidMinBedrooms").value = document.getElementById("ddMinBed").value;
    document.getElementById("hidMinBathrooms").value = document.getElementById("ddMinBath").value;
    currentmap.DeleteAllShapes();
    map._GetPinData();
}


function FindLayer(title)
{
  var layer = null;
  for (var i = 0; i < currentmap.GetShapeLayerCount(); i++)
  {
    layer = currentmap.GetShapeLayerByIndex(i);
    if (layer.GetTitle() == title) break;
    layer = null; 
  }
  return layer;
}


function BuildInfoBox(ID, displayname, phone, fax, address1, city, state, zipcode, websiteurl,type,contactname,contactemail)
{
            
            var strInfoBoxContents;
            strInfoBoxContents = "";
            
           strInfoBoxContents += "<table cellspacing=0 cellpadding=2 style=\"width:100%\">";
           strInfoBoxContents +="<tr>";
            //strInfoBoxContents +="<td style=\"vertical-align:top; padding-top:5px;\">";
            //strInfoBoxContents +="<img alt=\"listing image\" src=\"" + ImagePath + "\"/>";
            //strInfoBoxContents +="</td>";
            strInfoBoxContents +="<td style=\"vertical-align:top\">";
            strInfoBoxContents +="<table cellspacing=0>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +="<b>" + displayname + "</b><br />";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += city + ", " + state + " " + zipcode;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += "&nbsp;";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            if (phone!="")
            { 
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += "<b>Phone:</b> " + phone;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            }
            if (fax!="")
            { 
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += "<b>Fax:</b> " + fax;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            }
            
            if (contactname!="")
            { 
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += "<b>Contact:</b> " + contactname;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            }
            
            if (contactemail!="")
            { 
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += "<b>Email:</b> <a href='mailto:" + contactemail + "'>" + contactemail + "</a>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            }
            
            if (websiteurl!="")
            { 
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += "<b>Website:</b> <a href='" + websiteurl + "' target='_blank'>" + websiteurl + "</a>" ;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            }
            
            strInfoBoxContents +="</table>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="</table>";
            
            return strInfoBoxContents;
 }

function BuildInfoBoxSingle(ListingID, Title, City, Price, ImagePath, Bedrooms, Bathrooms, SqFeet, MLSID, DataSourceID)
{
            var strInfoBoxContents;
            strInfoBoxContents = "";
            
            //strInfoBoxContents += "<div class=\"popcontainer\">";
            //strInfoBoxContents += "<b class=\"poprtop\"><b class=\"popr1\"></b> <b class=\"popr2\"></b> <b class=\"popr3\"></b> <b class=\"popr4\"></b></b>";

           strInfoBoxContents += "<table cellspacing=0 cellpadding=2 style=\"width:100%\">";
           strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td style=\"vertical-align:top; padding-top:5px;\">";
            strInfoBoxContents +="<img alt=\"listing image\" src=\"" + ImagePath + "\"/>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="<td style=\"vertical-align:top\">";
            strInfoBoxContents +="<table cellspacing=0>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +="<b>" + Title + "</b>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += City;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +=Price;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +=Bedrooms + " Beds " + Bathrooms + " Baths";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +=SqFeet + " Square Feet";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            if (DataSourceID == "BRLAMLS")
            {
                strInfoBoxContents +="<a href=\"javascript:popUpFull('http://www.cjbrown.com/" + MLSID + "',800,600)\" title=\"Click to view details for this Listing.\">View Listing Details</a>";
            }
            else
            {
                strInfoBoxContents +="<a href=\"javascript:popUpFull('http://www.latter-blum.com/" + MLSID + "',800,600)\" title=\"Click to view details for this Listing.\">View Listing Details</a>";
            }

            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="</table>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="</table>";
             //strInfoBoxContents += "<b class=\"poprbottom\"><b class=\"popr4\"></b> <b class=\"popr3\"></b> <b class=\"popr2\"></b> <b class=\"popr1\"></b></b>";
            //strInfoBoxContents += "</div>";

            return strInfoBoxContents;
 }

function BuildInfoBoxMultiple(ListingID, Title, City, Price, ImagePath, Bedrooms, Bathrooms, SqFeet, MLSID, DataSourceID, PropertyCount)
{
            var strInfoBoxContents;
            strInfoBoxContents = "";
            
            strInfoBoxContents += "<table cellspacing=0 cellpadding=2 style=\"width:100%\">";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td style=\"vertical-align:top; padding-top:5px;\">";
            strInfoBoxContents +="<img alt=\"listing image\" src=\"" + ImagePath + "\"/>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="<td style=\"vertical-align:top\">";
            strInfoBoxContents +="<table cellspacing=0>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +="<b>" + Title + "</b>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += City;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +=Price;
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents +=Bedrooms + " Beds " + Bathrooms + " Baths";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            strInfoBoxContents += SqFeet + " Square Feet";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="</table>";
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="</table>";
            
            strInfoBoxContents +="<table cellspacing=0 cellpadding=2 style=\"width:100%\">";
            strInfoBoxContents +="<tr>";
            strInfoBoxContents +="<td>";
            if (DataSourceID == "BRLAMLS")
            {
                strInfoBoxContents +="<a href=\"javascript:popUp('ViewListingMultiple.aspx?c=CJBRN&mls=" + MLSID + "&count=" + PropertyCount + "',800,600)\" title=\"Click to view details for this Listing.\">Click here to view <span style=\"color:red;font-weight:bold;\">" + PropertyCount + "</span> Listings at this location</a>";
            }
            else
            {
                strInfoBoxContents +="<a href=\"javascript:popUp('ViewListingMultiple.aspx?c=LATTB&mls=" + MLSID + "&count=" + PropertyCount + "',800,600)\" title=\"Click to view details for this Listing.\">Click here to view <span style=\"color:red;font-weight:bold;\">" + PropertyCount + "</span> Listings at this location</a>";
            }
            strInfoBoxContents +="</td>";
            strInfoBoxContents +="</tr>";
            strInfoBoxContents +="</table>";

            return strInfoBoxContents;
 }
 
 

RealtyLogic.MapSearch.Map.registerClass('RealtyLogic.MapSearch.Map', null, Sys.IDisposable);

if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

