// Author: Aditya Raj
// Dated: 20th August 2007
location_loader = {
init: function(options){
this.options = options;
this.selector = $(this.options.selector);
Event.observe(this.selector, 'change', this.loadAddress.bindAsEventListener(this));
for(var i=0; i < this.options.data.length; i++){
this.selector.options[this.selector.options.length] = new Option(this.options.data[i].name, i);
}
Event.observe(window, 'load', this.loadAll.bindAsEventListener(this));
},
loadAddress: function(event){
var selectedOffice = this.options.data[Event.element(event).getValue()];
if (this.selector.value == 'Show All'){
$('officeInfo').innerHTML = "";
return this.loadAll();
}
if(!selectedOffice) return false;
var geocoder = new GClientGeocoder();
this.map = new GMap2($(this.options.mapContainer));
this.from_address = selectedOffice.address
geocoder.getLatLng(this.from_address, this.loadMap.bindAsEventListener(this));
var info = this.from_address;
if(selectedOffice.lobby) info += "
Lobby: " + selectedOffice.lobby;
if(selectedOffice.drive_in) info += "
Drive-in: " + selectedOffice.drive_in;
if(selectedOffice.office) info += "
Office: " + selectedOffice.office;
if(selectedOffice.telephone) info += "
Telephone: " + selectedOffice.telephone;
if(selectedOffice.fax) info += "
Fax: " + selectedOffice.fax;
$('officeInfo').innerHTML = info;
},
show_google_from_to_map: function(){
var to = $('text_box').value;
// blank and empty are defined in prototype 1.5.1
if (to==""){ return alert ('Adress is blank !'); }
// else simply call the google's map in new window
else{
// http://maps.google.com/?q=+to+
from = this.from_address;
from = from.gsub(' ','+');
to = to.gsub(' ','+');
url = "http://maps.google.com/?q=" + from + '+to+' + to
window.open(url);
}
},
loadAll: function(){
this.map = new GMap2($(this.options.mapContainer));
for(var i=0; iPlease fill in your address." +
"
Find my directions...");});
}
};