updated google map sample part1

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Residential.aspx.cs" Inherits="Residential" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    
<title>Residential Iframe</title>
    
<link href="RESULTS.css" rel="stylesheet" type="text/css" />

    
<script type="text/javascript">
<!-- Original:  Cyanide_7 (leo7278@hotmail.com) -->
<!-- Web Site:  http://www7.ewebcity.com/cyanide7 -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function formatCurrency(num) {
num 
= num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num 
= "0";  
sign 
= (num == (num = Math.abs(num)));
num 
= Math.floor(num*100+0.50000000001);
cents 
= num%100;
num 
= Math.floor(num/100).toString(); 
if(cents<10)
cents 
= "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length
-(4*i+3));
//return (((sign)?'':'-') + '$' + num + '.' + cents);
return (((sign)?'':'-'+ '$' + num);
}

//  End -->
    
</script>

    
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA0fjp2tHrrQJwoaRp8r_sYxR9fR65Vek3QPwU0sVxyfrqv-3SrxSOi2QPW6Z4SZY2sm8l2ZDVezrplA"
        type
="text/javascript"></script>

    
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=ABQIAAAA0fjp2tHrrQJwoaRp8r_sYxR9fR65Vek3QPwU0sVxyfrqv-3SrxSOi2QPW6Z4SZY2sm8l2ZDVezrplA"
        type
="text/javascript"></script>

    
<script src="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.js" type="text/javascript"></script>

    
<link href="http://www.google.com/uds/css/gsearch.css" rel="stylesheet" type="text/css" />
    
<link href="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.css" rel="stylesheet"
        type
="text/css" />

    
<script type="text/javascript">    
var addressCheckedCount;
var goodZipcodeList;
var totalList;
var goodLongitudeList;
var goodLatitudeList;
var map;
var smallMap;
var geocoder;
var request=false;
var minPrice = 0;
var maxPrice = 6000000;
var priceRange = 2000000;
var bedroom = 1;
var bedroomRange = 8;
var bathroom = 1;
var bathroomRange = 8;
var type = "";
var parking= "";
var leftPointerDoDrag = false;
var rightPointerDoDrag = false;
var singlePointerDoDrag = false;
var currentLeftPointer;
var currentRightPointer;
var currentSinglePointer;
var currentBar;
var leftPointerMouseOffset;
var rightPointerMouseOffset;
var singlePointerMouseOffset;
var gdir;
var baseIcon = new GIcon();
baseIcon.image 
= "http://www.thesarasotamls.com/mapfiles/orange_marker.png";
//baseIcon.shadow = "http://www.thesarasotamls.com/mapfiles/blue_marker.png";
baseIcon.iconSize = new GSize(2023);
baseIcon.shadowSize 
= new GSize(2023);
baseIcon.iconAnchor 
= new GPoint(2023);
baseIcon.infoWindowAnchor 
= new GPoint(92);
baseIcon.infoShadowAnchor 
= new GPoint(1825);
//joey 2.20
var nearbyIcon = new GIcon();
nearbyIcon.image 
= "http://www.ottawaplus.ca/feature/emergency_numbers/60273/images/sign_hospital.gif";
nearbyIcon.iconSize 
= new GSize(2323);
nearbyIcon.shadowSize 
= new GSize(2323);
nearbyIcon.iconAnchor 
= new GPoint(2323);
nearbyIcon.infoWindowAnchor 
= new GPoint(92);
nearbyIcon.infoShadowAnchor 
= new GPoint(1825);
//end
var tooltip = document.createElement("div");
tooltip.setAttribute(
"id","marker_tooltip");
tooltip.style.border
="1px #2E68AF solid";
tooltip.style.backgroundColor
="#ffffff";
tooltip.style.fontWeight
="bold";
tooltip.style.overflow
="hidden";
var area;
var currentMLS;
var currentBaths;
var currentBeds;
var currentPrice;
var currentCommunity;
var currentSiteInflue;
var currentParking;
var currentYearBuilt;
var currentType;
var currentPictureCount;
var currentInformation;
var currentTotalFloorArea;
var currentTotalArea;
var currentZipCode;
var maxPicturesInOneRow;
var currentShowPosition;
//joey 2.12
var currentLongitude;
var currentLatitude;
//end

//joey 2.13
var currentAddress;
//end

//joey 2.13
var markerList;
var markerMLSList;
var side_bar_html = "";    
//end

//joey 2.19
var markerAddressList;
var markerZipcodeList;
var markerIndex=-1;
var triedAddressForLocation;
//end

//joey 2.20
var markerLongitudeList;
var markerLatitudeList;
//end

//joey 2.14
var latitudeDifference=0.01;
var longitudeDifference=0.015;
var nearByLatitudeDifference=0.02;
var nearByLongitudeDifference=0.03;
var draggableMarker;
//end

//joey 2.20
var nearByTitleList;
var nearByCityList;
var nearByRegionList;
var nearByCountryList;
var nearByLongitudeList;
var nearByLatitudeList;
var nearByPhoneList;
//end

//joey 2.12
function buildDetails(content)
{
    
var temp = content.split("%^_^%");
    currentBaths
=temp[0];
    currentBeds
=temp[1];
    currentMLS
=temp[2];
    currentPrice
=temp[3];
    currentCommunity
=temp[4];
    currentSiteInflue
=temp[5];
    currentParking
=temp[6];
    currentYearBuilt
=temp[7];
    currentType
=temp[8];
    currentPictureCount
=temp[9];
    currentInformation
=unescape(temp[10]);
    currentTotalFloorArea
=temp[11];
    currentTotalArea
=temp[12];
    currentZipCode
=temp[13];
    currentLongitude
=temp[14];
    currentLatitude
=temp[15];
    
//joey 2.13
    currentAddress=temp[16];
    
//end
    var DVaddress = "";
    DVaddress 
+= "" + unescape(currentAddress);
    document.getElementById(
"detail_address").innerHTML = DVaddress;
    
var content = "";
    
//joey 2.15 it will show unknown runtime error when h3 tag is added
    content += ""+ formatCurrency(currentPrice);
    content 
+= "";
    
//end
    content += currentBeds+" beds "+fixBathNumber(currentBaths)+" baths ";
    content 
+= "<br/>" + currentTotalArea +" sqft";
    content 
+= "<br/>";
    content 
+= "Community: " + currentCommunity;
    content 
+= "<br/>";
    content 
+= "Parking: " + unescape(currentParking);
    content 
+= "<br/>";
    content 
+= "Year built: "+currentYearBuilt;
    content 
+= "<br/>";
    content 
+= "Type: " + fixType(currentType);
    content 
+= "<br/>";
    content 
+= "Total floor area: "+fixSqft(currentTotalFloorArea);
    content 
+= "<br/>";
    content 
+= "Total area: "+fixSqft(currentTotalFloorArea);
    document.getElementById(
"detail_house").innerHTML = content;
    content 
= "";
    content 
+= currentInformation;
    document.getElementById(
"detail_description").innerHTML = content;
    addSmallMapPoint(currentLongitude,currentLatitude);
    content 
= "";
    content 
+= "<img src=\"http://www2.creb.com/";
    content += currentMLS.substring(currentMLS.length-2,currentMLS.length)+"/";
    content 
+= currentMLS+"_1.jpg\" width=\"300\" style=\"border:1px solid\" onError='showDefaultPicture(this);' />";
   
    document.getElementById(
"detail_picture").innerHTML = content;
    currentShowPosition
=1;
    maxPicturesInOneRow
=5;
    buildPictureListContent();
}

//end
function changeImage(index,object)
{
    
var content="";
    content 
+= "<img src=\"http://www2.creb.com/";
    content += currentMLS.substring(currentMLS.length-2,currentMLS.length)+"/";
    content 
+= currentMLS+"_"+index+".jpg\" width=\"300\" style=\"border:1px solid\" onError='showDefaultPicture(this);' />";
    document.getElementById("detail_picture").innerHTML=content;
    
//joey 2.15
    moveByTravis(object);
    
//end
}

//joey 2.12 2.19
function addSmallMapPoint(longitude,latitude)
{
    
var point = new GLatLng(latitude,longitude);
    
var icon = new GIcon(baseIcon);
    
var marker = new GMarker(point,icon);
    smallMap.clearOverlays();
    smallMap.addOverlay(marker);
    smallMap.checkResize();
    smallMap.setCenter(point, 
14);
}

