﻿//<![CDATA[
if (GBrowserIsCompatible())
{
 
var map;
var firstTabName = 'Summary';
var secondTabName = 'Details';
var thirdTabName = 'Agent';
var markers = [];
var List = [];
var overlays = [];
var html1s = [];
var html2s = [];
var html3s = [];
var toolTip;

var _number = 0;
var _id = -1;
var _long = 0;
var _lat = 0;
var _innerHTML = "";
var tilelayer;
var tilelayerOverlay = [];

var legendStatus='visible';
var search = 1;
var initial_zoom = 0;
var zoom = ZOOM_FACTOR_VERIFIED;
var records;
//var clusterer;

var displayLength = 48*7;
var disDiv=[];
var divPos=0;
var maxDiv=0;

//pageLoad -- Start --
function pageLoad()
{
    SetVariables();
    
    _innerHTML = document.getElementById('mapLoad').innerHTML; // MAP Loading Image
         
    map = new GMap2(document.getElementById("map")); 
    map.addControl(new GLargeMapControl());
    map.addControl(new GScaleControl());
    CreateCustomControls();
        
    GEvent.addListener(map, "moveend", function(){ 
        
        document.getElementById('mapLoad').innerHTML = _innerHTML; // show MAP loading img   
        
        DisplayMap('');        
        
    });     
    
    if(Vancouver_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // Vancouver_Domain subdomain
        point = new GPoint2( -123.11394,49.26049);
    else    
         point = new GPoint2(LONGITUDE, LATITUDE);
    if(Mckenzie_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // mckinzie subdomain
    {
        zoom = ZOOM_FACTOR_MCKINZIE;
        map.setCenter(point, ZOOM_FACTOR_MCKINZIE);
    }
    else if(Vancouver_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // vancouver subdomain
    {
        zoom = ZOOM_FACTOR_MCKINZIE;
        map.setCenter(point, ZOOM_FACTOR_VANCOUVER);
    }    
    else if(Foster_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // Foster subdomain
    {
        zoom = ZOOM_FACTOR_FOSTER;
        map.setCenter(point, ZOOM_FACTOR_FOSTER);
    }
    else 
    {
        zoom = ZOOM_FACTOR_VERIFIED;
        map.setCenter(point, ZOOM_FACTOR_VERIFIED);
    }  
   
   ///////////// Tooltip ////////////////////////////////
    
   toolTip = document.getElementById('dhtmltooltip');        
   map.getPane(G_MAP_FLOAT_PANE).appendChild(toolTip);
   toolTip.style.visibility="hidden";
   
   ////////////////////////////////////////////////////

//   DisplayMap();
    CreateMapLegend();
    
    
}
//pageLoad -- End --
function PrintMap(x,y,myView)
{
    var myMapType = map.getCurrentMapType();
    var myMapTypeStr ;
    if (myMapType == G_SATELLITE_TYPE) {
      myMapTypeStr = "satellite";
    }
    else if (myMapType == G_MAP_TYPE) {
      myMapTypeStr = "map";
    }
    else if (myMapType == G_HYBRID_TYPE) {
      myMapTypeStr = "hybrid";
    }
    
    window.open("PrintPreview.aspx?" + qs_PRINT_TYPE + "=public&" + qs_LONGITUDE + "=" +  x +"&" + qs_LATITUDE + "="+ y + "&" + qs_ZOOM + "="+map.getZoom() +"&" + qs_MAP_TYPE + "="+ myMapTypeStr + "&" + qs_PROPERTY_TYPE + "=Residential");    ///window.print();
}


function drawKML(fileName,ctrl,index) // KML file name,Control that call the dunction,index of layer
{
    if(checkOverlay(ctrl,index))
    {       
        
        // === Create the tilelayer ===          
               
          if(!tilelayerOverlay[index])
          {              
              tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
              
              // === Set the getTileUrl to use the Google KML tile processor with our KML file ===
              tilelayer.getTileUrl = function(a,b) {
                b=this.maxResolution()-b;
                
                return "http://maps.google.com/mapsdt?id=http://maptop.techlogix.com/maptop/KML/"+fileName+"&x="+a.x+"&y="+a.y+"&zoom="+b;
                //return "http://maps.google.com/mapsdt?id=http://www.mapgroove.com/KML/"+fileName+"&x="+a.x+"&y="+a.y+"&zoom="+b;
                //return "http://maps.google.com/mapsdt?id=http://"+document.location.hostname+"/maptop/KML/"+fileName+"&x="+a.x+"&y="+a.y+"&zoom="+b;

              }
              tilelayer.isPng = function() {return true;}             
              
              // === add a GTileLayerOverlay to it ===
              tilelayerOverlay[index] = new GTileLayerOverlay(tilelayer);
          }
          map.addOverlay( tilelayerOverlay[index] );
    }
}

function checkOverlay(ctrl,index)
{
    
    if(ctrl.checked == true)
        return true;
    else
    {        
        map.removeOverlay(tilelayerOverlay[index]);        
    }    
    
}

//DisplayOverlayData -- Start --
function DisplayOverlayData()
{   
    var school = 0;
    var park = 0;
    var hospital = 0;
    var shoppingMall = 0;
    
    if(document.getElementById("chkSchool").checked == true)
        school = OVERLAY_TYPE_SCHOOL;
        
    if(document.getElementById("chkPark").checked == true)
        park = OVERLAY_TYPE_PARK;
        
    if(document.getElementById("chkHospital").checked == true)
        hospital = OVERLAY_TYPE_HOSPITAL;
        
    if(document.getElementById("chkShoppingMall").checked == true)
        shoppingMall = OVERLAY_TYPE_SHOPPING_MALL;
    
    /////////////////////////////////////////////////////
    
     var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        
        var longmin = southWest.lng();
        var longmax = northEast.lng();
    
        var latmin = southWest.lat();
        var latmax = northEast.lat(); 
    
    ////////////////////////////////////////////////////
    
    
    MapData.GetOverlayDataTable(school, park, hospital, shoppingMall,longmin,latmin,longmax,latmax, DisplayOverlayData_CallBack);
}
//DisplayOverlayData -- End --

//DisplayOverlayData_CallBack -- Start --
function DisplayOverlayData_CallBack(res)
{
    var length = res.get_length();
       
    for (j = 0; j < overlays.length; j ++)
        map.removeOverlay(overlays[j]);
        
        
    for (i = 0; i < length; i++)
    {
        var x = res.getItem(i).getProperty('Longitude');
        var y = res.getItem(i).getProperty('Latitude');
        var overlayTypeIdLkp = res.getItem(i).getProperty('OverLayTypeIdLkp');
        var OverLayType = res.getItem(i).getProperty('OverLayType');
        var description = res.getItem(i).getProperty('Description');
        var imageName = res.getItem(i).getProperty('image');
        var street = res.getItem(i).getProperty('Address');
        var address = '';
        var toolTipText = OverLayType+ ' - ';
        
        if(street)
        {
            if(street != '' && street != " ")
            {            
                address = street + "<br>" + res.getItem(i).getProperty('City') + ", "+res.getItem(i).getProperty('State')+" "+ res.getItem(i).getProperty('ZipCode');                                  
                toolTipText = toolTipText + street;            
            }
        }        
                
        var point = new GPoint2(x, y);

        var icon = GetIconPath(overlayTypeIdLkp);
        
        var overlayHtml = GenerateOverlayHtml(OverLayType,address,imageName,description);
                
        CreateOverlayMarker(point,toolTipText,overlayHtml,icon);
    }
}

// HTML Bubble for marker

function GenerateOverlayHtml(type,address, imageName,description)
{
    var div = GenerateWindowSize();
    var html = div;
	    
    html = html + '<table align=center class="BubbleTable">';
    html = html + '<tr>';
    html = html + '<td align=center valign=top>';
    html = html + '<img src=' + OverlayImagesPath + imageName + ' width=77 height=77 border=1>';
    html = html + '</td>';
    html = html + '<td>';
    html = html + '<table align=center class="BubbleTable">';

    if(type != '')
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + '<b>'+ type +'</b>';
        html = html + '</td>';
        html = html + '</tr>';
    }
    
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + 'Address: ' + address;
    html = html + '</td>';
    html = html + '</tr>';
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + '--------------';
    html = html + '</td>';
    html = html + '</tr>';
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + description;
    html = html + '</td>';
    html = html + '</tr>';
    html = html + '</table>';
    html = html + '</td>';
    html = html + '</tr>';    
    html = html + '</table>';
    html = html + '</div>';

    return html;
}

function CreateOverlayMarker(point,toolTipText,overlayHtml,icon)
{
    var infoTabs = [
    new GInfoWindowTab(firstTabName, overlayHtml)    
    ]; 

    var marker = new GMarker(point, icon);
    marker.tooltip = toolTipText;
    
    GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowTabsHtml(infoTabs);
    });

    map.addOverlay(marker);
    overlays.push(marker);

    GEvent.addListener(marker,"mouseover", function() {
    ShowToolTip(marker);
    });
    
    GEvent.addListener(marker,"mouseout", function() {
    toolTip.style.visibility="hidden"
    });
    
    GEvent.addListener(marker,"click", function() {    
    toolTip.style.visibility="hidden"
    });
    
    GEvent.addListener(marker, "infowindowopen", function() {testHeight();});
        

}

//DisplayOverlayData_CallBack -- End --

//DisplayMap -- Start --
function DisplayMap(isSearch)
{     
    var dpProperty = document.getElementById("ctl00_ContentPlaceHolder1_dpPropertyStatus");        
   var dpPriceMin = document.getElementById("ctl00_ContentPlaceHolder1_dpPriceRangeMin");
   var dpPriceMax = document.getElementById("ctl00_ContentPlaceHolder1_dpPriceRangeMax");
   var dpSqftMin = document.getElementById("ctl00_ContentPlaceHolder1_dpSqFtMin");
   var dpSqftMax = document.getElementById("ctl00_ContentPlaceHolder1_dpSqFtMax");
   var dpType = document.getElementById("ctl00_ContentPlaceHolder1_dpType");
   var txtStreet = document.getElementById("ctl00_ContentPlaceHolder1_txtStreet");
   var txtAPN = document.getElementById("ctl00_ContentPlaceHolder1_txtAPN");   
   var APN_value;
   
   if(txtAPN == null)
        APN_value='';
   else
       APN_value=txtAPN.value;
            
   var dpBed = document.getElementById("ctl00_ContentPlaceHolder1_dpBeds");
   var dpBath = document.getElementById("ctl00_ContentPlaceHolder1_dpBaths");
   var dpCity = document.getElementById("ctl00_ContentPlaceHolder1_dpCity");
   var txtZipCode = document.getElementById("ctl00_ContentPlaceHolder1_txtZipCode");
   var lblCompanyId = document.getElementById("ctl00_ContentPlaceHolder1_lblCompanyId");
   
   var dpBrokersFirm;
   
   if(legendStatus=='visible')
   {         
        document.getElementById("mapLegend").style.display='';
   }
   else 
   {      
        document.getElementById("mapLegend").style.display='none';        
   }
    
   if(Mckenzie_Domain.toLowerCase() == window.location.hostname.toLowerCase())
   {
        dpBrokersFirm = "Mckinzie Nielsen";
   }
   else if(Foster_Domain.toLowerCase() == window.location.hostname.toLowerCase())
   {
        dpBrokersFirm = "Foster & Associates";
   }
   else if(ASU_Domain_1.toLowerCase() == window.location.hostname.toLowerCase())
   {
        dpBrokersFirm = "Grubb & Ellis";     
   }
   else
    dpBrokersFirm = document.getElementById("ctl00_ContentPlaceHolder1_dpBrokersFirm").value;
   
   /////////////////////////////////////////////////       

    
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        
        var longmin = southWest.lng();
        var longmax = northEast.lng();
    
        var latmin = southWest.lat();
        var latmax = northEast.lat();   
  
   if(isSearch == '1')
   {          
        map.clearOverlays(markers);        
        markers = [];
        List = [];
        overlays = [];
        html1s = [];
        html2s = [];
        html3s = [];
        _number = 0;
        _long = 0;
        _lat = 0;
        search = 1;
        initial_zoom = 0;
        
   }    
   var lblListingID = document.getElementById("ctl00_ContentPlaceHolder1_lblListingID");  
   MapData.GetResidentialDataTable(dpPriceMin.value, dpPriceMax.value, dpSqftMin.value, dpSqftMax.value, dpType.value, txtStreet.value, APN_value, dpBrokersFirm, dpBed.value, dpBath.value,dpCity.value,txtZipCode.value,lblListingID.value,dpProperty.value,longmin,latmin,longmax,latmax,lblCompanyId.value, DisplayMap_CallBack);
}
//DisplayMap -- End --

//DisplayBubble -- Start --
function DisplayBubble(id,longitude,latitude)
{
    _id = id;
    _number = List.indexOf(id);
   
    if(_number != -1)
    {    
        var infoTabs = [
        new GInfoWindowTab(firstTabName, html1s[_number]), 
        new GInfoWindowTab(secondTabName, html2s[_number]),
        new GInfoWindowTab(thirdTabName, html3s[_number])
        ];             

        markers[_number].openInfoWindowTabsHtml(infoTabs); 
        

        
        _long = longitude;
        _lat = latitude;
        point = new GPoint2(longitude, latitude);
        if(Mckenzie_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // mckinzie subdomain
        {
             map.setCenter(point, map.getZoom());
        }
        else if(Foster_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // Foster subdomain
        {
             map.setCenter(point, map.getZoom());
        }
        else 
        {
             map.setCenter(point, map.getZoom());
        } 
    }
    else
    {
        _long = longitude;
        _lat = latitude;
        point = new GPoint2(longitude, latitude);
        if(Mckenzie_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // mckinzie subdomain
        {
             map.setCenter(point, ZOOM_FACTOR_MCKINZIE);
        }
        else if(Mckenzie_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // mckinzie subdomain
        {
             map.setCenter(point, ZOOM_FACTOR_MCKINZIE);
        }
        else if(Foster_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // Foster subdomain
        {
             map.setCenter(point, ZOOM_FACTOR_FOSTER);
        }
        else 
        {
             map.setCenter(point, ZOOM_FACTOR_VERIFIED);
        }  
    }
}

function testHeight()
{   
    //SetDetails();
    var tbl1 = document.getElementById("tbl1");
    var tbl2 = document.getElementById("tbl2");    
    var tbl3 = document.getElementById("tbl3");
    
    var div_parent = document.getElementById("bubbleDiv").parentNode;
    var div_e = document.getElementById("bubbleDiv");
    
    div_e.style.height = div_parent.parentNode.clientHeight;    
    tbl3.style.height = tbl2.style.height = tbl1.style.height =div_e.style.height;
    
}

//DisplayBubble -- End --

//DisplayMap_CallBack -- Start --
function DisplayMap_CallBack(res_array)
{   
    
    var res = res_array[0];
    var length = res.get_length(); 
     
/////////////////////////////////// map location setting according to search results ///////////////////////////////////

    var initialLongitude = 0;
    var initialLatitude = 0;
    var icons_count = 0;
    var city;
    
    if(res_array[1])
    {
        if(res_array[1].get_length() >0)
        {
            initialLongitude = res_array[1].getItem(0).getProperty('initialLongitude');
            initialLatitude = res_array[1].getItem(0).getProperty('initialLatitude');
            icons_count = res_array[1].getItem(0).getProperty('records');
            city = res_array[1].getItem(0).getProperty('City');
            
            if(city == "#" && res_array[1].get_length()>1)
            {
                initialLongitude = res_array[1].getItem(1).getProperty('initialLongitude');
                initialLatitude = res_array[1].getItem(1).getProperty('initialLatitude');
                icons_count = res_array[1].getItem(1).getProperty('records');
                city = res_array[1].getItem(1).getProperty('City');
            }
        }
    }

    var longi;
    var lati;
    var point;
    
  if(search == 1)
  {            

        if(icons_count > 0)   
        {                 
            
            var a= length;            
               
            point = new GPoint2(initialLongitude, initialLatitude);
            
            if(initial_zoom == 0)
            {               
                
                if(Mckenzie_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // mckinzie subdomain
                {
                     zoom = ZOOM_FACTOR_MCKINZIE;
                     map.setCenter(point, ZOOM_FACTOR_MCKINZIE);
                }
                else if(Foster_Domain.toLowerCase() == window.location.hostname.toLowerCase()) // Foster subdomain
                {
                     zoom = ZOOM_FACTOR_FOSTER;
                     map.setCenter(point, ZOOM_FACTOR_FOSTER);
                }
                else 
                {
                    zoom = ZOOM_FACTOR_VERIFIED;
                     map.setCenter(point, ZOOM_FACTOR_VERIFIED);
                }
                initial_zoom = 1;
                return;
            } //---- initial zoom == 0
            
            
            if(icons_count <= MAP_ICONS_THRESHOLD && a < icons_count/2)
            {
                
                zoom = zoom -1;
                if(zoom >= 0)           
                { 
                    
                    //map.setCenter(point, zoom);
                    map.setZoom(zoom);                    
                    
                }
                  
                return;
            }
            else if(a < MAP_ICONS_THRESHOLD && a < (icons_count/2))
            { 
                zoom = zoom -1;
                if(zoom >=0 )           
                {
                    //map.setCenter(point, zoom);
                    map.setZoom(zoom);                    
                    
                }
                  
                return;
            }  
                       
        }
  } 

search = 0;


    for (i = 0; i < length; i++)
    {
        
        var resPropId = res.getItem(i).getProperty('ResPropID');
        
        if(List.length > 0)
        {
            if(List.indexOf(resPropId) != -1)
                continue;
        }
    
        List.push(resPropId);
    
        var x = res.getItem(i).getProperty('Longitude');
        var y = res.getItem(i).getProperty('Latitude');
        var price = res.getItem(i).getProperty('Price');
        
        var street = res.getItem(i).getProperty('Address');
        var location = res.getItem(i).getProperty('Location');
        var city = res.getItem(i).getProperty('City');
        var state = res.getItem(i).getProperty('State');
        var zipCode = res.getItem(i).getProperty('ZipCode');
        
        var address = '';
        var toolTipText = '';
        var Adress_Complete = '';
        
        if(street != '' && street != " ")
        {
            address = street + "<br>" + city + ", " + state + " " + zipCode;
            Address_Complete = street + " " + city + ", " + state + " " + zipCode;
            toolTipText = street + " - " + toolTipText;
        }
        else
        {
            Address_Complete = location;
            address = location;
            toolTipText = address + " - " + toolTipText;
        }

        var realtorName = res.getItem(i).getProperty('RealtorName');
        var webAddress = res.getItem(i).getProperty('WebAddress');
        var no = res.getItem(i).getProperty('No');
        var imageName = res.getItem(i).getProperty('ImageName');
        var propertyWebAddress = res.getItem(i).getProperty('PropertyWebAddress');
        var type = res.getItem(i).getProperty('Type');
        var sqft = res.getItem(i).getProperty('Sqft');
        var pricePerSqft = Math.round((price / sqft) * 100) / 100;
        var description = res.getItem(i).getProperty('Description');
        var openHouse = res.getItem(i).getProperty('OpenHouseDateTime');
        var realtorImage = res.getItem(i).getProperty('RealtorImage');
        
        var propertyStatusLkpId = res.getItem(i).getProperty('PropertyStatusIDLkp');
        var emailAddress = res.getItem(i).getProperty('EmailAddress');
        var contactOff = res.getItem(i).getProperty('ContactOff');
        var fax = res.getItem(i).getProperty('Fax');
        var brochureFileName = res.getItem(i).getProperty('BrochureFileName');
        var brochureFileURL = res.getItem(i).getProperty('BrochureFileURL');
        var BrokerFirm = res.getItem(i).getProperty('BrokerFirm');
        var APN = res.getItem(i).getProperty('APN');
        var Bedrooms = res.getItem(i).getProperty('Bedrooms');
        var Bathrooms = res.getItem(i).getProperty('Bathrooms');
        
        var secondaryRealtorName = res.getItem(i).getProperty('SecondaryRealtorName');
        var SRWebAddress = res.getItem(i).getProperty('SRWebAddress');
        var SecondaryRealtorImage = res.getItem(i).getProperty('SecondaryRealtorImage');
        var SREmailAddress = res.getItem(i).getProperty('SREmailAddress');
        var SRContactOff = res.getItem(i).getProperty('SRContactOff');
        var SRFax = res.getItem(i).getProperty('SRFax');
        var SRBrokerFirm = res.getItem(i).getProperty('SRBrokerFirm');

                
        openHouse = FormatDate(openHouse);
        
        var html1 = GenerateHtml1(price, address, imageName, sqft, pricePerSqft, openHouse,Bedrooms,Bathrooms,APN,Address_Complete,x,y);
        var html2 = GenerateHtml2(description, openHouse, resPropId, brochureFileName, brochureFileURL, APN, Address_Complete, type, x, y, street, state, city, zipCode, Bedrooms, Bathrooms, price);
        var html3 = GenerateHtml3(realtorName, webAddress, realtorImage, emailAddress, contactOff, fax,BrokerFirm, secondaryRealtorName, SRWebAddress, SecondaryRealtorImage, SREmailAddress, SRContactOff, SRFax, SRBrokerFirm,APN,Address_Complete,x,y);

        var point = new GPoint2(x, y);
        var icon = GetIconPath(propertyStatusLkpId, RESIDENTIAL_FUNCTIONS);
        CreateMarker(point, toolTipText+' $'+number_format(price), html1, html2, html3, no, icon);
    }  
    
    if(_number == -1)
    {
        DisplayBubble(_id,_long,_lat);
        _number = 0;
        _long = 0;
        _lat = 0;
    }        
        
    DisplayOverlayData();
    document.getElementById('mapLoad').innerHTML = ""; // HIDE MAP Loading img
}
//DisplayMap_CallBack -- End --
function NextRealtor()
{
    var realtor = document.getElementById('RealtorTable');
    var secondaryRealtor= document.getElementById('SecondaryRealtorTable');
    var button = document.getElementById('RealtorButton');
    var buttonNext = document.getElementById('RealtorButtonNext');
    var buttonPrevious = document.getElementById('RealtorButtonPrevious');
    //alert(realtor);
    if(realtor.style.display == 'block')
    {
        secondaryRealtor.style.display='block';
        realtor.style.display='none';
        document.getElementById('Broker').innerText = document.getElementById('Broker2').innerText;
        buttonNext.style.display='none';
        buttonPrevious.style.display='block';
    }
    else
    {
        secondaryRealtor.style.display='none';
        realtor.style.display='block';
        document.getElementById('Broker').innerText = document.getElementById('Broker1').innerText;
        buttonNext.style.display='block';
        buttonPrevious.style.display='none';

    }    
}
//GenerateHtml3 -- Start --
function GenerateHtml3(realtorName, webAddress, realtorImage, emailAddress, contactOff, fax, BrokerFirm, secondaryRealtorName, SRWebAddress, SecondaryRealtorImage, SREmailAddress, SRContactOff, SRFax, SRBrokerFirm,APN,Address,x,y)
{
    var div = GenerateWindowSize();
    var html = div;    
  
    html = html + '<table id="tbl3" width="100%" class="TableBorder" cellpadding="0" cellspacing="0" >';
    html = html + '<tr>';
    html = html + '<td class="RowBorder">';
        html = html + '<table width = "100%">';
        html = html + '<tr width = "100%" valign=top>';
        html = html + '<td align=left class="BubbleHeadingGreen">';
            html = html + '<b><div id="Broker">'+BrokerFirm+'</div></b>'
        html = html + '</td>';
        html = html + '<td align = right >';
            html = html + '<a href="#" onclick="PrintMap('+x +','+y+')" class="LinkInBubble"> <IMG style="text-decoration:none" border=0 SRC="Images/Domains/Shared/Printer.png" alt="Print" />'                
            html = html + '</a>'
            html = html + '<a  class="LinkInBubble" href="javascript:Popup1_Feedback(\'' + APN + '\',\'' + Address + '\')" ><IMG style="text-decoration:none" border=0 SRC="Images/Domains/Shared/FeedBack.gif" alt="Feedback" /></a>';
        html = html + '</td>';        
        html = html + '</tr>';
        html = html + '</table>';    
           
    html = html + '</td>';
    html = html + '</tr >';
    
    html = html + '<tr height="100%">';
    html = html + '<td>';  
	    
    html = html + '<table id ="tbl_3" align=center class="BubbleTable">';
    html = html + '<tr><td></td></tr>'
    html = html + '<tr>';
    html = html + '<td>';
    html = html + '<table id="RealtorTable" style="display:block;" class="BubbleTable">';
    html = html + '<tr>';
    html = html + '<td align=left>';   
    html = html + '<img src=' + RealtorThumbnailImagesPath + realtorImage + ' class="AgentImageInBubble" >';
    html = html + '</td>';
    html = html + '<td>';
    html = html + '<table align=center class="BubbleTable">';
    html = html + '<tr>';
    html = html + '<td align=center>';
    
    if(webAddress != '#')
	    html = html + '<a href=' + webAddress + ' target=_blank><font class="LinkInBubble">' + realtorName + '</font></a>';
    else
	    html = html + '<b>' + realtorName + '<b>';
	    
    html = html + '</td>';
    html = html + '</tr>';
    
    if(contactOff != '')
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + contactOff;
        html = html + '</td>';
        html = html + '</tr>';
    }
    
    if(fax != '')
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + 'Fax: ' + fax;
        html = html + '</td>';
        html = html + '</tr>';
    }
    
    html = html + '</table>';
    html = html + '</td>';
    html = html + '</tr>';
    
    html = html + '<tr style="display:none">';
    html = html + '<td align=left colspan="2">';
    html = html + '<b><div id="Broker1">'+ BrokerFirm +'</div></b>';
    html = html + '</td>';
    html = html + '</tr>';
    
    if(emailAddress != '')
    {
        html = html + '<tr>';
        html = html + '<td align=left colspan="2">';
        html = html + '<a  class="LinkInBubble" href="javascript:Popup_SendMail(\'' + emailAddress + '\')" ><font class="LinkInBubble">' + emailAddress + '</font></a>';
        html = html + '</td>';
        html = html + '</tr>';
    }

    html = html + '</table>';
    html = html + '<table id="SecondaryRealtorTable" style="display:none;" class="BubbleTable">';
    html = html + '<tr>';
    html = html + '<td align=left>';   
    html = html + '<img src=' + RealtorThumbnailImagesPath + SecondaryRealtorImage + ' class="AgentImageInBubble" >';
    html = html + '</td>';
    html = html + '<td>';
    html = html + '<table align=center class="BubbleTable">';
    html = html + '<tr>';
    html = html + '<td align=center>';
    
    if(SRWebAddress != '#')
	    html = html + '<a href=' + SRWebAddress + ' target=_blank><font class="LinkInBubble">' + secondaryRealtorName + '</font></a>';
    else
	    html = html + '<b>' + secondaryRealtorName  + '<b>';
	    
    html = html + '</td>';
    html = html + '</tr>';
    
    if(SRContactOff != '')
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + SRContactOff;
        html = html + '</td>';
        html = html + '</tr>';
    }
    
    if(SRFax != '')
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + 'Fax: ' + SRFax;
        html = html + '</td>';
        html = html + '</tr>';
    }
    html = html + '</table>';
    html = html + '</td>';
    html = html + '</tr>';
    
    html = html + '<tr style="display:none">';
    html = html + '<td align=left colspan="2">';
    html = html + '<b><div id="Broker2">'+ SRBrokerFirm  +'</div></b>';
    html = html + '</td>';
    html = html + '</tr>';
    
    if(emailAddress != '')
    {
        html = html + '<tr>';
        html = html + '<td align=left colspan="2">';
        html = html + '<a  class="LinkInBubble" href="javascript:Popup_SendMail(\'' + SREmailAddress + '\')" ><font class="LinkInBubble">' + SREmailAddress + '</font></a>';
        html = html + '</td>';
        html = html + '</tr>';
    }
    html = html + '</table>';
    html = html + '</td>';
    html = html + '</tr>';
    html = html + '</table>';
    
    html = html + '</td>';
    html = html + '</tr>';
    
    if(SREmailAddress != '')
    {
        html = html + '<tr align="right">';
        html = html + '<td align="right" class="RowBorderNoBg">';
        html = html + '<a id="RealtorButton" href="#" onclick="NextRealtor()"  class="LinkInBubble">';
        html = html + '<img id="RealtorButtonNext" style="display:block" border="0" src="'+ GetPath()+'Pages/next_off.gif" onmouseover=SetImagePath(this,"next_on.gif") onmouseout=SetImagePath(this,"next_off.gif")  height="16" width="59" />'
        html = html + '<img id="RealtorButtonPrevious" style="display:none" border="0" src="'+ GetPath()+'Pages/previous_off.gif" onmouseover=SetImagePath(this,"previous_on.gif") onmouseout=SetImagePath(this,"previous_off.gif")  height="16" width="59" />'        
        html = html + '</a>';        
        html = html + '</td>';
        html = html + '</tr>';
   }    
    
    
    html = html + '</table>';
    
    html = html + '</div>';    
   
    

    return html;
}
//GenerateHtml3 -- End --


function FormatDiscriptionNext(index)
{
    var description=disDiv[divPos+1];
    var desArea=document.getElementById("desArea");
    var previous = document.getElementById("PreDes");
    var next = document.getElementById("NextDes");        
   // alert(next.text);
    if((divPos+1)< maxDiv)
    {        
        previous.style.display = 'block';               
        divPos++;
        desArea.innerText=description;
        if((divPos+1) == maxDiv)
        {                      
            next.style.display = 'none';                       
        }            
    }              
    
}

function FormatDiscriptionPrevious(index)
{
    var description=disDiv[divPos-1];
    var desArea=document.getElementById("desArea");
    var previous = document.getElementById("PreDes");
    var next = document.getElementById("NextDes");        
    
    if((divPos-1)>= 0)
    {        
        next.style.display = 'block';
        divPos--;
        desArea.innerText=description;
        if(divPos == 0)
        {                      
            previous.style.display = 'none';                       
            
        }            
    }              
    
}


function SetDetails()
{
    divPos=0;
    maxDiv=0;
    var area = document.getElementById("desArea"); 
    var next = document.getElementById("NextDes");            
    var description = area.innerText;
    var index=0;
    var ptr=0;   
    var prePtr=0;
  
    if(description.length > displayLength)
    {
        do{         
            var des="";
            prePtr=ptr;           
            for(var i=0; i < displayLength && ((i+ptr) < description.length) ;i++);        
            ptr=ptr+i;
            if(description.length!=ptr)
            {
                for(;(description.charAt(ptr)!=' ' && description.charAt(ptr)!=" ") && (description.charAt(ptr)!='.' && description.charAt(ptr)!=".");ptr--);
            }

            for(;prePtr<=ptr;prePtr++)
            {
                if(!(description.charCodeAt(prePtr) == 13 || description.charAt(prePtr)=="\n" || description.charAt(prePtr)=='\n'))
                {
                    des=des+description.charAt(prePtr);                    
                }

            }

            disDiv[index++]=des;            
        }while((ptr+1) < (description.length) && ptr < description.length)
           
        maxDiv=index;
        area.innerText=disDiv[0];
        if(maxDiv==1)
        {
            next.style.display = 'none';
        }
        
    }else
    {
        area.innerText=description;
        next.style.display = 'none';        
    }
}

//GenerateHtml2 -- Start --
function GenerateHtml2(description, openHouse, resPropId, brochureFileName, brochureFileURL, APN, Address, type, x, y, street, state, city, zipCode, Bedrooms, Bathrooms, price)
{
    var div = GenerateWindowSize();
    var html = div;
    
    html = html + '<table id="tbl2" width="100%" class="TableBorder" cellpadding="0" cellspacing="0" >';
    html = html + '<tr>';
    html = html + '<td class="RowBorder">';
        html = html + '<table width = "100%">';
        html = html + '<tr width = "100%" valign=top>';
        html = html + '<td align=left class="BubbleHeadingGreen">';
            html = html + '<b>'+'Residential - '+type+'</b>'
        html = html + '</td>';
        html = html + '<td align = right >';
            html = html + '<a href="#" onclick="PrintMap('+x +','+y+')" class="LinkInBubble"> <IMG style="text-decoration:none" border=0 SRC="Images/Domains/Shared/Printer.png" alt="Print" />'                
            html = html + '</a>'
            html = html + '<a  class="LinkInBubble" href="javascript:Popup1_Feedback(\'' + APN + '\',\'' + Address + '\')" ><IMG style="text-decoration:none" border=0 SRC="Images/Domains/Shared/FeedBack.gif" alt="Feedback" /></a>';
        html = html + '</td>';        
        html = html + '</tr>';
        html = html + '</table>';    
           
    html = html + '</td>';
    html = html + '</tr >';
    
    html = html + '<tr height="100%">';
    html = html + '<td>';
    
    html = html + '<div class="BubbleTableDetail">';  
    
    html = html + '<table id ="tbl_2"  align=center class="BubbleTable" valign="top" height="100%">';

    html = html + '<tr valign="top">';
    html = html + '<td align=left>';

    html = html + '</td>';
    html = html + '</tr>';
    html = html + '<tr valign="top" >';
    html = html + '<td id="desArea" align=left style="text-align:justify" valign="top" height="100%">';
    
    html = html + description;
    
    html = html + '</td>';
    html = html + '</tr>';

    html = html + '</table>';
    
    html = html + '</div>';
    html = html + '</td>';
    html = html + '</tr>';
    
    html = html + '<tr >';
    html = html + '<td class="RowBorderNoBg">';
        html = html + '<table width = "100%">';
        html = html + '<tr width = "100%">';
        html = html + '<td align=left >';
            html = html + ' <a class="LinkInBubble" href=javascript:Popup1(' + resPropId + ')>More Detail</a>';
        html = html + '</td>';
        if(Vancouver_Domain.toLowerCase() != window.location.hostname.toLowerCase()) // other than Vancouver_Domain subdomain
        {
            html = html + '<td align=right >';                
                html = html + ' <a class="LinkInBubble" href="javascript:PopupTrulia(\'' + street + '\',\'' + city + '\',\'' + state + '\',\'' + zipCode + '\',\'' + Bedrooms + '\',\'' + Bathrooms + '\',\'' + price + '\')">Trulia Detail</a>';            
            html = html + '</td>';
        
            html = html + '<td align=right >';
                html = html + ' <a class="LinkInBubble" href="javascript:PopupZillow(\'' + street + '\',\'' + city + '\',\'' + state + '\',\'' + zipCode + '\',\'' + Bedrooms + '\',\'' + Bathrooms + '\',\'' + price + '\')">Zillow Detail</a>';            
            html = html + '</td>';
        }
        html = html + '<td align = right >';
            if(brochureFileName != '#' && brochureFileURL !='#')
            {                 
              html = html + '<a class="LinkInBubble" href=javascript:DisplayFile("'+ BrochuresPath + brochureFileURL + '")>'+brochureFileName+'</a>';               
            }
        html = html + '</td>';        
        html = html + '</tr>';
        html = html + '</table>';
    html = html + '</td>';
    html = html + '</tr >';
    
    html = html + '</table>';
    
    html = html + '</div>';
    
    return html;
}
//GenerateHtml2 -- End --

//GenerateWindowSize -- Start --
function GenerateWindowSize()
{
    var div;
    div = '<div id=\'bubbleDiv\' class="BubbleDiv">';
    return div;
}
//GenerateWindowSize -- End --

//GenerateHtml1 -- Start --
function GenerateHtml1(price, address, imageName, sqft, pricePerSqft, openHouse,Bedrooms,Bathrooms,APN,Address_c,x,y)
{   
    var div = GenerateWindowSize();
    var html = div;
    
    html = html + '<table id="tbl1" width="100%" class="TableBorder" cellpadding="0" cellspacing="0" >';
    html = html + '<tr >';    
    html = html + '<td class="RowBorder">';
        html = html + '<table width = "100%">';
        html = html + '<tr width = "100%" valign=top>';
        html = html + '<td align=left class="BubbleHeadingGreen">';
            if(address != '')
            {                
                html = html + '<b>'+Address_c+'</b>';   
             
            }   
        html = html + '</td>';
        html = html + '<td align = right >';
            html = html + '<a href="#" onclick="PrintMap('+x +','+y+')" class="LinkInBubble"> <IMG style="text-decoration:none" border=0 SRC="Images/Domains/Shared/Printer.png" alt="Print" />'                
            html = html + '</a>'
            html = html + '<a  class="LinkInBubble" href="javascript:Popup1_Feedback(\'' + APN + '\',\'' + Address_c + '\')" ><IMG style="text-decoration:none" border=0 SRC="Images/Domains/Shared/FeedBack.gif" alt="Feedback" /></a>';
        html = html + '</td>';        
        html = html + '</tr>';
        html = html + '</table>';    
           
    html = html + '</td>';        
        
    html = html + '</tr >';
    
    html = html + '<tr height="100%">';
    html = html + '<td>';
	    
    html = html + '<table id ="tbl_1" align=center class="BubbleTable" >';
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + '<img src=' + ResidentialThumbnailImagesPath + imageName + ' class="PropertyImageInBubble" >';
    
    html = html + '</td>';
    html = html + '<td>';
    html = html + '<table align=center class="BubbleTable">';
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + '<b>Price: $' + number_format(price) + '</b>';
    html = html + '</td>';
    html = html + '</tr>';
    
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + 'Sq. Ft.: ' + number_format(sqft);
    html = html + '</td>';
    html = html + '</tr>';
    
    html = html + '<tr>';
    html = html + '<td align=center>';
    html = html + 'Price / Sq. Ft.: $' + number_format(pricePerSqft);
    html = html + '</td>';
    html = html + '</tr>';
    if(Bedrooms != 0)
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + 'Bedrooms: '+Bedrooms;
        html = html + '</td>';
        html = html + '</tr>';
    }
    
    if(Bathrooms != 0)
    {
        html = html + '<tr>';
        html = html + '<td align=center>';
        html = html + 'Bathrooms: '+Bathrooms;
        html = html + '</td>';
        html = html + '</tr>';
    }
    
    html = html + '</table>';
    html = html + '</td>';
    html = html + '</tr>';
    html = html + '</table>';
    
    html = html + '</td>';
    html = html + '</tr>';   
    html = html + '</table>';
    
    html = html + '</div>';

    return html;
}
//GenerateHtml1 -- End --

//CreateMarker -- Start --
function CreateMarker(point, toolTipText, html1, html2, html3, i, icon)
{
    var infoTabs = [
    new GInfoWindowTab(firstTabName, html1), 
    new GInfoWindowTab(secondTabName, html2),
    new GInfoWindowTab(thirdTabName, html3)
    ]; 

    var marker = new GMarker(point, icon);
    
    marker.tooltip = toolTipText;
    
    GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowTabsHtml(infoTabs);
    });

    map.addOverlay(marker);

    GEvent.addListener(marker,"mouseover", function() {
    ShowToolTip(marker);
    });
    
    GEvent.addListener(marker,"mouseout", function() {
    toolTip.style.visibility="hidden"
    });
    
    GEvent.addListener(marker,"click", function() {    
    toolTip.style.visibility="hidden"
    });
    
    GEvent.addListener(marker, "infowindowopen", function() {testHeight();});
        
    markers.push(marker);
    html1s.push(html1);
    html2s.push(html2);
    html3s.push(html3);
}
//CreateMarker -- End --

}
//]]>
