var plan_key = ''; var meet_loc_url = '/unm/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 = [ [78908240,'A+Lot',35.08132168034191,-106.61810874938965],[78908854,'Coronado+Hall',35.082989826208156,-106.61478281021118],[78909485,'Lot+C',35.08555343651704,-106.62340879440308]]; // create a data structure for all the location groups var loc_grps = [ [78599381, 35.083288314355702, -106.61876678466797, 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 = [ [2968515,1014543,78908240,[49167247,'']],[94564,1362743,78909485,[49167247,'']],[94563,45910234,78908854,[49167247,'']] ]; // local array of makes and models so we can tell which is which var mks_mos = [[2968515,1],[1014543,0],[94563,1],[45910234,0],[94564,1],[1362743,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,8586495,8577469,8577471]; // get a local mapping of locations to location groups. this allows us to trim accordion // results by neighborhood. var lgmap = [[78908240,78599381],[78908854,78599381],[78909485,78599381]]; // get a local mapping of models to styles. this allows us to trim accordion results by style var stylemap = [[1014543,8577468],[1362743,8577469],[45910234,8577471],[45910234,8586495]]; // 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 + ', New Mexico', 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 - 35.08328831, 2) + Math.pow(firstaddr.lng - -106.61876678, 2)); new_dist = Math.sqrt(Math.pow(s.lat() - 35.08328831, 2) + Math.pow(s.lng() - -106.61876678, 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"); } }); }); } }