/*
Copyright (c) 2009, Devel-Tech Inc., dti@develtech.ca
All rights reserved.
Redistribution and/or use in source and binary forms, with or without modification, 
are NOT permitted without the express written consent of Devel-Tech Inc. 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var map = null; var geocoder = null; 
var bus_lines = new Array(); var bus_lines_sw_ne = new Array();
var bus_routes_bounds = new Array(); var bus_routes_texts = new Array(); var numrows_sw_ne = 0;
var numrowsbus = 0; var numbustexts = 0; var numbusroutes = 0;
var bus_routes = new Array(); var current_routes = new Array(); var numcurrentroutes = 0;
var currentposition = ""; var currentlat = 0.0; var currentlng = 0.0;
var selectedindex = -1; var nextindex = -1; var busroutesflag = 0;
var buslinks = new Array(); var showmessageflag = 0; var communityflag = 0; 
var current_markers = new Array(); 
var bike_lines = new Array(); var bike_lines_sw_ne = new Array();
var bike_routes_bounds = new Array(); var bike_routes = new Array();
var current_routes_bike = new Array();
var numrows_sw_ne_bike = 0; var numrowsbike = 0;
var numbikeroutes = 0; var numcurrentroutes_bike = 0;
var dontzoom = 0; var bikepathsflag = 0;
var busscriptline = "";
var holdcolor = 0; var tolerance = 1.0;
var loaded_markers = new Array(); var numloadedmarkers = 0;
var communities = new Array(); var numcommunitites = 0;
var geoxml = null;
var communitiesxml = null;
var run_load_routine = 1; var hasquadtype = 0;
var changeit = 0; var competitor_marker = null;
var passedlat = ""; var passedlng = ""; 
var listingID = ""; var exact_location = "";
var global_dist = ""; 
var dragzoomflag = 0; var global_startprice = 0; var global_endprice = 0; 
var site_link = ""; var global_beds = ""; var global_price = ""; var from_url = "";
var myzoomflag = 0; var filterson = 0; var proximityon = 0; var startup = 1;
var global_type = ""; var global_lat = ""; var global_lng = ""; var globalStats = "";
var globalS = ""; var globalW = ""; var globalN = ""; var globalE = "";
var global_furnished = "";
delta_lat = 0.010; delta_lng = 0.015;
var iconProperty = new GIcon();
iconProperty.image = "./images/google_listing_info2.gif"; iconProperty.shadow = "./images/iconMooseShadow.png";
iconProperty.iconSize = new GSize(70, 51); iconProperty.shadowSize = new GSize(44, 29);
iconProperty.iconAnchor = new GPoint(22, 51); iconProperty.infoWindowAnchor = new GPoint(35, 1);
var iconCommunity = new GIcon();
iconCommunity.image = "./images/google_listing_info3.gif"; iconCommunity.shadow = "./images/iconMooseShadow.png";
iconCommunity.iconSize = new GSize(70, 51); iconCommunity.shadowSize = new GSize(44, 29);
iconCommunity.iconAnchor = new GPoint(22, 51); iconCommunity.infoWindowAnchor = new GPoint(35, 1);
var redicon = new GIcon();
redicon.image = red_iconfile; redicon.iconSize = new GSize(12,12);
redicon.iconAnchor = new GPoint(6,6); redicon.infoWindowAnchor = new GPoint(6, 1);
var greyicon = new GIcon();
greyicon.image = grey_iconfile; greyicon.iconSize = new GSize(12,12);
greyicon.iconAnchor = new GPoint(6,6); greyicon.infoWindowAnchor = new GPoint(6, 1);
var largeredicon = new GIcon();
largeredicon.image = large_red_iconfile; largeredicon.iconSize = new GSize(24,24);
largeredicon.iconAnchor = new GPoint(12,12); largeredicon.infoWindowAnchor = new GPoint(12, 1);
var cyanicon = new GIcon();
cyanicon.image = cyan_iconfile; cyanicon.iconSize = new GSize(12,12);
cyanicon.iconAnchor = new GPoint(6,6); cyanicon.infoWindowAnchor = new GPoint(6, 1);
var whichicon = "regular";
var disclaimer = 'Distance is estimated and not guaranteed by RentFaster.ca';
var disclaimer_property = "<tr><td><table style='font-size:8pt;font-family:Arial;'><tr><td valign='top'><div style='font-size:10px;'><b>Note:</b></div></td><td><div style='font-size:10px;'>The property location marker is not exact, it is based on postal code data. This usually places the marker within about 1 block of the actual location.</div></td></tr></table></td></tr>";
var loadingtext = "Loading"; var othertext = "Search";
var prompttxt = "Pick an Area"; var warning1 = "Your search returned no results."
var warning2 = "<tr><td>You must pick a City/Section or zoom in to obtain results.</td></tr>"
var initial_txt = "Click on <b>Enable Filters</b> to see other query options";
function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,"");}
function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,"");}
function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,"");}
function IsNumeric(sText)
{
var ValidChars = "0123456789."; var IsNumber=true; var Char;
for (i = 0; i < sText.length && IsNumber == true; i++) 
{ Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) {IsNumber = false;} }
return IsNumber;
}
var pages = new Array(600);
var numarrays = 0;
var whichmore = "";
var more_than_txt2 = " > " + max_marker_points + " display maximum.<br>Select a smaller distance.";
var more_than_txt = " > " + max_marker_points + " display maximum.<br>Further refine your search criteria.";
var warning_txt = "<P><BR><BR><span style='font-size:8pt;font-family:Arial;color:red'><b>More than " + max_marker_points + " records were returned.<BR><BR>Further refine your search criteria.</b></span>";
var warning_txt2 = "<P><BR><BR><span style='font-size:8pt;font-family:Arial;color:red'><b>More than " + max_marker_points + " records were returned.<BR><BR>Select a smaller distance.</b></span>";
var gridtexthdr = "<DIV class=tableContainer3><table class='f8font'>";
var gridtextftr = "<tr><td><div class='f10font'>Distance is estimated and not guaranteed<br>by RentFaster.ca</div></td></tr></table></div>"; 
var gridtextftr2 = "<tr><td><div class='f10font'>Distance is estimated and not guaranteed<br>by RentFaster.ca</div></td></tr></table></div>";
/*var gridtextftr3 = "<tr><td><div class='f10font'><b>Community Location</b><br>For privacy issues, some landlords do not wish the exact location of the property to be listed. In these cases, a center point in the neighbourhood is picked.<br><br>Distance is estimated and not guaranteed<br>by RentFaster.ca</div></td></tr></table></div>";*/
var gridtextftr3 = "<tr><td><table class='f8font'><tr><td valign='top'><div class='f8font'><b>Community Location</b></div></td><td><div style='font-size:8px;'>For privacy issues, some landlords do not wish the exact location of the property to be listed. In these cases, a center point in the neighbourhood is picked.<br><br>Distance is estimated and not guaranteed<br>by RentFaster.ca</div></td></tr></table></td></tr>";
var gridtext = ""; 
var lastrow = 0; var numrows = 0; var proximity_lat = ""; var proximity_lon = "";
var whichbrowser = ""; var priceflag = 1; var typeflag = 1; var bdmflag = 1; 
var communityflag = 1; var newwindow;
var newcontent = "<HTML><HEAD><TITLE>RENTFASTER</TITLE></HEAD><BODY><b>Loading query. Please wait...</b><br><img src='./images/wait.gif' /></BODY></HTML>";
var current_lines = new Array(); var proximity_values = new Array();
var all_markers = new Array(); var school_markers = new Array();
var mall_markers = new Array(); var hospital_markers = new Array();
var LRT_markers = new Array(); var downtown_markers = new Array();
var airport_markers = new Array(); var university_markers = new Array();
var library_markers = new Array();
function getGlobalsFromURL()
{
listingID = ""; exact_location = ""; zipcode = ""; global_dist = "1"; global_beds = "All"; global_price = "All"; global_type = "All";
global_lat = ""; global_lng = ""; global_furnished = "All";
globalStats = ""; globalS = ""; globalW = ""; globalN = ""; globalE = "";
global_startprice = -1; global_endprice = -1;
var parameters2 = from_URL.split("&");
var param_names = new Array();
var param_values = new Array();
for (var i = 0; i < parameters2.length; i++)
{
var temp = parameters2[i].split("=");
param_names.push(temp[0]);
if (temp.length > 1)
{
param_values.push(temp[1]);
if (temp[0] == "listingID")
{
listingID = temp[1];
site_link = "<a href='" + linkURL + "/listingview.php?listingID="+listingID+"'>";
site_link = site_link+"<div style='font-family:Arial;font-size:11px;'>";
site_link = site_link+"Go Back To Listing</a></div>";
}
if (temp[0] == "exact_location"){exact_location = temp[1]; }
if (temp[0] == "lat"){ global_lat = temp[1]; }
if (temp[0] == "lng"){ global_lng = temp[1]; }
if (temp[0] == "distance"){ global_dist = temp[1]; }
if (temp[0] == "type"){ global_type = temp[1]; if (global_type == "All"){global_type = "All Property";}}
if (temp[0] == "beds"){ 
global_beds = temp[1]; 
if (temp[1].length == 0){global_beds = "All";}
if (global_beds == "bachelor"){}
else{if (global_beds == "none"){}}
}
if (temp[0] == "price"){
global_price = temp[1];
if (global_price.length == 0){global_price = "All";}else{
var tempprice = parseInt(global_price) - 300; 
if (tempprice < 300){global_startprice = 0;}
if (tempprice == 300){global_startprice = 300;}
if (tempprice > 300){ if (tempprice <= 400){global_startprice=400;}}
if (tempprice > 400){ if (tempprice <= 500){global_startprice=500;}}
if (tempprice > 500){ if (tempprice <= 600){global_startprice=600;}}
if (tempprice > 600){ if (tempprice <= 700){global_startprice=700;}} 
if (tempprice > 700){ if (tempprice <= 800){global_startprice=800;}} 
if (tempprice > 800){ if (tempprice <= 900){global_startprice=900;}} 
if (tempprice > 900){ if (tempprice <=1000){global_startprice=1000;}} 
if (tempprice >1000){ if (tempprice <=1100){global_startprice=1100;}} 
if (tempprice >1100){ if (tempprice <=1200){global_startprice=1200;}} 
if (tempprice >1200){ if (tempprice <=1300){global_startprice=1300;}} 
if (tempprice >1300){ if (tempprice <=1400){global_startprice=1400;}} 
if (tempprice >1400){ if (tempprice <=1500){global_startprice=1500;}} 
if (tempprice >1500){ if (tempprice <=1600){global_startprice=1600;}} 
if (tempprice >1600){ if (tempprice <=1700){global_startprice=1700;}} 
if (tempprice >1700){ if (tempprice <=1800){global_startprice=1800;}} 
if (tempprice >1800){ if (tempprice <=1900){global_startprice=1900;}} 
if (tempprice >1900){ if (tempprice <=2500){global_startprice=2000;}} 
if (tempprice >2000){ if (tempprice <=2500){global_startprice=2500;}} 
if (tempprice >2500){ if (tempprice <=3000){global_startprice=3000;}} 
if (tempprice >3000){global_startprice=3500;} 
var tempprice = parseInt(global_price) + 300; 
if (tempprice <= 300){global_endprice=300;}
if (tempprice > 300){ if (tempprice <= 400){global_endprice=400;}}
if (tempprice > 400){ if (tempprice <= 500){global_endprice=500;}}
if (tempprice > 500){ if (tempprice <= 600){global_endprice=600;}}
if (tempprice > 600){ if (tempprice <= 700){global_endprice=700;}} 
if (tempprice > 700){ if (tempprice <= 800){global_endprice=800;}} 
if (tempprice > 800){ if (tempprice <= 900){global_endprice=900;}} 
if (tempprice > 900){ if (tempprice <=1000){global_endprice=1000;}} 
if (tempprice >1000){ if (tempprice <=1100){global_endprice=1100;}} 
if (tempprice >1100){ if (tempprice <=1200){global_endprice=1200;}} 
if (tempprice >1200){ if (tempprice <=1300){global_endprice=1300;}} 
if (tempprice >1300){ if (tempprice <=1400){global_endprice=1400;}} 
if (tempprice >1400){ if (tempprice <=1500){global_endprice=1500;}} 
if (tempprice >1500){ if (tempprice <=1600){global_endprice=1600;}} 
if (tempprice >1600){ if (tempprice <=1700){global_endprice=1700;}} 
if (tempprice >1700){ if (tempprice <=1800){global_endprice=1800;}} 
if (tempprice >1800){ if (tempprice <=1900){global_endprice=1900;}} 
if (tempprice >1900){ if (tempprice <=2500){global_endprice=2000;}} 
if (tempprice >2000){ if (tempprice <=2500){global_endprice=2500;}} 
if (tempprice >2500){ if (tempprice <=3000){global_endprice=3000;}} 
if (tempprice >3000){global_endprice=3500;} 
}
}
if (temp[0] == "sprice"){ global_startprice = parseInt(temp[1]);} 
if (temp[0] == "eprice"){ global_endprice = parseInt(temp[1]);} 
if (temp[0] == "S"){ globalS = temp[1];} 
if (temp[0] == "W"){ globalW = temp[1];} 
if (temp[0] == "N"){ globalN = temp[1];} 
if (temp[0] == "E"){ globalE = temp[1];} 
if (temp[0] == "stats"){ globalStats = temp[1];} 
if (temp[0] == "furnished"){ global_furnished = temp[1]; }
}
}
}

