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, type, notRemove) {
		type = type === true ? 'city' : type;
		if(type != 'city' && type != 'sad' && type != 'shop') type = 'shop';
		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);
		switch(type) {
			case 'city':
				iconPath = "/images/mark1.png";
				break;
			case 'sad':
				iconPath = "/images/mark3.png";
				break;
			case 'shop':
			default:
				iconPath = "/images/mark2.png";
				break;
		}
		letteredIcon.image = iconPath;	
		letteredIcon.iconSize = new GSize(43, 54);
		
		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(43, 54);
			this.baseIcon.iconAnchor = new GPoint(20, 54);
		}
	};
	
	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);
			}
		}
	};
}

