// JavaScript Document
/*const MPLAT = 0;
const MPLON = 1;
const MPTYPE = 2;
const MPNORM = 0;
const MPSATL = 1;
const MPHYBR = 2;
const MKCLR  = 3;
const ZOOM  = 4;
const TXT = 5;
const MSCLK = 0;
const MSOVR = 1;*/

function createMarker(point, icon, ms_behav, html_text)
{

  var marker = new GMarker(point, icon);
  	GEvent.addListener(marker, ms_behav, function() {  	
    marker.openInfoWindowHtml(html_text);    
  });
  return marker;
}

//function createMarkerResult(point, icon, ms_behav, html_text)
function createMarkerResult()
{
	
		
	var point = new GLatLng(47.374, 8.53179);
	
        var iconO = new GIcon();
        iconO.image = "../../app/map/pin_orange.png";
        iconO.shadow = "../../app/map/sm_shadow.png";
        iconO.iconSize = new GSize(12, 20);
        iconO.shadowSize = new GSize(22, 20);
        iconO.iconAnchor = new GPoint(6, 20);
        iconO.infoWindowAnchor = new GPoint(5, 1);	
        
         icon = iconO;
         
         html_text="<b>test</b>";
         
         createMarker(point,'<image src="../../app/map/pin_orange.png" width=150 height=100>'); 

  
}

function CreateGoogleMap(lat, lng, zoom, mouse_event, map_mode, marker_ar, html_text)
{
      if (GBrowserIsCompatible()) {
      	

        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(lat, lng), zoom);
	
        var iconR = new GIcon();
        iconR.image = "../../app/map/pin_red.png";
        iconR.shadow = "../../app/map/sm_shadow.png";
        iconR.iconSize = new GSize(12, 20);
        iconR.shadowSize = new GSize(22, 20);
        iconR.iconAnchor = new GPoint(6, 20);
        iconR.infoWindowAnchor = new GPoint(3, 25);  

        var iconY = new GIcon();
        iconY.image = "../../app/map/pin_yellow.png";
        iconY.shadow = "../../app/map/sm_shadow.png";
        iconY.iconSize = new GSize(12, 20);
        iconY.shadowSize = new GSize(22, 20);
        iconY.iconAnchor = new GPoint(6, 20);
        iconY.infoWindowAnchor = new GPoint(3, 25);  

        var iconG = new GIcon();
        iconG.image = "../../app/map/pin_green.png";
        iconG.shadow = "../../app/map/sm_shadow.png";
        iconG.iconSize = new GSize(12, 20);
        iconG.shadowSize = new GSize(22, 20);
        iconG.iconAnchor = new GPoint(6, 20);
        iconG.infoWindowAnchor = new GPoint(3, 25);  

        var iconB = new GIcon();
        iconB.image = "../../app/map/pin_blue.png";
        iconB.shadow = "../../app/map/sm_shadow.png";
        iconB.iconSize = new GSize(12, 20);
        iconB.shadowSize = new GSize(22, 20);
        iconB.iconAnchor = new GPoint(6, 20);
        iconB.infoWindowAnchor = new GPoint(3, 25);  
        
        var iconO = new GIcon();
        iconO.image = "../../app/map/pin_orange.png";
        iconO.shadow = "../../app/map/sm_shadow.png";
        iconO.iconSize = new GSize(12, 20);
        iconO.shadowSize = new GSize(22, 20);
        iconO.iconAnchor = new GPoint(6, 20);
        iconO.infoWindowAnchor = new GPoint(3, 25);  
        
        var iconP = new GIcon();
        iconP.image = "../../app/map/pin_purple.png";
        iconP.shadow = "../../app/map/sm_shadow.png";
        iconP.iconSize = new GSize(12, 20);
        iconP.shadowSize = new GSize(22, 20);
        iconP.iconAnchor = new GPoint(5, 1);
        iconP.infoWindowAnchor = new GPoint(3, 25);  
              
        var iconResult = new GIcon();
        iconResult.image = "../../app/map/markerResult.png";
        iconResult.shadow = "../../app/map/shadowResult.png";
        iconResult.iconSize = new GSize(20, 34);
        iconResult.shadowSize = new GSize(37, 34);
        iconResult.iconAnchor = new GPoint(10, 31);
        iconResult.infoWindowAnchor = new GPoint(8, 31);
        
       

        var tcnt = marker_ar.length;
        var lcnt = 0;
        for (lcnt = 0; lcnt<tcnt; lcnt++)
        {
            switch(marker_ar[lcnt][3]){ // 3 = COLOR
                case 1:
                    icon = iconR;
                    break;
                case 2:
                    icon = iconB;
                    break;
                case 3:
                    icon = iconG;
                    break;
                case 4:
                    icon = iconY;
                    break;
                case 5:
                    icon = iconP;
                    break;
                case 99:
                    icon = iconResult;
                    var point_selected = new GLatLng(marker_ar[lcnt][0], marker_ar[lcnt][1]); // 0 = LAT, 1 = LONG                    
                    
                    break;
                default:
                    icon = iconO;
            } // switch
			if (mouse_event == 0)
			{
				behav	= "mouseover";
			}
			else
			{
				behav	= "click";
			}
            var point = new GLatLng(marker_ar[lcnt][0], marker_ar[lcnt][1]); // 0 = LAT, 1 = LONG
            map.addOverlay(createMarker(point, icon, behav, marker_ar[lcnt][5])); // 5 = TXT
        }
        
        if(html_text != ''){
          map.openInfoWindowHtml(point_selected,html_text);
        }             
          
    }
}
