$(document).ready(function(){$("#googleMapApp").css("display","block");$("p.mapLinks").css("display","block");var j,f=new GMap2($("#map").get(0)),k=new GLatLng(49.5,-118.4);f.setCenter(k,5);var d=new GDirections(f,$("#directions").get(0));GEvent.addListener(d,"error",u);function u(){if(d.getStatus().code==G_GEO_UNKNOWN_ADDRESS)alert("Location could not be found.\n\nMake sure all street and city names are spelled correctly.\n\nMake sure your address includes a city and province.\n\nTry entering a Postal Code.\n\nError code: "+
d.getStatus().code);else if(d.getStatus().code==G_GEO_SERVER_ERROR)alert("A geocoding or directions request could not be successfully processed,\n\nyet the exact reason for the failure is not known.\n\nError code: "+d.getStatus().code);else if(d.getStatus().code==G_GEO_MISSING_QUERY)alert("The HTTP q parameter was either missing or had no value.\n\nFor geocoder requests, this means that an empty address was specified as input.\n\nFor directions requests, this means that no query was specified in the input.\n\nError code: "+
d.getStatus().code);else if(d.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\n Error code: "+d.getStatus().code);else d.getStatus().code==G_GEO_BAD_REQUEST?alert("A directions request could not be successfully parsed.\n\nError code: "+d.getStatus().code):alert("An unknown error occurred.");location.reload(true)}$("#submitBTN").click(function(){var b=$("input#fromAddress").val();if(b==""||b==" ")alert("Please enter an address");
else{$("#getDir").css("display","none");$("#overlayBG").css("display","none");$("p.mapLinks").css("display","none");$("#mapReset").css("display","block");$("#mapResetLink").click(function(){location.reload(true)});$("#directions").css("display","block");$("div.googledir table tr").css("background-color","#eee");for(e=0;e<3;e++){c[e].hide();c[e].closeInfoWindow()}var h="en";d.load("from: "+b+" to: "+j,{locale:h});return false}});$("#overlayBG").click(function(){$("#getDir").css("display","none");$("#overlayBG").css("display",
"none")});f.addControl(new GSmallMapControl);var a=[];a[0]=[49.123816,-123.100339,"Richmond, BC (Head Office)","Suite 100 - 12251 Horseshoe Way","Richmond, BC","V7A 4V4","(604) 272-6000"];a[1]=[48.436,-123.37,"Victoria, BC","570 Bay Street","Victoria, BC","V8T 1P9","(250) 953-2050"];a[2]=[49.6983,-112.833,"Lethbridge, AB","110-905 1st Avenue S.","Lethbridge, AB","T1J 4M7","(403) 320-1551"];for(var c=[],e=0;e<3;e++){k=new GLatLng(a[e][0],a[e][1]);var v={title:a[e][2]};marker=new GMarker(k,v);f.addOverlay(marker);
c[e]=marker}$(c).each(function(b,h){var w=a[b][2],n=a[b][3],o=a[b][4],p=a[b][5],x=a[b][6],y="<a href='#' id='bubbleLink' onclick='getStoreDir();'>Get Directions</a>",q="<strong>"+w+"</strong><br><br>"+n+"<br>"+o+", "+p+"<br>"+x+"<br><br>";function z(){h.openInfoWindowHtml(q+y);$(".storeAddress").html(q);j=n+" "+o+" "+p}GEvent.addListener(h,"click",function(){f.setZoom(15);i(h,b);z(b)});function l(g){var m=a[g][2],r=a[g][3],s=a[g][4],t=a[g][5];g=a[g][6];m="<strong>"+m+"</strong><br><br>"+r+"<br>"+
s+", "+t+"<br>"+g+"<br><br>";$(".storeAddress").html(m);j=r+" "+s+" "+t;$("#getDir").css("display","block");$("#overlayBG").css("display","block")}$("#richmondDir").click(function(){l(0)});$("#victoriaDir").click(function(){l(1)});$("#lethbridgeDir").click(function(){l(2)})});$("#richmondZoom").click(function(){$("#getDir").css("display","none");$("#overlayBG").css("display","none");c[0].show();c[0].closeInfoWindow();f.setZoom(15);i(c[0])});$("#victoriaZoom").click(function(){$("#getDir").css("display",
"none");$("#overlayBG").css("display","none");c[1].show();c[1].closeInfoWindow();f.setZoom(15);i(c[1])});$("#lethbridgeZoom").click(function(){$("#getDir").css("display","none");$("#overlayBG").css("display","none");c[2].show();c[2].closeInfoWindow();f.setZoom(15);i(c[2])});function i(b){f.panTo(b.getLatLng())}$(window).unload(function(){GUnload()})});function getStoreDir(){$("#getDir").css("display","block");$("#overlayBG").css("display","block").animate({opacity:0.6})};