var gMap;
var center;
function LatLng(lat, lng) {
    this.lat = lat;
    this.lng = lng;

    LatLng.prototype.getLat = function() {
        return this.lat;
    };
    LatLng.prototype.getLng = function() {
        return this.lng;
    };
    LatLng.prototype.setLat = function(lat) {
        this.lat = lat;
    };
    LatLng.prototype.setLng = function(lng) {
        this.lng = lng;
    };
    LatLng.prototype.setMarker = function(marker) {
        this.marker = marker;
    };
    LatLng.prototype.getMarker = function() {
        return this.marker;
    };
}

function loadPortalGmap(mapCanvas, centerLat, centerLng) {
    if (GBrowserIsCompatible()) {
        gMap = new GMap2(document.getElementById(mapCanvas));
        gMap.addControl(new GLargeMapControl());
        gMap.addControl(new GOverviewMapControl());
        gMap.enableContinuousZoom();
        gMap.enableDoubleClickZoom();
        //gMap.enableScrollWheelZoom();
		gMap.disableScrollWheelZoom();
        center = new GLatLng(centerLat, centerLng);
        gMap.setCenter(center, 14);

    }
}

function loadMarkerGmap(mapCanvas, centerLat, centerLng) {
    if (GBrowserIsCompatible()) {
        gMap = new GMap2(document.getElementById(mapCanvas));
        gMap.addControl(new GLargeMapControl());
        gMap.addControl(new GOverviewMapControl());
        gMap.enableContinuousZoom();
        gMap.enableDoubleClickZoom();
        //gMap.enableScrollWheelZoom();
		gMap.disableScrollWheelZoom();
        center = new GLatLng(centerLat, centerLng);
        gMap.setCenter(center, 14);

    }
}
function loadPortalMarkerGmap(mapCanvas, centerLat, centerLng, bMapControl, bOverview, bl) {
    if (GBrowserIsCompatible()) {
        gMap = new GMap2(document.getElementById(mapCanvas));
        if (bMapControl == 'true')
            gMap.addControl(new GLargeMapControl());
        if (bOverview == 'true')
            gMap.addControl(new GOverviewMapControl());
        gMap.enableContinuousZoom();
        gMap.enableDoubleClickZoom();
        //gMap.enableScrollWheelZoom();
		gMap.disableScrollWheelZoom();
        center = new GLatLng(centerLat, centerLng);
		
		if(typeof(bl) == "undefined")
        gMap.setCenter(center, 14);
		else
		gMap.setCenter(center, bl);
    }
}

function initPortalMarker(centerLat, centerLng, htmlInfo) {
    var location = new GLatLng(centerLat, centerLng);
    var portalMarker = new GMarker(location, {draggable: false});
    gMap.addOverlay(portalMarker);
    portalMarker.bindInfoWindow(htmlInfo);
}

function addDragMarker(htmlInit, htmlDrag) {
    var latLng = new LatLng(null, null);

    var curCenter = gMap.getCenter();
    var marker = new GMarker(curCenter, {draggable: true});
    GEvent.addListener(marker, "dragstart", function() {
        marker.closeInfoWindow();
    });
    GEvent.addListener(marker, "dragend", function() {
        marker.openInfoWindow(htmlDrag);
        var gLatLng = marker.getLatLng();
        latLng.setLat(gLatLng.lat());
        latLng.setLng(gLatLng.lng());
    });
    gMap.addOverlay(marker);
    latLng.setMarker(marker);
    marker.openInfoWindowHtml(htmlInit);
    return  latLng;
}
