function GMaps(container_id, lat_lng, _zoom, _map_type, disable_ui, callback){
	
	this.markersArray = new Array();
	this.infoWindowsArray = new Array();
	
	var myOptions = {
		disableDefaultUI: disable_ui,
		zoom: _zoom ? _zoom : 8,
		mapTypeId: _map_type ? _map_type : google.maps.MapTypeId.ROADMAP,
		navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL}
	};
    	
	this.map = new google.maps.Map(document.getElementById("google_map"), myOptions);
    
	
	if(lat_lng){
		if(typeof lat_lng == 'string'){
			this.findAddress(lat_lng, callback, false);
		}else{
			this.map.setCenter(lat_lng);
		}
	}else{
		this.setDefaultCenter();
		//this.getUserLocation();
	}
	
}

GMaps.prototype = {
	
	addMarker: function(latLng, title, text, open_by_click, icon){
		var iw = -1;
		var marker = new google.maps.Marker({
			'position': latLng,
			'map': this.map,
			'title': title,
			'icon': icon
		});
		if(text){
			if(!open_by_click)
				var iw = this.addInfoWindow(text, null, marker);	
			else{
				var oThis = this;		
				var iw = this.addInfoWindow(text);
				google.maps.event.addListener(
					marker,
					'click',
					function(){
						oThis.infoWindowsArray[iw].open(oThis.map, marker);
					}
				);
			}
		}
		this.markersArray.push({'marker': marker, 'iw': iw});
	},
	
	removeMarkers: function(){
		for(var i=0; i<this.markersArray.length; i++){
			this.markersArray[i]['marker'].setMap(null);
			if(this.markersArray[i]['iw'] > -1)
				this.infoWindowsArray[this.markersArray[i]['iw']].close();
		}
		this.markersArray.length = 0;
	},
	
	addInfoWindow: function(text, latLng, marker, autopan){
		
		var wnd = new google.maps.InfoWindow({disableAutoPan: autopan});
		wnd.setContent(text);
		if(latLng){
			wnd.setPosition(latLng);
			wnd.open(this.map);
		}else{
			if(marker){
				wnd.open(this.map, marker);
			}
		}
		
		this.infoWindowsArray.push(wnd);
		return this.infoWindowsArray.length-1;
		
	},
	
	findAddress: function(adr, callback, add_marker){				
		var oThis = this;		
		geocoder = new google.maps.Geocoder();	
		geocoder.geocode(
			{'address': adr},
			function(results, status){
				if(status == google.maps.GeocoderStatus.OK){
					oThis.map.setCenter(results[0].geometry.location);
					if(add_marker)
						oThis.addMarker(results[0].geometry.location);
					if(callback)
						callback(oThis);
				}else{
					alert("Geocode was not successful for the following reason: " + status);
				}
			}
		);	
	},
	
	setEventHandler: function(ev, callback){
		var oThis = this;
		google.maps.event.addListener(
			oThis.map, 
			ev, 
			function(event){
				if(event)
					callback(event, oThis);
				else
					callback(oThis);
			}
		);
	},
	
	getUserLocation: function(){			
		var oThis = this;			
		if(navigator.geolocation){
			browserSupportFlag = true;
			navigator.geolocation.getCurrentPosition(
				function(position) {
					oThis.map.setCenter(new google.maps.LatLng(position.coords.latitude,position.coords.longitude));					
				}, 
				function(){
					oThis.setDefaultCenter();
				}
			);		
		}else{		
			// Try Google Gears Geolocation
			if(google.gears){ 
				var geo = google.gears.factory.create('beta.geolocation');
				geo.getCurrentPosition(
					function(position) {
						oThis.map.setCenter(new google.maps.LatLng(position.latitude,position.longitude));
					},
					function(){
						oThis.setDefaultCenter();
					}
				);
			}
		}
	},
	
	setDefaultCenter: function(){
		var LatLng = new google.maps.LatLng(-34.397, 150.644);
		this.map.setCenter(LatLng);
	}
	
}
