GoogleMap = function(id, x, y, zoom){
	this.map = null;
	this.markers = new Array();
	this.elId = id;
	this.x = parseFloat(x);
	this.y = parseFloat(y);
	this.zoom = parseInt(zoom);
	
	if(this.x+'' == 'NaN' || this.y+'' == 'NaN' || this.zoom+'' == 'NaN'){
		this.x = 53.74871079689897;
		this.y = 57.3046875;
		this.zoom = 4;
	}
	
	this.createMarker = function (point, title, href, isCity, notRemove) {
		if(notRemove+'' == 'undefined' || !notRemove || notRemove == null) notRemove = false;
		if(title+'' == 'undefined' || !title || title == null) title = '';
		if(!notRemove)this.removeMarker();
		var letteredIcon = new GIcon(this.baseIcon);
		letteredIcon.image = (isCity ? "/img/au_city.GIF" : "/img/logo_google_small.gif");	
		letteredIcon.iconSize = (isCity ? new GSize(29, 33) : new GSize(35, 29));
		
		markerOptions = {
			icon: letteredIcon,
			title: (String(title).length > 0 ? title : this.name)
		};
		var marker = new GMarker(point, markerOptions);

		this.markers[this.markers.length] = marker;
		this.map.addOverlay(marker);
		
		if(href)
			GEvent.addListener(marker, "click", function() {
				document.location = href;
	        });

				
		return marker;
	};

	this.loadGmap = function(noScale) {
		if(!noScale) noScale = false;
		
		if (GBrowserIsCompatible()) {
			this.map = new GMap2(document.getElementById(this.elId));
			this.map.setCenter(new GLatLng(this.x, this.y), this.zoom);
			this.map.setting = false;
			this.map.screenSet = false;
			this.map.panel = this;
			if(noScale){
				this.map.disableDoubleClickZoom();
				this.map.disableContinuousZoom();
				this.map.disableScrollWheelZoom();
				this.map.disablePinchToZoom();
			} else {
				this.map.addControl(new GMapTypeControl());
				this.map.addControl(new GLargeMapControl3D());
				this.map.enableScrollWheelZoom();
			}
			

			this.baseIcon = new GIcon();
			this.baseIcon.iconSize = new GSize(35, 29);
			this.baseIcon.iconAnchor = new GPoint(18, 29);
		}
	};
	
	this.removeMarker = function(){
		if (this.markers.length > 0) {
			for(var i=0; i < this.markers.length; i++) {
				if (this.marker != this.markers[i]) {
					this.map.removeOverlay(this.markers[i]);
					this.markers[i] = null;
				}
				this.markers.splice(i, 1);
			}
		}
	};
}