//end
try
{
 request 
= new XMLHttpRequest();//Firefox
}

catch(trymicrosoft)
{
 
try 
 
{
    request 
= new ActiveXObject("Msxml2.XMLHTTP.5.0");//New IE
 }
 
 
catch(othermicrosoft)
 
{
    
try 
    
{
          request 
= new ActiveXObject("Microsoft.XMLHTTP");//Old IE
    }
 
    
catch(failed)
    
{
          request 
= false;//Unknown browser
    }

 }

}


function Rectangle(bounds, opt_weight, opt_color) 
{
  
this.bounds_ = bounds;
  
this.weight_ = opt_weight || 2;
  
this.color_ = opt_color || "#888888";
}

Rectangle.prototype 
= new GOverlay();
Rectangle.prototype.initialize 
= function(map) 
{
  
var div = document.createElement("div");
  div.style.border 
= this.weight_ + "px solid " + this.color_;
  div.style.position 
= "absolute";
  map.getPane(G_MAP_MAP_PANE).appendChild(div);
  
this.map_ = map;
  
this.div_ = div;
}
;
Rectangle.prototype.remove 
= function() 
{
  
this.div_.parentNode.removeChild(this.div_);
}
;
Rectangle.prototype.copy 
= function() 
{
  
return new Rectangle(this.bounds_, this.weight_, this.color_,
                       
this.backgroundColor_, this.opacity_);
}
;
Rectangle.prototype.redraw 
= function(force) 
{
  
if (!force) return;
  
var c1 = this.map_.fromLatLngToDivPixel(this.bounds_.getSouthWest());
  
var c2 = this.map_.fromLatLngToDivPixel(this.bounds_.getNorthEast());
  
this.div_.style.width = Math.abs(c2.x - c1.x) + "px";
  
this.div_.style.height = Math.abs(c2.y - c1.y) + "px";
  
this.div_.style.left = (Math.min(c2.x, c1.x) - this.weight_) + "px";
  
this.div_.style.top = (Math.min(c2.y, c1.y) - this.weight_) + "px";
}
;
//joey 2.14
function buildSurroundingList(content)
{
    
var number = content.split("@^_^@");
    
if(number.length>75)
    
{
        alert(number.length);
    }

    
else
    
{
        buildList(content);
        addDraggableMarker(draggableMarker.getPoint().lat(),draggableMarker.getPoint().lng(),
14);
    }

}

//end
//
joey 2.20
function clickSearchNearBy()
{
    
if(markerIndex!=-1)
    
{
        
var queryString="";
        queryString
+="nearBy&^-^&";
        
if(document.getElementById("cb_SearchByHospital").checked)
        
{
            queryString
+=document.getElementById("cb_SearchByHospital").value+",";
        }

        
if(document.getElementById("cb_SearchBySchool").checked)
        
{
            queryString
+=document.getElementById("cb_SearchBySchool").value+",";
        }

        
if(document.getElementById("cb_SearchByMall").checked)
        
{
            queryString
+=document.getElementById("cb_SearchByMall").value+",";
        }

        
if(queryString!="nearBy&^-^&")
        
{
            queryString
=queryString.substring(0,queryString.length-1);
            queryString
+="!^-^!";
            queryString
+=nearByLongitudeDifference;
            queryString
+="!^-^!";
            queryString
+=nearByLatitudeDifference;
            queryString
+="!^-^!";
            queryString
+=markerLongitudeList[markerIndex];
            queryString
+="!^-^!";
            queryString
+=markerLatitudeList[markerIndex];
            queryString
+="!^-^!";
            queryString
=queryString.substring(0,queryString.length-5);
            
//alert(queryString);
            sendRequest(queryString);
        }

    }

}

function buildNearByList(content)
{
    
var nearByList = content.split("@^_^@");
    nearByTitleList 
= new Array();
    nearByCityList 
= new Array();
    nearByRegionList 
= new Array();
    nearByCountryList 
= new Array();
    nearByLongitudeList 
= new Array();
    nearByLatitudeList 
= new Array();
    nearByPhoneList 
= new Array();
    
for(var i=0;i<nearByList.length;i++)
    
{
        nearByTitleList[i]
=unescape(nearByList[i].split("%^_^%")[0]);
        nearByCityList[i]
=unescape(nearByList[i].split("%^_^%")[1]);
        nearByRegionList[i]
=unescape(nearByList[i].split("%^_^%")[2]);
        nearByCountryList[i]
=unescape(nearByList[i].split("%^_^%")[3]);
        nearByLongitudeList[i]
=unescape(nearByList[i].split("%^_^%")[4]);
        nearByLatitudeList[i]
=unescape(nearByList[i].split("%^_^%")[5]);
        nearByPhoneList[i]
=unescape(nearByList[i].split("%^_^%")[6]);
        markNearBySearchResults(nearByTitleList[i],nearByCityList[i],nearByRegionList[i],nearByCountryList[i],nearByLongitudeList[i],nearByLatitudeList[i],nearByPhoneList[i]);
    }

}

function markNearBySearchResults(title,city,region,country,longitude,latitude,phone)
{
    
var point = new GLatLng(latitude,longitude);
    
var icon = new GIcon(nearbyIcon);
    
var marker = new GMarker(point,icon);
    map.addOverlay(marker);
    GEvent.addListener
    (
        marker, 
        
"click"
        
function() 
        
{
            
var content = "";
            content 
+= "<table>";
            content 
+= "<tr>";
            content 
+= "<td>";
            content 
+= title;
            content 
+= "</td>";
            content 
+= "</tr>";
            content 
+= "<tr>";
            content 
+= "<td>";
            content 
+= phone;
            content 
+= "</td>";
            content 
+= "</tr>";
            content 
+= "</table>";
            marker.openInfoWindowHtml(content);
        }

    ); 
}

//end
//
joey 2.19
function clearOverlaysExceptTheDraggableMarker()
{
    map.clearOverlays();
    addDraggableMarker(draggableMarker.getPoint().lat(),draggableMarker.getPoint().lng(),
14);
}

function clearAllOverlays()
{
    map.clearOverlays();
}

//end
function buildList(content)
{
  resetSidebar();
  
//joey 2.19
  side_bar_html="";
  markerList
=new Array();
  markerMLSList
=new Array();
  markerAddressList
=new Array();
  markerZipcodeList
=new Array();
  markerLongitudeList
=new Array();
  markerLatitudeList
=new Array();
  map.clearOverlays();
  
//end
  totalList = content.split("@^_^@");
  
//joey 2.13
  var zipcodeList= new Array();
  
//end
  var mlsList= new Array();
  
var lastTwoDigitsList= new Array();
  
var priceList= new Array();
  
var communityList = new Array();
  
var bedsList = new Array();
  
var bathsList = new Array();
  
var typeList = new Array();
  
var sqftList = new Array();
  
var picCount= new Array();
  
//joey 2.12
  var longitudeList = new Array();
  
var latitudeList = new Array();
  
//end
  //joey 2.13
  var addressList= new Array();
  
//end
  for(var i =0; i< totalList.length; i++)
  
{
    
//joey 2.13
    zipcodeList[i]=totalList[i].split("%^_^%")[0];
    
//end
    mlsList[i]=totalList[i].split("%^_^%")[1];
    lastTwoDigitsList[i]
=totalList[i].split("%^_^%")[2];
    priceList[i]
=totalList[i].split("%^_^%")[3];
    communityList[i]
=totalList[i].split("%^_^%")[4];
    bedsList[i]
=totalList[i].split("%^_^%")[5];
    bathsList[i]
=totalList[i].split("%^_^%")[6];
    typeList[i]
=totalList[i].split("%^_^%")[7];
    sqftList[i]
=totalList[i].split("%^_^%")[8];
    picCount[i]
=totalList[i].split("%^_^%")[9];
    
//joey 2.12
    longitudeList[i]=totalList[i].split("%^_^%")[10];
    latitudeList[i]
=totalList[i].split("%^_^%")[11];
    
//end
    //joey 2.13
    addressList[i]=totalList[i].split("%^_^%")[12];
    
//end
  }

  addressCheckedCount 
= 0;
  
//joey 2.12
  makeCorrectListAndSetCenter(zipcodeList,mlsList,lastTwoDigitsList,priceList,communityList,bedsList,bathsList,typeList,sqftList,picCount,longitudeList,latitudeList,addressList);
  
//end
}

