var plan_key = ''; var meet_loc_url = '/yale/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 = [ [198295638,'Whitney+Ave%2fHumphrey+St',41.31769771915374,-72.92095363140106],[60287993,'Yale+School+of+Medicine',41.30284512937652,-72.93160200119019],[60291971,'Yale+University+-+221+Whitney+Ave%2e',41.316855,-72.920133],[185281302,'Yale+University+-+246+Church+St',41.30987292946039,-72.92316913604736],[128471624,'Yale+University+-+25+Science+Park',41.320461555279266,-72.92861938476562],[110952058,'Yale+University+-+393+Prospect+St',41.32294326743418,-72.92306184768677],[60289388,'Yale+University+-+Hendrie+Hall',41.30990516533017,-72.92484283447266],[60288641,'Yale+University+-+Ingalls+Rink+Lot+26V',41.31628755352778,-72.92462825775146],[60291646,'Yale+University+-+Payne+Whitney+Gym',41.31482094891284,-72.92922019958496]]; // create a data structure for all the location groups var loc_grps = [ [60288272, 41.314632140941654, -72.92513669921112, 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,198295638,['']],[2190563,6869299,60287993,['']],[2968515,1014543,60289388,['']],[2190563,6869299,60291646,[49167247,'']],[94564,742432,60291971,['']],[94563,33798998,110952058,[49167247,'']],[94563,33798998,60289388,['']],[94564,742432,128471624,[49167247,'']],[2190563,9876627,60289388,[49167247,'']],[2190563,9876627,60291646,['']],[4264850,4264865,185281302,[49167247,'']],[4264850,4264865,60291971,[49167247,'']],[4264850,4264865,60287993,[49167247,'']],[94563,163026706,185281302,[49167247,'']],[94564,3398752,60291646,[49167247,'']],[94564,3398752,185281302,[49167247,'']],[94564,3398752,198295638,[49167247,'']],[94564,3398752,110952058,[49167247,'']],[94564,3398752,60287993,[49167247,'']],[94564,3398752,198295638,[49167247,'']],[94564,3398752,60287993,[49167247,'']],[94563,163026706,198295638,[49167247,'']],[94563,163026706,198295638,[49167247,'']],[94564,3398752,198295638,[49167247,'']],[94564,3398752,60288641,[49167247,'']],[94564,742432,60288641,[49167247,'']],[94564,3398752,60289388,[49167247,'']] ]; // local array of makes and models so we can tell which is which var mks_mos = [[2968515,1],[1014543,0],[94563,1],[33798998,0],[163026706,0],[2190563,1],[6869299,0],[9876627,0],[4264850,1],[4264865,0],[94564,1],[742432,0],[3398752,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]; // get a local set of ids for the styles so we can easily figure out what styles are needed var styles = [8577468,142802904,8586495,8577471,8577470,8577473]; // get a local mapping of locations to location groups. this allows us to trim accordion // results by neighborhood. var lgmap = [[60287993,60288272],[60288641,60288272],[60289388,60288272],[60291646,60288272],[60291971,60288272],[110952058,60288272],[128471624,60288272],[185281302,60288272],[198295638,60288272]]; // get a local mapping of models to styles. this allows us to trim accordion results by style var stylemap = [[742432,8577473],[1014543,8577468],[3398752,8586495],[4264865,8577473],[6869299,8577471],[9876627,142802904],[33798998,8577470],[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 + ', Connecticut', 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 - 41.31463214, 2) + Math.pow(firstaddr.lng - -72.9251367, 2)); new_dist = Math.sqrt(Math.pow(s.lat() - 41.31463214, 2) + Math.pow(s.lng() - -72.9251367, 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"); } }); }); } }