var plan_key = ''; var meet_loc_url = '/umich/meet-location'; // handy images var img_zipmarker, img_youarehere, img_nomatch, img_expanded, img_unknown; img_youarehere = "/images/zipmarker-youarehere.png"; img_nomatch = "/images/zipmarker-reserved.png"; img_expanded = "/images/zipmarker-viewing.png"; img_zipmarker = "/images/zipmarker.png"; img_unknown = "/images/zipmarker-unknown.png"; img_shadow = "/images/zipshadow.png"; // create a data structure for all the locations var locs = [ [158385894,'4th+Ave%2fCatherine+St',42.28323,-83.74726],[31749512,'Ann+St+%2f+Zina+Pitcher+Place',42.282419999999995,-83.73390000000002],[31748733,'Bonisteel+Blvd+%2f+Beal+Ave',42.29052999999999,-83.71280999999998],[198214905,'Fletcher+St+Parking+Structure',42.279983904259225,-83.73658061027527],[201694538,'Glen+Ave+Parking+Structure',42.28332567271289,-83.73674154281616],[146823936,'Hill+St+Parking+Structure',42.272212218224176,-83.73695611953735],[158385617,'Main+St%2fWilliam+St',42.27789,-83.74869],[67739444,'Packard+St+%2f+E+Madison+St',42.2739111160228,-83.74350070953369],[217582197,'Student+Activities+Building+-+W13+Parking+Lot',42.27723733003858,-83.74291598796844],[230110992,'Washington+St+btwn+Division+and+State',42.280468114468704,-83.74206304550171]]; // create a data structure for all the location groups var loc_grps = [ [32067203, 42.2778563926210625, -83.73979300260543666666666666666666666667, 15],[158421164, 42.280529371489568, -83.74600434850057, 15],[32067227, 42.282419999999995, -83.73390000000002, 15],[32067219, 42.29052999999999, -83.71280999999998, 15]]; // even though we have vehicle_id, it is not relevant at this stage since it will just be used for // counting up how many vehicles match said criteria. we will leave it out of the array. // make, model, location, amenity list var vehicles = [ [94564,742432,31748733,['']],[94562,5107542,31748733,['']],[2190563,6869299,201694538,['']],[4264850,55604681,31748733,[49167247,'']],[94564,742432,67739444,[49167247,'']],[2968515,1014543,198214905,['']],[94563,68894811,146823936,['']],[94563,45910234,146823936,['']],[4264850,55604681,158385617,[49167247,'']],[94564,742432,158385894,[49167247,'']],[94564,742432,158385617,[49167247,'']],[4264850,55604681,158385894,[49167247,'']],[94563,163026706,67739444,[49167247,'']],[94562,5107542,198214905,[485650,49167247,'']],[94562,5107542,217582197,[485650,49167247,'']],[94562,5107542,67739444,[49167247,'']],[94564,742432,31749512,[49167247,'']],[94562,5107542,31749512,[49167247,'']],[94562,5107542,217582197,[49167247,'']],[94562,5107542,230110992,[49167247,'']],[94563,94567,230110992,[49167247,'']] ]; // local array of makes and models so we can tell which is which var mks_mos = [[2968515,1],[1014543,0],[94562,1],[5107542,0],[94563,1],[94567,0],[45910234,0],[163026706,0],[68894811,0],[2190563,1],[6869299,0],[4264850,1],[55604681,0],[94564,1],[742432,0]]; // get a local set of ids for the amenities (we dont really need the description, unless // we want to get really fancy and have the form adjust itself based on selections made // (only show relevant body styles / amenities / neighborhoods based on the chosen make/model) var amenities = [49167247,485650]; // get a local set of ids for the styles so we can easily figure out what styles are needed var styles = [8577468,142802904,8586495,8577469,8577471,8577470,8577473]; // get a local mapping of locations to location groups. this allows us to trim accordion // results by neighborhood. var lgmap = [[67739444,32067203],[146823936,32067203],[198214905,32067203],[201694538,32067203],[217582197,32067203],[230110992,32067203],[31748733,32067219],[31749512,32067227],[158385617,158421164],[158385894,158421164],[230110992,158421164]]; // get a local mapping of models to styles. this allows us to trim accordion results by style var stylemap = [[94567,8577471],[742432,8577473],[1014543,8577468],[5107542,8577470],[6869299,8577471],[45910234,8577471],[45910234,8586495],[68894811,8577469],[163026706,8586495],[163026706,142802904]]; // globals for finding your local address in the search box var closestaddr = new Object(); var firstaddr = new Object(); var addrstr; // TODO: right now, this just returns the coords for one address, // we should expand this to support multiple address geocoding function refreshCarsByAddress() { var addr = document.getElementById('gmaps-address').value; addrstr = addr; var new_addr; if (addr.match(/[ ]*/) != null && addr != "enter some or all of an address") { geocode(addrstr, function (p) { // see if this address is closer to the current fleet of a modified address is closer if (p) { firstaddr.lat = p.lat(); firstaddr.lng = p.lng(); } else { // this is kinda lame, but at least it is in the ocean firstaddr.lat = 0; firstaddr.lng = 0; } geocode(addrstr + ', Michigan', function (s) { var old_dist, new_dist, e; if (!s && (firstaddr.lat == 0 && firstaddr.lng == 0)) { closestaddr.lat = 0; closestaddr.lng = 0; } else if (!s) { closestaddr.lat = firstaddr.lat; closestaddr.lng = firstaddr.lng; } else if (firstaddr.lat == 0 && firstaddr.lng == 0) { closestaddr.lat = s.lat(); closestaddr.lng = s.lng(); } else { old_dist = Math.sqrt(Math.pow(firstaddr.lat - 42.27994575, 2) + Math.pow(firstaddr.lng - -83.73477214, 2)); new_dist = Math.sqrt(Math.pow(s.lat() - 42.27994575, 2) + Math.pow(s.lng() - -83.73477214, 2)); if (old_dist >= new_dist) { closestaddr.lat = s.lat(); closestaddr.lng = s.lng(); } else { closestaddr.lat = firstaddr.lat; closestaddr.lng = firstaddr.lng; } } if (!(closestaddr.lat == 0 && closestaddr.lng == 0)) { find_loc.in_progress = 1; find_loc.retry = 1; place_home(closestaddr.lat, closestaddr.lng); recenter(eval(find_loc.map), closestaddr.lat, closestaddr.lng, 16, 0); e = document.getElementById('location_group_id'); if (e) { e.selectedIndex = 0; } $('#new-type-filter').hide(); find_loc.in_progress = 0; refreshAccordion(find_loc); } else { alert("sorry, we couldn't find that address"); } }); }); } }