//joey 2.12
function makeCorrectListAndSetCenter(zipcodeList,mlsList,lastTwoDigitsList,priceList,communityList,bedsList,bathsList,typeList,sqftList,picCount,longitudeList,latitudeList,addressList)
{
   map.clearOverlays();
   goodZipcodeList 
= new Array();
   goodLongitudeList 
= new Array();
   goodLatitudeList 
= new Array();
   
for(i=0;i<addressList.length;i++)
   
{
      
//joey 2.13
      checkAndAddPoint(zipcodeList[i],'http://www2.creb.com/'+lastTwoDigitsList[i]+'/'+mlsList[i],"",priceList[i],communityList[i],bedsList[i],bathsList[i],typeList[i],mlsList[i],sqftList[i],picCount[i],longitudeList[i],latitudeList[i],addressList[i]);
      
//end
   }

}

//end
//
joey 2.12
function checkAndAddPoint(zipcode, picture, link, price, community, beds, baths, type, mls,sqft,pictureCount,longitude,latitude,address)
{
   
//joey 2.12
   if(longitude!=""&&latitude!=""&&longitude!=undefined&&latitude!=undefined&&longitude!=null&&latitude!=null&&longitude!="null"&&longitude!="null")
   
{
       
var point = new GLatLng(latitude,longitude);
       
//joey 2.12
       setGoogleMapLocations(zipcode, picture, link, price, community, beds, baths, type, mls,sqft,pictureCount,longitude,latitude,address);
       
//end
       goodZipcodeList[goodZipcodeList.length] = zipcode;
       goodLongitudeList[goodLongitudeList.length] 
= point.lng();
       goodLatitudeList[goodLatitudeList.length] 
= point.lat();
   }

   addressCheckedCount
++;
   
if(addressCheckedCount >= totalList.length)
   
{
        setRelativeCenterPoint();
   }

   
//end
}

//end

//joey 2.12
function setRelativeCenterPoint()
{
  
var relativeLongitudePlusLatitude = 10000000000;
  
var averageLongitude = getAverageLongitude();
  
var averageLatitude = getAverageLatitude();
  
var centerLongitude;
  
var centerLatitude;
  
for(var i=0;i<goodZipcodeList.length;i++)
  
{
    
var tempLat=goodLatitudeList[i]-averageLatitude;
    tempLat
=Math.abs(tempLat);
    
var tempLng=goodLongitudeList[i]-averageLongitude;
    tempLng
=Math.abs(tempLng);
    
var totalDifference = tempLat+tempLng;
    
if(totalDifference<relativeLongitudePlusLatitude)
    
{
        relativeLongitudePlusLatitude 
= Math.abs(goodLatitudeList[i]-averageLatitude)+Math.abs(goodLongitudeList[i]-averageLongitude);
        centerLongitude
=goodLongitudeList[i];
        centerLatitude
=goodLatitudeList[i];
    }

  }

  
if(centerLongitude!=undefined&&centerLatitude!=undefined)
  
{
    setGoogleMapCommunity(centerLongitude,centerLatitude);
  }

}
  
//end
//
joey 2.13
function getAverageLatitude()
{
  
var total=0;
  
for(var i =0;i<goodLatitudeList.length;i++)
  
{
    
var temp=goodLatitudeList[i];
    sign 
= (temp == (temp = Math.abs(temp)));
    
if(sign)
    
{
        total 
= total + temp;
    }

    
else
    
{
        total 
= total - temp;
    }

  }

  
return total/goodLatitudeList.length;
}

function getAverageLongitude()
{
  
var total=0;
  
for(var i=0;i<goodLongitudeList.length;i++)
  
{
    
var temp=goodLongitudeList[i];
    sign 
= (temp == (temp = Math.abs(temp)));
    
if(sign)
    
{
        total 
= total + temp;
    }

    
else
    
{
        total 
= total - temp;
    }

  }

  
return total/goodLongitudeList.length;
}

//end
function initialize() 
{      
 
if (GBrowserIsCompatible()) 
 
{
      map 
= new GMap2(document.getElementById("map_canvas"));
      geocoder 
= new GClientGeocoder();
      map.addControl(
new GSmallMapControl());
      map.addControl(
new GMapTypeControl());
      
var center = new GLatLng('51.053728''-114.062474')
      map.setCenter(center, 
6);
      gdir 
= new GDirections(map,document.getElementById("directions"));
      GEvent.addListener(gdir, 
"load", onGDirectionsLoad);
      GEvent.addListener(gdir, 
"error", handleErrors);
      map.getContainer().appendChild(tooltip); 
      smallMap 
= new GMap2(document.getElementById("small_map"));
      smallMap.addControl(
new GSmallMapControl());
      smallMap.addControl(
new GMapTypeControl());
      smallMap.setCenter(center, 
6);
      document.getElementById(
"side_bar").style.display="none";
      
     
//  ======== Add a map overview ==========
      //  ======== save a reference to the control =========
//
      var ovcontrol = new GOverviewMapControl(new GSize(100,100)); 
//
      map.addControl(ovcontrol);

      
//  ======== A function to adjust the positioning of the overview ========
//
      function positionOverview(x,y) {
//
        var omap=document.getElementById("map_overview");
//
        omap.style.left = x+"px";
//
        omap.style.top = y+"px";
//
        
//
        // == restyling ==
//
        omap.firstChild.style.border = "1px solid gray";

//        omap.firstChild.firstChild.style.left="4px";
//
        omap.firstChild.firstChild.style.top="4px";
//
        omap.firstChild.firstChild.style.width="190px";
//
        omap.firstChild.firstChild.style.height="190px";
//
      }
//
      
//
      // ======== get a reference to the GMap2 ===========
//
      var ovmap = ovcontrol.getOverviewMap();
//
      
//
      
//
      //  ======== Cause the overview to be positioned AFTER IE sets its initial position ======== 
//
      setTimeout("positionOverview(558,254)",1);
//
      
//
      //  ======== change the overview map type AFTER the overview finisges initializing =====
//
      setTimeout("ovmap.setMapType(G_SATELLITE_MAP);",1);
  }

}
    
//joey 2.19
function setDirections(fromAddress, toAddress, locale) 
{
    triedAddressForLocation
=false;
    
var locale = "en";
    
var fromAddress = document.getElementById("FromAddress").value;
    
if(markerIndex!=-1)
    
{
        document.getElementById(
"side_bar").style.display="none";
        document.getElementById(
"closeSidebar_now").style.display="none";
        document.getElementById(
"leftSpace").style.display="none";
        document.getElementById(
"GDirection").style.display="none";
        document.getElementById(
"cb_SearchByHospital").style.display="none";
        document.getElementById(
"lb_SearchByHospital").style.display="none";
        document.getElementById(
"cb_SearchBySchool").style.display="none";
        document.getElementById(
"lb_SearchBySchool").style.display="none";
        document.getElementById(
"cb_SearchByMall").style.display="none";
        document.getElementById(
"lb_SearchByMall").style.display="none";
        document.getElementById(
"searchNearBy").style.display="none";
        document.getElementById(
"FromAddress").style.display="none";
        document.getElementById(
"searchCriteriaLeft").style.display="none";
        document.getElementById(
"openSidebar_now").style.display="none";
        document.getElementById(
"directions").style.display="block";
        document.getElementById(
"closeDirections_now").style.display="block";
        
var toAddress = unescape(markerAddressList[markerIndex]);
        gdir.load(
'from: '+fromAddress+' to: '+toAddress,"locale": locale });
    }

}

function onGDirectionsLoad() 
{
    document.getElementById(
"getDistance").innerHTML = gdir.getSummaryHtml();
}

