function googleMaps(element_id) {
	
	var defunct = false;
	var map;
	var map_div;
	var cords;
	var zoom;
	var geocoder;
	var gdir;
	var gdir_route_container;
	var controls;
	
	if(!element_id) {
		this.defunct = true;
	}
	else {
		this.map_div = element_id;
		this.cords = new Array(0, 0);
		this.zoom = 1;
	}
	
}

googleMaps.prototype.loadMap = function() {
	
	if(!this.defunct) {
		this.map = new GMap2(document.getElementById(this.map_div));
		this.map.setCenter(new GLatLng(this.cords[0], this.cords[1]), this.zoom);
	}

}

googleMaps.prototype.addControl = function(control) {
	
	if(!this.controls) {
		this.controls = new Object();
	}
	
	switch(control) {
		case("smallMapControl"):
			this.controls[control] = new GSmallMapControl();
		break;
		case("largeMapControl"):
			this.controls[control] = new GLargeMapControl();
		break;
		case("smallZoomControl"):
			this.controls[control] = new GSmallZoomControl();
		break;
		case("scaleControl"):
			this.controls[control] = new GScaleControl();
		break;
		case("mapTypeControl"):
			this.controls[control] = new GMapTypeControl();
		break;
	}

	if(this.controls[control]) {
		this.map.addControl(this.controls[control]);
	}
	
}

googleMaps.prototype.removeControl = function(control) {
	this.map.removeControl(this.controls[control]);	
}

googleMaps.prototype.checkResize = function() {
	this.map.checkResize();
}

googleMaps.prototype.enableRouting = function(element) {
	
	if(!this.gdir_route_container) {
		this.gdir_route_container = document.getElementById(element);
	}
	
	this.gdir = new GDirections(this.map, this.gdir_route_container);
	GEvent.addListener(this.gdir, "error", this.routeHandleErrors);
}

googleMaps.prototype.calcRoute = function(start, end) {
	this.gdir.load("from: " + start + " to: " + end);
}

googleMaps.prototype.clearRouteResults = function() {
	this.gdir.clear();
}

googleMaps.prototype.routeHandleErrors = function() {
	if (this.gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		this.throwRouteError("Die eingegebene Adresse konnte nich gefunden werden!");
	else if (this.gdir.getStatus().code == G_GEO_SERVER_ERROR)
		this.throwRouteError("Eine Routenberechnung ist zur Zeit nicht möglich!");
	else if (this.gdir.getStatus().code == G_GEO_MISSING_QUERY)
		this.throwRouteError("Es wurde keine Adresse angegeben!");
	else if (this.gdir.getStatus().code == G_GEO_BAD_KEY)
		this.throwRouteError("Der API Key ist nicht korrekt!");
	else if (this.gdir.getStatus().code == G_GEO_BAD_REQUEST)
		this.throwRouteError("Die Anfrage konnte nicht bearbeitet werden!");
	else 
		this.throwRouteError("Es ist ein unbekannter Fehler aufgetreten!");
}

googleMaps.prototype.throwRouteError = function(error) {
	if(this.gdir_route_container) {
		this.gdir_route_container.innerHTML = error;
	}
}

googleMaps.prototype.setCords = function(cords) {
	
	switch(typeof cords) {
		case("object"):
			this.cords = new Array(cords.lat(), cords.lng());
		break;
		case("string"):
			this.cords = cords.split(",");
		break;
	}
	
}

googleMaps.prototype.setZoom = function(zoom) {
	
	if(typeof zoom != "number") {
		zoom = parseInt(zoom);
	}
	
	if(zoom > 18) {
		zoom = 18;
	}
	
	this.zoom = zoom;
}

googleMaps.prototype.addMarker = function(cords, content, show_content) {
	
	switch(typeof cords) {
		case("object"):
			point = new GLatLng(cords.lat(), cords.lng());
		break;
		case("string"):
			cords = cords.split(",");
			point = new GLatLng(cords[0], cords[1]);
		break;
	}
	
	var marker = this.createMarker(point, content);
	
	this.map.addOverlay(marker);
	
	if(show_content) {
		marker.openInfoWindowHtml(content);
	}
}

googleMaps.prototype.createMarker = function(point) {
	
	var marker = new GMarker(point);
	/*
	if(content.length > 0) {
		
		GEvent.addListener(	marker,
							"click",
							function() {
								marker.openInfoWindowHtml(content);
							}
						)
	}
	*/
	return marker;
}