/*
 * Google Map Class
 */
GoogleMap = function(location) {
  
  if(document.getElementById(location)) {
    this.mapContainer = document.getElementById(location);
  } else {
    this.mapContainer = null;
  }
  
  this.map = null;
  this.marker = [];
  this.lines = [];
  this.zoomlevel = null;

}

GoogleMap.prototype.initialize = function () {
  
  if (GBrowserIsCompatible()) {
    this.map = new GMap2(this.mapContainer);
    this.map.setCenter(new GLatLng(50, 10), 3);
    this.map.addControl(new GSmallMapControl());
    this.map.enableScrollWheelZoom()
    
    this.clusterer = new Clusterer(this.map);
  }
  
}

GoogleMap.prototype.getMap = function () {
  return this.map;
}

GoogleMap.prototype.addPushpin = function() {
}

/*
 * Google Map directions class
 */
GoogleMapDirections = function(map, summary) {
  this.map = map;
  this.summary = summary;
  this.direction = null;
  this.route = null;
  this.from = null;
  this.to = null;
  this.over = '';
}

GoogleMapDirections.prototype.initialize = function () {
  
  var direction = this.direction = new GDirections(this.map ,document.getElementById(this.summary));
  GEvent.addListener(direction, "load", function() {
  });
  GEvent.addListener(direction, "error", function() {
    alert(direction.getStatus().code);
  });
  
}

GoogleMapDirections.prototype.setRoute = function (from,to,over) {
  this.from = from;
  this.to = to;
  if(over != '') {
    this.over = ' to: '+over;
  } else {
    this.over = '';
  }
}

GoogleMapDirections.prototype.getRoute = function (locale) {
  if(locale == "") {
	locale = 'de_DE';
  }
  this.direction.load('from:'+this.from+this.over+' to: '+this.to,{ "locale": locale });
}
