
//var googleMap = new gMap();
//googleMap.initialize();


function gMap(){

	this.mapMarkers = new Array();
	
	this.map;
	
	this.baseIcon;
 	
 	var bounds = new GBounds();
 	
 		 	
	this.initialize = function() {
	 	
	 	if (GBrowserIsCompatible()) {
	 		
	 		this.map = new GMap2(document.getElementById("map_canvas"));
        	//this.map.setMapType(G_SATELLITE_MAP);
        	this.map.setCenter(new GLatLng(55.661268, 12.568359), 13);

			
			//ENABLE SCROLL ZOOM
			/*
			// Get the default GMapUIOptions.
  			var uiOptions = this.map.getDefaultUI();
  			// Disable scroll wheel zoom.
  			uiOptions.zoom.scrollwheel = true;
  			// Now set the map's UI with the tweaked options.
  			this.map.setUI(uiOptions);*/

        	
        	var controlPosition = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5,10));
        
        	this.map.addControl(new GSmallMapControl(), controlPosition);
   
        	
	        // Create a base icon for all of our markers that specifies the shadow, icon dimensions, etc.
	        this.baseIcon = new GIcon();
	        this.baseIcon.iconSize = new GSize(20, 22);
	       	this.baseIcon.iconAnchor = new GPoint(5, 13);
	        this.baseIcon.infoWindowAnchor = new GPoint(9, 2);
       	}
    }
    
    
    this.createMarker = function(lat, long, index, html, setCenter) {
    	
    	if(setCenter == 1){
    	
    		this.map.setCenter(new GLatLng(lat, long), 16);
    	}
    	
    	// Create a lettered icon for this point using our icon class
        var letter = String.fromCharCode("A".charCodeAt(0) + index);
        var letteredIcon = new GIcon(this.baseIcon);
       	letteredIcon.image = "/images/map/map-icon-custom-typeA.png";
			
		var point = new GLatLng(lat, long);	
        // Set up our GMarkerOptions object
        markerOptions = { icon:letteredIcon };
        var marker = new GMarker(point, markerOptions);
			
		if(html.length > 0){	
	      	
	      	GEvent.addListener(marker, "click", function() {
	     		marker.openInfoWindowHtml(unescape(html));
	         });
	     }
		
		this.mapMarkers.push(marker);
		
		this.map.addOverlay(marker);
     }
     
     
     
     this.openInfoWindow = function(index){
		  	
  		if (GBrowserIsCompatible()) {
  		
    		GEvent.trigger(this.mapMarkers[index], "click");
    	}
    }
    
    
    this.clearMap = function(){
    	
    	if(this.mapMarkers.length > 0){
    	
	    	this.map.removeOverlay(this.mapMarkers[0]);
	    	
	    	this.mapMarkers = null;
	    	this.mapMarkers = new Array();
    	}
    }
    
    
}





