var gmaps3 = new Class({
  //map: null,
  //geocoder: null,
  options: {
    div_id: 'map_canvas',
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    navigationControl: true,
    scaleControl: false,
    mapTypeControl: true,
    zoom: 15,
    base_url: 'http://static.meseon.net/images/common/map/',
    p_default: 'pointer_b.png',
    p_news: 'pointer_b.png',
    p_museum: 'pointer_g.png',
    p_gallery: 'pointer_p.png',
    p_ahouse: 'pointer_r.png'
  },
  initialize: function(myOptions) {
    this.map= null;
    this.geocoder= null;

    this.setOptions(myOptions);    
    //this.options= myOptions;

  },
  
//register: function(field, options) {
  getOptions: function()	{
	 return { zoom: this.options.zoom, mapTypeId: this.options.mapTypeId , navigationControl: this.options.navigationControl, 
		scaleControl: this.options.scaleControl, mapTypeControl: this.options.mapTypeControl };
   },

  unload: function ()	{
  },
  getPoint: function(latitude, longitude)	{
    return new google.maps.LatLng(latitude, longitude);
  },
  getGalleryImageMarker: function()	{
    return this.getImageMarker(this.options.base_url + this.options.p_gallery, 20, 32);
  },
  getMuseumImageMarker: function()	{
    return this.getImageMarker(this.options.base_url + this.options.p_museum, 20, 32);
  },
  getAhouseImageMarker: function()	{
    return this.getImageMarker(this.options.base_url + this.options.p_ahouse, 20, 32);
  },
  getNewsImageMarker: function()	{
    return this.getImageMarker(this.options.base_url + this.options.p_news, 20, 32);
  },

  getImageMarker: function(image_url, width, height)	{
    return new google.maps.MarkerImage(image_url, 
	   new google.maps.Size(width, height), new google.maps.Point(0,0), 
	   new google.maps.Point(0, height),  new google.maps.Size(width, height));
  },

  getMarker: function(point, image, i_title)	{
	 return new google.maps.Marker({ position: point, map: this.map, icon: image , title: i_title});
  },

  getMap: function(myOptions)	{
    this.map= new google.maps.Map(document.getElementById(this.options.div_id), myOptions);
    this.setGeocoder();
  },

  setMap: function(myOptions)	{
    this.getMap(myOptions);
  },
  setMapCenter: function(point, zoom)	{    
    if (point != null)	{
	 this.map.setCenter(point);
	 if (zoom > 0)
	   this.map.setZoom(zoom);
    }
  },
  getInfoWindow: function(frame)	{
    return getInfoWindow(frame, -1);
  },
  setGeocoder: function()	{
    this.geocoder = new google.maps.Geocoder();
  },
  getBounds: function()	{
    return this.map.getBounds();
  },
  getInfoWindow: function(frame, maxWidth)	{
    if (maxWidth>0)
	 return new google.maps.InfoWindow({content: frame, maxWidth: maxWidth});
    else
	 return new google.maps.InfoWindow({content: frame});
  },
  searchAddress: function(address, zoom)	{
    _m= this.map;
    if (this.geocoder)	{
      this.geocoder.geocode( { 'address': address}, function(results, status) {
	   if (status == google.maps.GeocoderStatus.OK) {
		_m.setCenter(results[0].geometry.location);
		if (zoom>0)
		  _m.setZoom(zoom);		
		return results[0].geometry.location;
	   } else {}
    });
    }
    return null;
  }

});

function searchAddress(gmaps, address, zoom)	{
  if (gmaps.geocoder) {
      gmaps.geocoder.geocode( { 'address': address}, function(results, status) {
	   if (status == google.maps.GeocoderStatus.OK) {
		gmaps.map.setCenter(results[0].geometry.location);
		gmaps.map.setZoom(zoom);
		return results[0].geometry.location;
	   } else {}

    });
  }
  return null;
}

gmaps3.implement(new Options);// Implements setOptions(defaults, options)

