
function ProjectMap(mapElement, latitudeElement, longitudeElement) {
    var map = new GMap2(mapElement);
    var latElement = latitudeElement;
    var longElement = longitudeElement;
    var this_ = this;
    
    /**
     * Constructor. Note that this is called at the end of the class.
     */
    var init = function init() {
	   map.addControl(new GLargeMapControl());
   	map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(32.0, 0.0), 1.0); // gives it the "classic" map look by hiding antartica some
    }
    
    /**
     * Creates a GLatLng based on the underlying DOM data.
     */
    ProjectMap.prototype.getLatitudeLongitude = function getLatitudeLongitude() {
        var latitudeLongitude = null;
        var latitude = getLatitude();
        var longitude = getLongitude();
        
        // make sure that we have a valid location
        if (latitude != null && longitude != null) {
            if (latitude != "" && longitude != "") {
                if (latitude != 0 && longitude != 0) {
                    latitudeLongitude = new GLatLng(latitude, longitude);
                }
            }
        }
        
        return latitudeLongitude;
    }
    
    /**
     * Clears any existing overlays and creates a new marker based on the DOM data.
     */
    ProjectMap.prototype.refresh = function refresh() {
        // clear any existing overlays
        map.clearOverlays();
        
        // get the position from the dom
        var latLong = this_.getLatitudeLongitude();
        
        // as long as we find a position, add it to the map!
        if (latLong != null) {
    	      map.addOverlay(new GMarker(latLong));
    	      map.setCenter(latLong, 2.0);
        }
    }
    
    /**
     * Sets the latitude on the underlying DOM element.
     */
    var setLatitude = function setLatitude(latitude) {
    	if (latElement != null) {
    		latElement.setAttribute("value", latitude);
    	}
    }
    
    /**
     * Sets the longitude on the underlying DOM element.
     */
    var setLongitude = function setLongitude(longitude) {
    	if (longElement != null) {
    		longElement.setAttribute("value", longitude);
    	}
    }
    
    /**
     * Gets the latitude from the underlying DOM element.
     */
    var getLatitude = function getLatitude() {
        var latitude = null;
    	if (latElement != null) {
    		latitude = latElement.getAttribute("value");
    	}
    	return latitude;
    }
    
    /**
     * Gets the longitude from the underlying DOM element.
     */
    var getLongitude = function getLongitude(longitude) {
    	var longitude = null;
    	if (longElement != null) {
    		longitude = longElement.getAttribute("value");
    	}
    	return longitude;
    }
    
	init();
};