function handleErrors()
{
    
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
    
{
        
if(triedAddressForLocation==false)
        
{
            triedAddressForLocation
=true;
            
var locale = "en";
            
var fromAddress = document.getElementById("FromAddress").value;
            
if(markerIndex!=-1)
            
{
                
var toAddress = unescape(markerZipcodeList[markerIndex]);
                gdir.load(
'from: '+fromAddress+' to: '+toAddress,"locale": locale });
            }

        }

        
else
        
{
            alert(
"No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
        }

    }

    
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
    
{
        alert(
"A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
    
{
        alert(
"The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
    
{
        alert(
"The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
    }

    
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
    
{
        alert(
"A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
    }

    
else
    

        alert(
"An unknown error occurred.");
    }

}

//end
function sendRequest(queryString)
{
   isCommunityAlreadySet 
= false;
   url
=escape("search.aspx")+"?random=" + Math.random();//use a random number to avoid cache
   request.open("Post",url,true);//connection method
   request.onreadystatechange=showProcess;//show Process method
   request.setRequestHeader('Content-Type''application/x-www-form-urlencoded; charset=utf-8');
   request.send(
"Search="+escape(queryString));
}

function showProcess() 
{
   
if(request.readyState == 4)//finished
   {
      
if(request.status == 200)//normal
      {
         eval(request.responseText);
//insert script to add locations to google map
      }

   }

}

function setGoogleMapCity(latitude, longtitude)
{
 
if (GBrowserIsCompatible()) 
 
{
      map.clearOverlays();
      map.setCenter(
new GLatLng(latitude, longtitude), 10);
 }

}

//joey 2.14 2.19
function addDraggableMarker(latitude, longtitude, zoom)
{
 
if (GBrowserIsCompatible()) 
 
{
    
var center = new GLatLng(latitude, longtitude)
    map.setCenter(center, zoom);
    
var marker = new GMarker(center, {draggable: true});
    
//joey 2.14
    draggableMarker=marker;
    
//end
    var side_bar_html = "";
    GEvent.addListener
    (
        marker, 
        
"dragstart"
        
function() 
        
{
          
//joey 2.19
          closeSidebar();
          
//end
          map.closeInfoWindow();
          addArea(marker);
        }

    );
    GEvent.addListener
    (
        marker, 
        
"drag"
        
function() 
        
{
          marker.openInfoWindowHtml(
"The surrounding search results<br> are for houses within a 10 <br> block radius of this pointer.");
          addArea(marker);
        }

    );
    
//joey 2.14
    GEvent.addListener
    (
        marker, 
        
"dragend"
        
function() 
        
{
          marker.openInfoWindowHtml(
"The surrounding search results<br> are for houses within a 10 <br> block radius of this pointer.");
          addArea(marker);
          searchSurrounding(marker.getPoint().lng(),marker.getPoint().lat());
        }

    );
    map.addOverlay(marker);
    addArea(marker);
    
//end
 }

}

//end
function setGoogleMapCityDistrict(latitude, longitude)
{
    
//joey 2.19
    map.clearOverlays();
    addDraggableMarker(latitude,longitude,
11);
}

//joey 2.14
function searchSurrounding(longitude,latitude)
{
    
//joey 2.19
    var queryString="surrounding&^-^&";
    queryString
+=longitudeDifference;
    queryString
+="!^-^!";
    queryString
+=latitudeDifference;
    queryString
+="!^-^!";
    queryString
+=longitude;
    queryString
+="!^-^!";
    queryString
+=latitude;
    queryString
+="!^-^!";
    queryString
+=minPrice;
    queryString
+="!^-^!";
    queryString
+=maxPrice;
    queryString
+="!^-^!";
    queryString
+=bedroom;
    queryString
+="!^-^!";
    queryString
+=bathroom;
    queryString
+="!^-^!";
    queryString
+=type;
    queryString
+="!^-^!";
    queryString
+=parking;
    sendRequest(queryString);
    
//end
}

//end
//
joey 2.14
function addArea(marker)
{
    
if(area)
    
{
        map.removeOverlay(area);
    }

    
var rectBounds = new GLatLngBounds
    (
        
new GLatLng(marker.getPoint().lat() - latitudeDifference, marker.getPoint().lng() - longitudeDifference),
        
new GLatLng(marker.getPoint().lat() + latitudeDifference, marker.getPoint().lng() + longitudeDifference)
    );
    area 
= new Rectangle(rectBounds);
    map.addOverlay(area);
}

//end
//
joey 2.12
function setGoogleMapCommunity(longitude,latitude)

    
var point = new GLatLng(latitude,longitude);
    map.setCenter(point, 
12);
}

//end
function showDefaultPicture(picture)
{
    picture.src 
= "http://tbn0.google.com/images?q=tbn:x-EdBG8y--9POM:http://farm3.static.flickr.com/2400/1789531625_45445f379b.jpg";
}

//Pieter 2.14
function mouseOverListing(mls, type)
{
    
var index;
    
for(var i=0;i<markerMLSList.length;i++)
    
{
        
if(markerMLSList[i]==mls)
        
{
            index
=i;
            
break;
        }

    }

    
//alert(mls);
    markerList[index].setImage("Images/red_marker.png");
}

function mouseOutListing(mls, type)
{
    
var index;
    
for(var i=0;i<markerMLSList.length;i++)
    
{
        
if(markerMLSList[i]==mls)
        
{
            index
=i;
            
break;
        }

    }

    
//alert(mls);
    markerList[index].setImage("http://www.thesarasotamls.com/mapfiles/orange_marker.png");
}

function myclick(address, picture, link, price, community, beds, baths, type, mls,sqft,pictureCount,longitude,latitude)
{
    
var index;
    
for(var i=0;i<markerMLSList.length;i++)
    
{
        
if(markerMLSList[i]==mls)
        
{
            index
=i;
            markerIndex
=index;
            
break;
        }

    }

    
var content = "";
    content 
= content + "<table>";
    content 
= content + "<tr>";
    content 
= content + "<td align = \"left\" rowspan=10>";
    content 
= content + "<img src=\"";
    if(pictureCount==1)
    {
    content = content + picture+
"_1.jpg";
    }
    else
    {
    content = content + picture+
"_2.jpg";
    }
    content = content + 
"\" align=\"left\" width=\"180\" height=\"110\" onError='showDefaultPicture(this);'/>";
    content 
= content + "</td>";
    content 
= content + "<td align = \"left\"><b>";
    content 
= content + formatCurrency(price);
    content 
= content + "</b></td>";
    content 
= content + "</tr>";
    content 
= content + "<tr>";
    content 
= content + "<td align = \"left\"><b>";
    content 
= content + community;
    content 
= content + "</b></td>";
    content 
= content + "</tr>";
    content 
= content + "<tr>";
    content 
= content + "<td align = \"left\">";
    content 
= content + "<b>Beds:</b> "+beds+""+" <b>Baths:</b> "+fixBathNumber(baths);
    content 
= content + "</td>";
    content 
= content + "</tr>";
    content 
= content + "<tr>";
    content 
= content + "<td align = \"left\"><b>";
    content 
= content + fixType(type);
    content 
= content + "</b></td>";
    content 
= content + "</tr>";
    content 
= content + "<tr>";
    content 
= content + "<td align = \"left\">";
    content 
= content + "<b>Square feet:</b> "+fixSqft(sqft);
    content 
= content + "</td>";
    content 
= content + "</tr>";
    content 
= content + "<tr>";
    content 
= content + "<td align = \"left\">";
    content 
= content + "<b><a href=\"\" onClick=\"showDetailPage('"+mls+"');return false\">View Details</a></b>";
    content 
= content + "</td>";
    content 
= content + "</tr>";
    content 
= content + "</table>";
    markerList[index].openInfoWindowHtml(content);
    tooltip.style.visibility
="hidden";
    markerList[index].setImage(
"http://www.thesarasotamls.com/mapfiles/blue_marker.png");
}

//end
//
joey 2.12
function setGoogleMapLocations(zipcode, picture, link, price, community, beds, baths, type, mls,sqft,pictureCount,longitude,latitude,address)
{
    
var point = new GLatLng(latitude,longitude);
    
var icon = new GIcon(baseIcon);
    
var marker = new GMarker(point,icon);
    markerList[markerList.length]
=marker;
    markerMLSList[markerMLSList.length]
=mls;
    markerAddressList[markerAddressList.length]
=address;
    markerZipcodeList[markerZipcodeList.length]
=zipcode;
    markerLongitudeList[markerLongitudeList.length]
=longitude;
    markerLatitudeList[markerLatitudeList.length]
=latitude;
    
var html = "";
    
//fills side_bar_html with the lisitngs returned in the search
    side_bar_html += '<div class="sbAddress"">';
    
//joey 2.15
    side_bar_html += '<a href="javascript:myclick(\''+ address+"\',\'"+ picture+"\',\'"+  link+"\',\'"+  price+"\',\'"+  community+"\',\'"+  beds+"\',\'"+ baths+"\',\'"+ type+"\',\'"+  mls+"\',\'"+ sqft+"\',\'"+ pictureCount+"\',\'"+ longitude+"\',\'"+ latitude+'\')" onmouseover="mouseOverListing(\''+ mls +"\',\'" + type + '\')"  onmouseout="mouseOutListing(\''+ mls + "\',\'" + type + '\')" >'  + unescape(address) + '</a><br></div>';
    
//end
    side_bar_html += '<div class="sbInfo"><img width="70" height="50"  style="border:1px outset #666; float:left; margin-right:2px; "';
    side_bar_html 
+=  "src='"+picture+"_1.jpg'";
    side_bar_html 
+= "onError='showDefaultPicture(this);' />";
    side_bar_html 
+= ''+formatCurrency(price)+'<br>';
    side_bar_html 
+= beds+ " Bderoom "+ fixBathNumber(baths) +" Baths <br>";
    side_bar_html 
+= community + '<br><br>';
   
// side_bar_html +=  "<a href=\"\" onClick=\"showDetailPage('"+mls+"');return false\">View Details</a>";
    side_bar_html += '</div>'
   
   
    html 
+= "<div style='width: 192px;height: auto;test-align: center; padding: 5px;'>";
    html 
+= "<h5 style='background-color:#3157A3;color:#fff;font-size:11px;padding: 5px;margin:0 0 5px 0'>";
    html 
+= "Click For More Information";
    html 
+= "</h5>";
    html 
+= "<img width='190' height='115' style='border:1px solid #666' ";
    html 
+= "src='"+picture+"_1.jpg'";
    html 
+= " onError='showDefaultPicture(this);'>";
    html 
+= "<p style='margin-bottom:0'>"+formatCurrency(price)+"</p></div>";
    marker.tooltip 
= html;
    map.addOverlay(marker);
    GEvent.addListener
    (
        marker, 
        
"click"
        
function() 
        
{
            
var content = "";
            content 
= content + "<table>";
            content 
= content + "<tr>";
            content 
= content + "<td align = \"left\" rowspan=10>";
            content 
= content + "<img src=\"";
            if(pictureCount==1)
            {
            content = content + picture+
"_1.jpg";
            }
            else
            {
            content = content + picture+
"_2.jpg";
            }
            content = content + 
"\" align=\"left\" width=\"180\" height=\"110\" onError='showDefaultPicture(this);'/>";
            content 
= content + "</td>";
            content 
= content + "<td align = \"left\"><b>";
            content 
= content + formatCurrency(price);
            content 
= content + "</b></td>";
            content 
= content + "</tr>";
            content 
= content + "<tr>";
            content 
= content + "<td align = \"left\"><b>";
            content 
= content + unescape(community);
            content 
= content + "</b></td>";
            content 
= content + "</tr>";
            content 
= content + "<tr>";
            content 
= content + "<td align = \"left\">";
            content 
= content + "<b>Beds:</b> "+beds+""+" <b>Baths:</b> "+fixBathNumber(baths);
            content 
= content + "</td>";
            content 
= content + "</tr>";
            content 
= content + "<tr>";
            content 
= content + "<td align = \"left\"><b>";
            content 
= content + fixType(type);
            content 
= content + "</b></td>";
            content 
= content + "</tr>";
            content 
= content + "<tr>";
            content 
= content + "<td align = \"left\">";
            content 
= content + "<b>Square feet:</b> "+fixSqft(sqft);
            content 
= content + "</td>";
            content 
= content + "</tr>";
            content 
= content + "<tr>";
            content 
= content + "<td align = \"left\">";
            content 
= content + "<b><a href=\"\" onClick=\"showDetailPage('"+mls+"');return false\">View Details</a></b>";
            content 
= content + "</td>";
            content 
= content + "</tr>";
            content 
= content + "</table>";
            marker.openInfoWindowHtml(content);
            tooltip.style.visibility
="hidden";
            
        }

    );           
    GEvent.addListener
    (
        marker, 
"mouseover",  function() 
        
{
       
            tooltip.innerHTML 
= marker.tooltip;
            marker.setImage(
"http://www.thesarasotamls.com/mapfiles/blue_marker.png");
            
//This changes the color of the icon that is currently being moused over
            var gPoint=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
            
var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
            
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - gPoint.x,- offset.y + gPoint.y -190)); 
            pos.apply(tooltip);
            tooltip.style.visibility
="visible";
            
        }

    );
    GEvent.addListener
    (
        marker,
        
'mouseout',
        
function() 
        
{
            tooltip.style.visibility
="hidden";
            
//Returns the icon to origional color after mouseout
            marker.setImage("http://www.thesarasotamls.com/mapfiles/orange_marker.png"); 
           
        }

    ); 
}

function populateSidebar(side)//fills the lisitngs sidebar with search results
{
    document.getElementById(
"side_bar").innerHTML += side;
}

//joey 2.19
function showSidebar()
{  
    
//calls function to fill the sidebar with results
    resetSidebar();
    populateSidebar(side_bar_html);
    document.getElementById(
"searchCriteriaLeft").style.display="none";
    document.getElementById(
"side_bar").style.display="block";
    document.getElementById(
"closeSidebar_now").style.display="block";
    document.getElementById(
"openSidebar_now").style.display="none";
    document.getElementById(
"leftSpace").style.display="block";
    document.getElementById(
"GDirection").style.display="block";
    document.getElementById(
"FromAddress").style.display="block";
    document.getElementById(
"cb_SearchByHospital").style.display="inline";
    document.getElementById(
"lb_SearchByHospital").style.display="inline";
    document.getElementById(
"cb_SearchBySchool").style.display="inline";
    document.getElementById(
"lb_SearchBySchool").style.display="inline";
    document.getElementById(
"cb_SearchByMall").style.display="inline";
    document.getElementById(
"lb_SearchByMall").style.display="inline";
    document.getElementById(
"searchNearBy").style.display="block";
}

function closeSidebar()
{
    document.getElementById(
"searchCriteriaLeft").style.display="block";
    document.getElementById(
"side_bar").style.display="none";
    document.getElementById(
"closeSidebar_now").style.display="none";
    document.getElementById(
"openSidebar_now").style.display="block";
    document.getElementById(
"leftSpace").style.display="none";
    document.getElementById(
"GDirection").style.display="none";
    document.getElementById(
"FromAddress").style.display="none";
    document.getElementById(
"cb_SearchByHospital").style.display="none";
    document.getElementById(
"lb_SearchByHospital").style.display="none";
    document.getElementById(
"cb_SearchBySchool").style.display="none";
    document.getElementById(
"lb_SearchBySchool").style.display="none";
    document.getElementById(
"cb_SearchByMall").style.display="none";
    document.getElementById(
"lb_SearchByMall").style.display="none";
    document.getElementById(
"searchNearBy").style.display="none";
    markerIndex
=-1;
}

function closeDirection()
{
    document.getElementById(
"directions").style.display="none";
    document.getElementById(
"closeDirections_now").style.display="none";
    showSidebar();
}

//end
function resetSidebar()
{
    document.getElementById(
"side_bar").innerHTML = "";
}

function showDetailPage(mls)
{
    currentMLS 
= mls;
    sendDetailViewRequest();
    document.getElementById(
"main_container").style.display="none";
    document.getElementById(
"detail_container").style.display="block";
    
var div = document.getElementById("outer_container");
    
//joey 2.15
    div.scrollLeft = 0;
    
//end
}

function showMainPage()
{
    document.getElementById(
"main_container").style.display="block";
    document.getElementById(
"detail_container").style.display="none";
}

function fixType(type)
{
    type 
= type.replace(/^\s+|\s+$/g, '');
    
if(type=="STACK")
    
{
        
return "Stacked Town House";
    }

    
else if(type=="TOWNH")
    
{
        
return "Town House";
    }

    
else if(type=="SWIDE")
    
{
        
return "Single Wide Trailer";
    }

    
else if(type=="4Plex")
    
{
        
return "Fourplex";
    }

    
else if(type=="HDUP")
    
{
        
return "Half Duplex";
    }

    
else if(type=="APTHI")
    
{
        
return "Apartment High Rise";
    }

    
else if(type=="DETCO")
    
{
        
return "Detached Condo";
    }

    
else if(type=="3PLEX")
    
{
        
return "Triplex";
    }

    
else if(type=="VLOT")
    
{
        
return "Vacant Lot";
    }

    
else if(type=="TSHAR")
    
{
        
return "Timeshare";
    }

    
else if(type=="CARRI")
    
{
        
return "Carriage RV";
    }

    
else if(type=="DUPSS")
    
{
        
return "Duplex Side by Side";
    }

    
else if(type=="APTLO")
    
{
        
return "Apartment Low Rise";
    }

    
else if(type=="DUPUD")
    
{
        
return "Duplex Up and Down";
    }

    
else if(type=="DWIDE")
    
{
        
return "Double Wide Trailer";
    }

    
else if(type=="DETCH")
    
{
        
return "Detached House";
    }

    
else if(type=="ATTCH")
    
{
        
return "Attached House";
    }

    
else
    
{
        
return "Unknown";
    }

}

function fixSqft(sqft)
{
    
if(sqft.indexOf(".")!=-1)
    
{
        
return sqft.substring(0,sqft.indexOf("."));
    }

    
else
    
{
        
return sqft;
    }

}

function fixBathNumber(baths)
{
    
if(baths.indexOf(".")!=-1)
    
{
        
if(baths.substring(baths.indexOf(".")+1,baths.indexOf(".")+2)=='1')
        
{
            
return baths.substring(0,baths.indexOf("."))+".5";
        }

        
else
        
{
            
return baths.substring(0,baths.indexOf("."));
        }

    }

    
else
    
{
        
return baths;
    }

}

function selectCityOrTown()
{
    
//joey 2.19
    closeSidebar();
    
//end
    resetSidebar();//clears the Listings sidebar
    communityObject = document.getElementById("dd_Community");
    communityName 
= communityObject.options[communityObject.selectedIndex].value;
    cityOrTownObject 
= document.getElementById("dd_CityOrTown");
    cityOrTownName 
= cityOrTownObject.options[cityOrTownObject.selectedIndex].value;
    districtObject 
= document.getElementById("dd_District");
    districtName 
= districtObject.options[districtObject.selectedIndex].value;
    
if(cityOrTownName != "")
    
{
        
if(cityOrTownName == "Calgary")
        
{
            document.getElementById(
"lb_District").style.display = "inline";
            document.getElementById(
"dd_District").style.display = "inline";
            districtObject.options[
0].selected = true;
            communityObject.options[
0].selected = true;
            setGoogleMapCity(
51.053728,-114.062474);
            map.clearOverlays();
        }

        
else if(cityOrTownName == "Edmonton")
        
{
            document.getElementById(
"lb_District").style.display = "inline";
            document.getElementById(
"dd_District").style.display = "inline";
            districtObject.options[
0].selected = true;
            communityObject.options[
0].selected = true;
            setGoogleMapCity(
53.540969,-113.493704);
            map.clearOverlays();
        }

        
else//town
        {
            document.getElementById(
"lb_District").style.display = "none";
            document.getElementById(
"dd_District").style.display = "none";
            document.getElementById(
"lb_Community").style.display = "none";
            document.getElementById(
"dd_Community").style.display = "none";
            districtObject.options[
0].selected = true;
            communityObject.options[
0].selected = true;
            
if(isOKToSendRequest())
            
{
                sendRequest(buildQueryString());
            }

        }

    }

}

function selectDistrict()
{
    
//joey 2.19
    closeSidebar();
    
//end
    resetSidebar();//clears the Listings sidebar
    selectList = document.getElementById("dd_District");
    selectedValue 
= selectList.options[selectList.selectedIndex].value;
    
if(selectedValue != "")
    
{
        document.getElementById(
"lb_Community").style.display = "inline";
        document.getElementById(
"dd_Community").style.display = "inline";
        document.getElementById(
"dd_Community").options.length = 0;
        document.getElementById(
"dd_Community").options[0= new Option(""""falsefalse);
        cityObject 
= document.getElementById("dd_CityOrTown");
        cityName 
= cityObject.options[cityObject.selectedIndex].value;
        
if(cityName == "Calgary")
        
{
            
if(selectedValue == "NW")
            
{
                setGoogleMapCityDistrict(
51.104384244689136,-114.19532775878906);
            }

            
else if(selectedValue == "NE")
            
{
                setGoogleMapCityDistrict(
51.114299564839285,-113.91448974609375);
            }

            
else if(selectedValue == "SE")
            
{
                setGoogleMapCityDistrict(
50.98091164990174,-113.89320373535156);
            }

            
else if(selectedValue == "SW")
            
{
                setGoogleMapCityDistrict(
50.981343945663895,-114.19258117675781);
            }

        }

        
else if(cityName == "Edmonton")
        
{
            
if(selectedValue == "NW")
            
{
                setGoogleMapCityDistrict(
53.6132842735673,-113.66798400878906);
            }

            
else if(selectedValue == "NE")
            
{
                setGoogleMapCityDistrict(
53.60839590747473,-113.33152770996094);
            }

            
else if(selectedValue == "SE")
            
{
                setGoogleMapCityDistrict(
53.47905653761052,-113.33908081054688);
            }

            
else if(selectedValue == "SW")
            
{
                setGoogleMapCityDistrict(
53.472926582928956,-113.66729736328125);
            }

        }

        sendRequest(buildQueryString());
    }

    
else
    
{
        document.getElementById(
"lb_Community").style.display = "none";
        document.getElementById(
"dd_Community").style.display = "none";
    }

}

function selectCommunity()
{
    resetSidebar();
//clears the Listings sidebar
    if(isOKToSendRequest())
    
{
        sendRequest(buildQueryString());
    }

    
//joey 2.19
    draggableMarker=null;
    closeSidebar();
    
//end
}

function addCommunity(community)
{
    communityList 
= document.getElementById("dd_Community");
    communityList.options[communityList.options.length] 
= new Option(community, community, falsefalse);
}

function buildQueryString()
{
    communityObject 
= document.getElementById("dd_Community");
    communityName 
= communityObject.options[communityObject.selectedIndex].value;
    cityOrTownObject 
= document.getElementById("dd_CityOrTown");
    cityOrTownName 
= cityOrTownObject.options[cityOrTownObject.selectedIndex].value;
    districtObject 
= document.getElementById("dd_District");
    districtName 
= districtObject.options[districtObject.selectedIndex].value;
    
var queryString;
    
if(communityName!="")//community
    {
        queryString 
= "community&^-^&"+cityOrTownName+"!^-^!"+districtName+"!^-^!"+communityName+"!^-^!"+minPrice+"!^-^!"+maxPrice+"!^-^!"+bedroom+"!^-^!"+bathroom+"!^-^!"+type+"!^-^!"+parking;
    }

    
else//town or district
    {
        
if(districtName=="")//town
        {
            queryString 
= "town&^-^&"+cityOrTownName+"!^-^!"+minPrice+"!^-^!"+maxPrice+"!^-^!"+bedroom+"!^-^!"+bathroom+"!^-^!"+type+"!^-^!"+parking;
        }

        
else//district
        {
            queryString 
= "district&^-^&"+cityOrTownName+"!^-^!"+districtName;
        }

    }

    
//alert(queryString);
    return queryString;
}

function buildDetailViewQueryString()
{
    
var queryString;
    queryString 
= "detailView&^-^&"+currentMLS;
    
return queryString;
}

function sendDetailViewRequest()
{
    sendRequest(buildDetailViewQueryString());
}

function isOKToSendRequest()
{
    cityObject 
= document.getElementById("dd_CityOrTown");
    cityName 
= cityObject.options[cityObject.selectedIndex].value;
    
if(cityName=="")
    
{
        
return false;
    }

    
else if(cityName == "Calgary" || cityName == "Edmonton")
    
{
        communityObject 
= document.getElementById("dd_Community");
        communityName 
= communityObject.options[communityObject.selectedIndex].value;
        
if(communityName=="")
        
{
            
return false;
        }

    }

    
else
    
{
        
return true;
    }

    
return true;
}

function MouseDownHandler(e, pointer, bar)//name left silde to xxx1, right slide to xxx2, but not 1 or 2 for single slide
{
    
if(!e)
    
{
        e 
= window.event;
    }

    
var number = pointer.id.substring(pointer.id.length-1);
    
if(number == "1")
    
{
        currentLeftPointer 
= pointer;
        currentRightPointer 
= document.getElementById(pointer.id.substring(0, pointer.id.length-1)+"2");
        currentBar 
= bar;
        leftPointerMouseOffset 
= e.clientX - currentLeftPointer.offsetLeft;
        leftPointerDoDrag 
= true;
    }

    
else if(number == "2")
    
{
        currentRightPointer 
= pointer;
        currentLeftPointer 
= document.getElementById(pointer.id.substring(0, pointer.id.length-1)+"1");
        currentBar 
= bar;
        rightPointerMouseOffset 
= e.clientX - currentRightPointer.offsetLeft;
        rightPointerDoDrag 
= true;
    }

    
else
    
{
        currentSinglePointer 
= pointer;
        currentBar 
= bar;
        singlePointerMouseOffset 
= e.clientX - currentSinglePointer.offsetLeft;
        singlePointerDoDrag 
= true;
    }

}

function MouseMoveHandler(e)
{
    
if(!e)
    
{
        e 
= window.event;
    }

    
if(leftPointerDoDrag)
    
{
        
var newPosition = e.clientX - leftPointerMouseOffset;
        
var minLeft = getAbsoluteLeftPosition(currentBar);
        
var maxLeft = getAbsoluteLeftPosition(currentBar) + (currentRightPointer.offsetLeft - currentLeftPointer.offsetWidth);
        
if(newPosition <= minLeft)
        
{
            newPosition 
= minLeft;
        }

        
if(newPosition >= maxLeft)
        
{
            newPosition 
= maxLeft;
        }

        setPosition(currentLeftPointer,(newPosition 
- minLeft));
        setMinPrice();
        setMaxPrice();
        setBedroom();
        setBathroom();
    }

    
else if(rightPointerDoDrag)
    
{
        
var newPosition = e.clientX - rightPointerMouseOffset;
        
var minLeft = getAbsoluteLeftPosition(currentBar) + currentLeftPointer.offsetLeft + currentLeftPointer.offsetWidth;
        
var maxLeft = getAbsoluteLeftPosition(currentBar) + (currentBar.offsetWidth - currentRightPointer.offsetWidth);
        
if(newPosition <= minLeft)
        
{
            newPosition 
= minLeft;
        }

        
if(newPosition >= maxLeft)
        
{
            newPosition 
= maxLeft;
        }

        setPosition(currentRightPointer,(newPosition 
- minLeft + currentLeftPointer.offsetLeft + currentLeftPointer.offsetWidth));
        setMinPrice();
        setMaxPrice();
        setBedroom();
        setBathroom();
    }

    
else if(singlePointerDoDrag)
    
{
        
var newPosition = e.clientX - singlePointerMouseOffset;
        
var minLeft = getAbsoluteLeftPosition(currentBar);
        
var maxLeft = getAbsoluteLeftPosition(currentBar) + (currentBar.offsetWidth - currentSinglePointer.offsetWidth);
        
if(newPosition <= minLeft)
        
{
            newPosition 
= minLeft;
        }

        
if(newPosition >= maxLeft)
        
{
            newPosition 
= maxLeft;
        }

        setPosition(currentSinglePointer,(newPosition 
- minLeft));
        setMinPrice();
        setMaxPrice();
        setBedroom();
        setBathroom();
    }

    
return false;
}

function MouseUpHandler(e)
{
    
if(!e)
    
{
        e 
= window.event;
    }

    
if(leftPointerDoDrag||rightPointerDoDrag||singlePointerDoDrag)
    
{
        leftPointerDoDrag 
= false;
        rightPointerDoDrag 
= false;
        singlePointerDoDrag 
= false;
        
//joey 2.19
        if(draggableMarker==null)
        
{
            
if(isOKToSendRequest())
            
{
                sendRequest(buildQueryString());
            }

        }

        
else
        
{
            searchSurrounding(draggableMarker.getPoint().lng(),draggableMarker.getPoint().lat());
        }

        
//end
    }

}

document.onmousemove 
= MouseMoveHandler;
document.onmouseup 
= MouseUpHandler;

function getAbsoluteLeftPosition(object) 
{
    
var count = object.offsetLeft;
    
while(object.offsetParent!=null//recursive way to get the absolute location value
    {
        
var parent = object.offsetParent;
        count 
= count + parent.offsetLeft;
        object 
= parent;
    }

    
return count;
}

function setPosition(object,relativeLeftPosition) 
{
    object.style.left 
= relativeLeftPosition + "px";//relative
}
        
function getPercentageRangeForSlide(slider, bar)
{
    
return Math.round((slider.offsetLeft*100)/(bar.offsetWidth-slider.offsetWidth));
}

function setMinPrice()
{
    
var value = getPercentageRangeForSlide(document.getElementById("priceSlide1"),document.getElementById("priceBar"));
    minPrice 
= value*priceRange/100;
    if(document.all)
    
{
        document.getElementById(
'minPrice').innerText = "" + formatCurrency(minPrice);
    }

    
else
    
{
        document.getElementById(
'minPrice').textContent = "" + formatCurrency(minPrice);
    }

}

function setMaxPrice()
{
    
var value = getPercentageRangeForSlide(document.getElementById("priceSlide2"),document.getElementById("priceBar"));
    
if(value==100)
    
{
        maxPrice
=6000000;
        
if(document.all)
        
{
            document.getElementById(
'maxPrice').innerText ="$2M+";
        }
 
        
else
        
{
            document.getElementById(
'maxPrice').textContent ="$2M+";
        }

    }

    
else
    
{
        maxPrice 
= value*priceRange/100;
        if(document.all)
        
{
            document.getElementById(
'maxPrice').innerText ="" + formatCurrency(maxPrice);
        }
 
        
else
        
{
            document.getElementById(
'maxPrice').textContent ="" + formatCurrency(maxPrice);
        }

    }
  
}

function setBedroom()
{
    
var value = getPercentageRangeForSlide(document.getElementById("bedroomSlide"),document.getElementById("bedroomBar"));
    
if(value==100)
    
{
        bedroom
=8;
        
if(document.all)
        
{
            document.getElementById(
'bedroom').innerText ="Beds: 5+";
        }
 
        
else
        
{
            document.getElementById(
'bedroom').textContent ="Beds: 5+";
        }

    }

    
else
    
{    
        bedroom 
= Math.ceil(value*bedroomRange/170);
        if(document.all)
        
{
            document.getElementById(
'bedroom').innerText ="Beds: " + bedroom + "+";
        }
 
        
else
        
{
            document.getElementById(
'bedroom').textContent ="Beds: " + bedroom+ "+";
        }

    }

}

function setBathroom()
{
    
var value = getPercentageRangeForSlide(document.getElementById("bathroomSlide"),document.getElementById("bathroomBar"));
    
if(value==100)
    
{
        bathroom
=8;
        
if(document.all)
        
{
            document.getElementById(
'bathroom').innerText ="Baths: 5+";
        }
 
        
else
        
{
            document.getElementById(
'bathroom').textContent ="Baths: 5+";
        }

    }

    
else
    
{        
        bathroom 
= Math.ceil(value*bathroomRange/170);
        if(document.all)
        
{
            document.getElementById(
'bathroom').innerText ="Baths: " + bathroom + "+";
        }
 
        
else
        
{
            document.getElementById(
'bathroom').textContent ="Baths: " + bathroom + "+";
        }

    }

}

function selectType()
{
    
var selectedList = document.getElementById("lb_Type");
    type 
= "";
    
for(var i =0;i<selectedList.length;i++)
    
{
        
if(selectedList.options[i].selected)
        
{
            type
=type+selectedList.options[i].value+"~^-^~";
        }

    }

    
if(isOKToSendRequest())
    
{
        sendRequest(buildQueryString());
    }

}

function selectParking()
{
    
var selectedList = document.getElementById("lb_Parking");
    parking
="";
    
for(var i =0;i<selectedList.length;i++)
    
{
        
if(selectedList.options[i].selected)
        
{
            parking
=parking+selectedList.options[i].value+"~^-^~";
        }

    }

    
if(isOKToSendRequest())
    
{
        sendRequest(buildQueryString());
    }

}

    
</script>

    
<%--<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=ABQIAAAA0fjp2tHrrQJwoaRp8r_sYxR9fR65Vek3QPwU0sVxyfrqv-3SrxSOi2QPW6Z4SZY2sm8l2ZDVezrplA"
      type
="text/javascript"></script>
<script src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js"
      type
="text/javascript"></script>

<style type="text/css">
  @import url(
"http://www.google.com/uds/css/gsearch.css");
  @import url(
"http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
</style>--
%>
</head>
<body onload="initialize()" onunload="GUnload()">
    
<form id="form1" runat="server">
        
<div id="main_container">
            
<div id="searchCriteriaLeft">
                
<div id="minPrice" style="position: absolute; top: 64px; left: 4px;">
                    $0
</div>
                
<div id="maxPrice" style="position: absolute; top: 64px; left: 140px;">
                    $2M+
</div>
                
<div id="priceBar" style="position: absolute; top: 84px; left: 4px; width: 175px;
                    height: 18px; background-image: url(Images/bgSlideBar(1).gif); background-repeat: repeat-x"
>
                    
<div id="priceSlide1" style="position: absolute; top: 0px; left: 0px; width: 10px;
                        height: 18px; cursor: pointer; cursor: hand; float: right; background-image: url(Images/icnSlider.gif)"

                        onmousedown
="MouseDownHandler(event, this, this.offsetParent)">
                    
</div>
                    
<div id="priceSlide2" style="position: absolute; top: 0px; left: 165px; width: 10px;
                        height: 18px; cursor: pointer; cursor: hand; float: right; background-image: url(Images/icnSlider.gif)"

                        onmousedown
="MouseDownHandler(event, this, this.offsetParent)">
                    
</div>
                
</div>
                
<div id="bedroom" style="position: absolute; top: 114px; left: 4px;">
                    Beds: 0+
</div>
                
<div id="bedroomBar" style="position: absolute; top: 134px; left: 4px; width: 75px;
                    height: 18px; background-image: url(Images/bgSlideBar(1).gif); background-repeat: repeat-x"
>
                    
<div id="bedroomSlide" style="position: absolute; top: 0px; left: 0px; width: 10px;
                        height: 18px; cursor: pointer; cursor: hand; float: right; background-image: url(Images/icnSlider.gif)"

                        onmousedown
="MouseDownHandler(event, this, this.offsetParent)">
                    
</div>
                
</div>
                
<div id="bathroom" style="position: absolute; top: 164px; left: 4px;">
                    Baths: 0+
</div>
                
<div id="bathroomBar" style="position: absolute; top: 184px; left: 4px; width: 75px;
                    height: 18px; background-image: url(Images/bgSlideBar(1).gif); background-repeat: repeat-x"
>
                    
<div id="bathroomSlide" style="position: absolute; top: 0px; left: 0px; width: 10px;
                        height: 18px; cursor: pointer; cursor: hand; float: right; background-image: url(Images/icnSlider.gif)"

                        onmousedown
="MouseDownHandler(event, this, this.offsetParent)">
                    
</div>
                
</div>
                
<%--<div id="Type" style="position:absolute;top:204px;left:4px;">
            
<asp:ListBox runat="server" ID="lb_Type" SelectionMode="Multiple" onchange="selectType();">
            
</asp:ListBox>
        
</div>--
%>
                
<%-- <div id="Parking" style="position:absolute;top:254px;left:4px;">
            
<asp:ListBox runat="server" ID="lb_Parking" SelectionMode="Multiple" onchange="selectParking();">
            
</asp:ListBox>
        
</div>--
%>
            
</div>
            
<table>
                
<tr>
                    
<td style="width: 800px">
                    
</td>
                    
<td>
                        
<div id="mapinputs">
                            
<table>
                                
<tr>
                                    
<td id="leftSpace" style="width: 163px; display: none">
                                    
</td>
                                    
<td class="city">
                                        
<asp:Label ID="lb_CityOrTown" runat="server" CssClass="inputLabels" Text="City/Town:"></asp:Label>
                                        
<br />
                                        
<asp:DropDownList ID="dd_CityOrTown" runat="server" onChange="selectCityOrTown();">
                                        
</asp:DropDownList>
                                    
</td>
                                    
<td class="district">
                                        
<asp:Label ID="lb_District" runat="server" CssClass="inputLabels" Text="District:"
                                            Style
="display: none"></asp:Label>
                                        
<br />
                                        
<select id="dd_District" onchange="selectDistrict();" style="display: none">
                                            
<option selected="selected" value=""></option>
                                            
<option value="NW">NW</option>
                                            
<option value="NE">NE</option>
                                            
<option value="SE">SE</option>
                                            
<option value="SW">SW</option>
                                        
</select>
                                        
<asp:Label ID="lb_Community" runat="server" Text="Community:" Style="display: none"></asp:Label>
                                        
<select id="dd_Community" style="display: none" onchange="selectCommunity();">
                                            
<option selected="selected"></option>
                                        
</select>
                                    
</td>
                                
</tr>
                            
</table>
                        
</div>
                        
<%--  This Table holds the Map and the Sidebar--%>
                        
<table>
                            
<tr>
                                
<td valign="top">
                                    
<input id="openSidebar_now" type="button" name="showSidebar_now" value="Show" onclick="showSidebar();" />
                                    
<input id="closeSidebar_now" type="button" style="display: none;" name="closeSidebar_now"
                                        value
="X" onclick="closeSidebar();" />
                                    
<div id="side_bar" style="overflow: auto; width: 215px; height: 500px;"></div>
                                    
<input id="closeDirections_now" type="button" style="display: none;"
                                        value
="X" onclick="closeDirection();" />
                                    
<div id="directions" style="overflow: auto; width: 215px; height: 500px; display:none"></div>
                                    
<%--sidebar with scrolling--%>
                                
</td>
                                
<td>
                                    
<div align="center" id="map_canvas" style="width: 500px; height: 500px">
                                    
</div>
                                
</td>
                            
</tr>
                        
</table>
                        
<%--  This Table holds the Map and the Sidebar--%>
                        
<div id="message">
                        
</div>
                        
<div id="getDistance">
                        
</div>
                        
<input style="display:none;" type="button" name="GDirection" value="GDirection" id="GDirection" onclick="setDirections();" />
                        
<input style="display:none;"type="text" name="FromAddress" id="FromAddress" value="calgary" />
                        
<br />
                        
<input style="display:none;" type="checkbox" id="cb_SearchByHospital" value="Hospital"/><label style="display:none;" id="lb_SearchByHospital">Hospital</label>
                        
<input style="display:none;" type="checkbox" id="cb_SearchBySchool" value="School"/><label style="display:none;" id="lb_SearchBySchool">School</label>
                        
<input style="display:none;" type="checkbox" id="cb_SearchByMall" value="Mall"/><label style="display:none;" id="lb_SearchByMall">Mall</label>
                        
<input style="display:none;" type="button" value="Search Near By" id="searchNearBy" onclick="clickSearchNearBy();" />
                    
</td>
                
</tr>
            
</table>
        
</div>
        
<div id="detail_container" style="display: none;">
            
<div id="controls">
                
<div id="detail_address" style="float: left; font-size: 22px; font-weight: bold;">
                
</div>
                
<div id="detail_close" style="float: right">
                    
<href="" onclick="showMainPage();return false;">~X~</a></div>

using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;

public partial class Search : System.Web.UI.Page
{
    
protected void Page_Load(object sender, EventArgs e)
    
{
        
try
        
{
            
string search;
            search 
= this.Request.Form["Search"].ToString();
            
string[] columns = System.Text.RegularExpressions.Regex.Split(search, "\\&\\^\\-\\^\\&");
            StringBuilder sb 
= new StringBuilder();
            SqlConnection conn 
= new SqlConnection();
            conn.ConnectionString 
= ConfigurationManager.ConnectionStrings["ConnectionInfo"].ConnectionString;
            conn.Open();
            SqlCommand comm 
= new SqlCommand();
            comm.Connection 
= conn;

            
"town"

            
"district"

            
"community"

            
"detailView"

            
"surrounding"

            
"nearBy"

            conn.Close();
            
//WriteFile("c:/ri2.txt", sb.ToString());
            this.Response.Write(sb.ToString());
        }

        
catch (Exception ex)
        
{
            WriteFile(
"c:/ri2.txt", ex.Message);
        }

        
finally
        
{
            
this.Response.End();
        }

    }


    
private void WriteFile(string filePath, string content)
    
{
        
if (!Directory.Exists(Path.GetDirectoryName(filePath)))
        
{
            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
        }

        
using (StreamWriter sw = new StreamWriter(filePath))
        
{
            sw.Write(content);
        }

    }

}

posted @ 2008-02-21 06:51  N/A2011  阅读(606)  评论(1编辑  收藏  举报