
var bigmap;var txtBoxWithFocus;var category,subCategory,interest;var businessnamesearch,subjectsearch,majorintersections,cityprovince;if(loadTaskList==undefined)
var loadTaskList=new Array();var oldOnload=false;if(typeof(window.onload)=='function'){oldOnload=window.onload;}
window.onload=function(){bodyelementonload();if(oldOnload)oldOnload();};function bodyelementonload(){for(var i=0;i<loadTaskList.length;i++){loadTaskList[i]();}}
function addLoadEvent(newFunction){loadTaskList[loadTaskList.length]=newFunction;}
function is_numeric(val){return(parseInt(val)>=0||parseInt(val)<=0);}
function el(e){return document.getElementById(e);}
function ev(evnt){evnt=evnt||window.event;if(evnt.target)trg=evnt.target;else if(evnt.srcElement)trg=evnt.srcElement;if(trg.nodeType==3)trg=trg.parentNode;ret=Object();ret.e=evnt;ret.targ=trg;return ret;}
function cel(elType,elID){e=document.createElement(elType);e.id=elID;return e;}
function conlog(str){if(typeof(console)!="undefined")console.log(str);}
addLoadEvent(initAll);function iPhoneTouchLocationCallback(lati,lngi,accuracyInM,locationIsReal){if(locationIsReal==1){alert("Latitude:  "+lati+"\n"+"Longitude: "+lngi+"\n"+"Accuracy:  "+accuracyInM);}else{alert("The location found is fake:\n"+"Latitude:  "+lati+"\n"+"Longitude: "+lngi+"\n"+"Accuracy:  "+accuracyInM);}}
function iPhoneTouchLocationCallbackFailed(){alert("iPhone/iTouch location callback failed");}
function initAll(){if(typeof(windowIsResized)=='function')
windowIsResized();}
function initMap(){if(document.getElementById("bigmap")==null)return;if(typeof GBrowserIsCompatible=='undefined')return;if(GBrowserIsCompatible()){document.body.onunload=GUnload;var elBigmap=document.getElementById("bigmap")
bigmap=new GMap2(elBigmap);var lat=43.699651,lng=-79.432913,zm=9;if(typeof defloc!='undefined')
if(defloc!=""){lat=defloc.substr(0,defloc.indexOf(','));lng=defloc.substr(lat.length+1);zm=10;}
if(typeof defzoom!='undefined')
if(defzoom!=""){zm=defzoom;}
if(typeof isMobi!="undefined")
if(isMobi){bigmap.getContainer().style.display="none";}
bigmap.setCenter(new GLatLng(lat,lng),zm);elBigmap.largemapcontrol=new GLargeMapControl();elBigmap.smallmapcontrol=new GSmallMapControl();if(typeof isMobi!="undefined")
if(!isMobi)
bigmap.addControl(elBigmap.largemapcontrol);bigmap.enableScrollWheelZoom();bigmap.defaultCenter=bigmap.getCenter();return;}
if(typeof(windowIsResized)=='function')
windowIsResized();}
function kmToLat(km){var p1=bigmap.getCenter();var kmInLat=p1.distanceFrom(new GLatLng(p1.lat()+1,p1.lng()))/1000;return km/kmInLat;}
function kmToLng(km){var p1=bigmap.getCenter();var kmInLng=p1.distanceFrom(new GLatLng(p1.lat(),p1.lng()-1))/1000;return km/kmInLng;}
function latToKm(lat){var p1=bigmap.getCenter();var kmInLat=p1.distanceFrom(new GLatLng(p1.lat()+1,p1.lng()))/1000;return lat*kmInLat;}
function lngToKm(lng){var p1=bigmap.getCenter();var kmInLng=p1.distanceFrom(new GLatLng(p1.lat(),p1.lng()-1))/1000;return lng*kmInLng;}
function updateMap(location){ajax(xhrUpdateMapLocation,"pageSiteFrontScrollTable.php?aj=sl&cityprovince="+location,ajaxUpdateMapResponse);}
function ajaxUpdateMapResponse(txt){if(txt=="not found"){ajax(xhrGetGeocodeLocation,"googleGeocoderPassthrough.php?q="+cityprovince,ajaxGetGeocodeResponse);}else{var s=txt.split(",");var lat=s[0];var lng=s[1];if(typeof(bigmap)!='undefined')
bigmap.setCenter(new GLatLng(lat,lng),12);}}
function ajaxGetGeocodeResponse(txt){var s=txt.split(",");var accuracy=s[1];var lat=s[2];var lng=s[3];ajax(xhrSaveGeocodeLocation,"pageSiteFrontScrollTable.php?aj=sal&cityprovince="+cityprovince+"&lat="+lat+"&lng="+lng+"&accuracy="+accuracy,ajaxSaveGeocodeResponse);if(typeof(bigmap)!='undefined')
bigmap.setCenter(new GLatLng(lat,lng),12);}
function ajaxSaveGeocodeResponse(txt){}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name){createCookie(name,"",-1);}
function companyNameClick(id){if(typeof(bigmap)!='undefined'){var latlng=document.getElementById('compLatLng'+id);var companyRow=document.getElementById('companyRow'+id);var lat=latlng.innerHTML.split(",")[0];var lng=latlng.innerHTML.split(",")[1];bigmap.setCenter(new GLatLng(lat,lng),14);}}
function resetAllFilters(){setAllFilters("","","","","","","");}
function setAllFilters(busn,subj,ints,ctyprov,intrst,cat,subj){if(busn!==0)businessnamesearch=busn;if(subj!==0)subjectsearch=subj;if(ints!==0)majorintersections=ints;if(ctyprov!==0)cityprovince=ctyprov;if(intrst!==0)interest=intrst;if(cat!==0)category=cat;if(subj!==0)subCategory=subj;updateTable();}
function killSearch(searchType){setAllFilters((searchType=='businessnamesearch')?"":0,(searchType=='subjectsearch')?"":0,(searchType=='majorintersections')?"":0,(searchType=='cityprovince')?"":0,(searchType=='interest')?"":0,(searchType=='cat')?"":0,(searchType=='subCat')?"":0);}
function toggleUserCommandBox(){if(typeof document.getElementById('headerUserCommandBox')!="undefined"){e=document.getElementById('headerUserCommandBox');if(e.className!='shown')
e.className='shown';else
e.className='hidden';}}
function updateTable(){scriptURL="pageSiteFrontScrollTable.php?aj=ut&subjectsearch="+subjectsearch;scriptURL+="&majorintersections="+majorintersections;scriptURL+="&businessnamesearch="+businessnamesearch;scriptURL+="&cityprovince="+cityprovince;scriptURL+="&interest="+interest;scriptURL+="&category="+category;scriptURL+="&subcategory="+subCategory;ajax(createXHR(),scriptURL,ajaxUpdateTableResponse);ajax(createXHR(),scriptURL.replace(/aj=ut/,'aj=uh'),ajaxUpdateHeaderResponse);}
function ajaxUpdateHeaderResponse(txt){}
function ajaxUpdateTableResponse(txt){var categoriesDiv=document.getElementById('categoriesDirectory');if(categoriesDiv!=null)categoriesDiv.innerHTML=txt;bigmap.clearOverlays();var divCollection=document.getElementsByTagName('div');for(i=0;i<divCollection.length;i++){var thisDiv=divCollection[i];if(thisDiv.id.indexOf("companyRow")!=-1){var thisID=thisDiv.id.substr(10);var latlngDiv=document.getElementById('compLatLng'+thisID);var lat=latlngDiv.innerHTML.split(",")[0];var lng=latlngDiv.innerHTML.split(",")[1];thisDiv.marker=new GMarker(new GLatLng(lat,lng));}}}
