var SGMaps = Class.create();
	SGMaps.prototype = {
			_geocoder : null,
			_mapdiv : null,
			_mapOptions : null,
			_defaultMapOptions : null,
			_map : null,
		initialize : function(mapdivId) {
			this._geocoder = new google.maps.Geocoder();
			this._mapdiv= document.getElementById(mapdivId);
			var	defaultLat=47.516231;
			var	defaultLng=13.550072;
			this._defaultMapOptions = {
				      zoom: 6,
				      center: new google.maps.LatLng(defaultLat, defaultLng),
				      mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			this._mapOptions = {
				      zoom: 13,
				      center: new google.maps.LatLng(defaultLat, defaultLng),
				      mapTypeId: google.maps.MapTypeId.ROADMAP
			};
		},
		showMapByGPS : function(lat, lng, seaHeight,title){
			var point = new google.maps.LatLng(lat, lng);
			this.showMap(point,title);
		},
		showMap : function(point,title,htmlBubble){
			this._mapOptions.center=point;
			this._map = new google.maps.Map(this._mapdiv,this._mapOptions);
	        var marker = new google.maps.Marker({
	            'position': point,
	            'title':title,
	            'map':this._map
	        });
	        
	        // create html-infowindow
	        var myMap = this._map;
	        if ( htmlBubble ) {
		        var infoWindow = new google.maps.InfoWindow({content: htmlBubble});
		        google.maps.event.addListener(marker, 'click', function () {infoWindow.open(myMap, marker);});
		        
		        // if we display the bubble later the map will move to make the bubble fully visible automatically 
		        setTimeout(function () {infoWindow.open(myMap, marker);}, 1500);	// we want to see the bubble as well
	        }
		},
		showDefaultPoint : function(){
			this._map = new google.maps.Map(this._mapdiv,this._defaultMapOptions);
		}, 
		//  vars = {'immoId':immoId};
		//  usage: showMapByAddressComponents(countryCtl.value,plzCtl.value,ortCtl.value,strCtl.value,nrCtl.value,title, callBackWithPoint,vars);
		//  callBackWithPoint should look like: function callBackWithPoint(vars, lat, lng, sh)
		showMapByAddressComponents : function(cc, plz, ort, str, strNr, title, callBackWithPoint, vars){
			var address = str + ' ' + strNr + ', ' + plz + ' ' + ort + ', ' + cc;
			this.showMapByAddress(address,title,callBackWithPoint,vars);
		},
		showMapByAddress : function(address,title,htmlBubble,vars){
			this._geocoder.geocode({
				 'address': address
				}, function(results){
					if(results){
						if(results[0]){
							point = results[0].geometry.location;
							this.showMap(point,title,htmlBubble);
						}
					}
			}.bind(this));
		}
	};
