
var directions=null;var showError=null;var map;var buildings=new Array();var markers=new Array();function createMarker(point,building,icon){var marker=null;if(point!=null){if(icon!=null){marker=new GMarker(point,icon);}
else{marker=new GMarker(point);}
map.addOverlay(marker);GEvent.addListener(marker,"click",function(){if($("#building").val()!=building.code){$("#building").val(building.code);}
marker.openInfoWindowHtml(building.message);map.setCenter(point,map.getZoom());if(directions!=null){directions.clear();}
$("#site-details").html(building.message);});}
return marker;}
function createMap(set){set=set.toString();var cpoint;$.get("/global/scripts/api/class-sites/set/"+set,null,function(data){var response=eval('('+data+')');if(GBrowserIsCompatible()){var i=0;map=new GMap2(document.getElementById('google-map'));geocode=new GClientGeocoder;cpoint=new GLatLng(42.268542,-83.664541);map.setCenter(cpoint,13);map.setUIToDefault();while(response[i]!=null){var building=response[i];var icon=null;var point=new GLatLng(building.geocode['lat'],building.geocode['long']);if(building.code=='WCC'){icon=new GIcon(G_DEFAULT_ICON);icon.image='/global/media/images/icons/star.png';icon.shadow='/global/media/images/icons/star-shadow.png';icon.iconSize=new GSize(32,32);icon.shadowSize=new GSize(47,31);}
markers[building.code]=createMarker(point,building,icon);buildings[building.code]=building;i++;}
GEvent.trigger(markers[$("#building").val()],'click');}});$("#building").change(function(){if(markers[$(this).val()]==undefined){$(this).val='WCC';}
GEvent.trigger(markers[$(this).val()],'click');});$("form#directions").submit(function(event){event.preventDefault();if(GBrowserIsCompatible()){var from=$("#address").val();var code=$("#building").val();var building=buildings[code];var to=building.address['street1']+' '+building.address['street2']+' '+
building.address['city']+', '+building.address['state']+' '+building.address['zip'];$("form#directions li:first").removeClass('error');$("form#directions li:first span:first strong").remove();if(from!=''){if(directions!=null){directions.clear();}
directions=new GDirections(map,document.getElementById('route'));GEvent.addListener(directions,'error',function(){if(showError!=null){$("form#directions li:first").addClass('error');$("form#directions li:first span:first").append("<strong>We couldn&rsquo;t find this address.</strong>");showError=null;}
else{to=building.geocode['lat']+' '+building.geocode['long'];showError=true;directions.load("from: "+from+" to: "+to);}});GEvent.addListener(directions,'load',function(){showError=null;var offset=$("#google-map").offset().top;$("html,body").animate({scrollTop:offset},1000);});directions.load("from: "+from+" to: "+to);}
else{$("form#directions li:first").addClass('error');$("form#directions li:first span:first").append("<strong>Enter your starting location.</strong>");}}});}