﻿// called at the bottom of index.php
//log('init.js');

if (GBrowserIsCompatible() && 1==1) {
	//some globals
	var map = null;
	var timeline_size = 1;
	var unorte = [];
	var unorteByID = [];
	var unortMarkers = [];
	var unortMarkersByID = {};
	var cluster = null;
	
	var geocoder = null;
	var categories = [];
	
	var icon_image = [
			["img/map/icon_other_map.png", "img/map/icon_other_map.png"],
			["img/map/icon_building_map.png", "img/map/icon_building_map_s.png"],
			["img/map/icon_place_map.png", "img/map/icon_place_map_s.png"],
			["img/map/icon_street_map.png", "img/map/icon_street_map_s.png"],
			["img/map/icon_area_map.png", "img/map/icon_area_map_s.png"],
			["img/map/icon_featured_map.png", "img/map/icon_featured_map.png"],
		];
	var dragmarker_image = "img/map/icon_anlegen_map.png";
	var shadow_image = "img/map/icon-anlegen-schatten-2.png";
	
	restoreMapStatus();

	// CREATING THE GOOGLE MAP AND ADDING CONTROLS etc... //
	
	// create the map
	map = new GMap2( document.getElementById( "map" ) );
	// Add the controls (zoom etc.)
	map.addControl( new GLargeMapControl(), new GControlPosition( G_ANCHOR_TOP_LEFT, new GSize( 10, 70 ) ) );
	// map.addControl( new GLargeMapControl(), new GControlPosition( G_ANCHOR_BOTTOM_LEFT, new GSize( 10, 80 ) ) );
	// Add the buttons to select the type of Map (satellite/hybrid/...)
	// map.addControl(new GMapTypeControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10, 100)));
	map.addMapType( G_NORMAL_MAP );
	map.addMapType( G_SATELLITE_MAP );
	map.addMapType( G_HYBRID_MAP );
	// Set the center and put the map on satellite
	var mitte =  new GLatLng( globalStatus.lat, globalStatus.lng );
	map.setCenter( mitte, globalStatus.zoom );
	// for (var i in status) {
	// 
	// 	alert(i);
	// };
	
	map.setZoom(globalStatus.zoom);
	map.setMapType( G_NORMAL_MAP );
	
	// Disable double click zoom. Conflict with adding a new unort
	// map.disableDoubleClickZoom();
	
	
	// Enable scrollwheel zoom
	// 
	// if(OPEN_UNORT == -1)
	map.enableScrollWheelZoom();
	
	// Disable scrollwheel zoom to allow scrolling inside Info Fields maybe better solution later
	// map.disableScrollWheelZoom();
	
	var projection = map.getCurrentMapType().getProjection();
	// Initialize a geocoder component
	geocoder = new GClientGeocoder();
	
	// ====== END GOOGLE MAP CREATON ======= //
	
	getBrowserSize();
	
	/* refreshTimelineDates(); */
	//mf initGui();
	
	
	
	
	// Global Google Map Icons

	// Icon for the dragmarker
	var icon_dragmarker = new GIcon();
	icon_dragmarker.image = dragmarker_image;
	icon_dragmarker.iconSize = new GSize(22, 28);
	icon_dragmarker.iconAnchor = new GPoint(15, 18);
	icon_dragmarker.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_dragmarker.dragCrossImage  = shadow_image;
	icon_dragmarker.dragCrossSize = new GSize(22, 28);
	icon_dragmarker.dragCrossAnchor = new GPoint(15, 18);

	// other unort
	var icon_other = new GIcon();
	icon_other.image = icon_image[0][0];
	icon_other.iconSize = new GSize(25, 30);
	icon_other.iconAnchor = new GPoint(17, 20);
	icon_other.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_other.dragCrossImage  = shadow_image;
	icon_other.dragCrossSize = new GSize(22, 28);
	icon_other.dragCrossAnchor = new GPoint(15, 18);
	var icon_other_s = new GIcon();
	icon_other_s.image = icon_image[0][1];
	icon_other_s.iconSize = new GSize(25, 30);
	icon_other_s.iconAnchor = new GPoint(17, 20);
	icon_other_s.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_other_s.dragCrossImage  = shadow_image;
	icon_other_s.dragCrossSize = new GSize(22, 28);
	icon_other_s.dragCrossAnchor = new GPoint(15, 18);

	// Building unort
	var icon_geb = new GIcon();
	icon_geb.image = icon_image[1][0];
	icon_geb.iconSize = new GSize(22, 28);
	icon_geb.iconAnchor = new GPoint(16, 18);
	icon_geb.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_geb.dragCrossImage  = shadow_image;
	icon_geb.dragCrossSize = new GSize(22, 28);
	icon_geb.dragCrossAnchor = new GPoint(15, 18);
	var icon_geb_s = new GIcon();
	icon_geb_s.image = icon_image[1][1];
	icon_geb_s.iconSize = new GSize(22, 28);
	icon_geb_s.iconAnchor = new GPoint(16, 18);
	icon_geb_s.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_geb_s.dragCrossImage  = shadow_image;
	icon_geb_s.dragCrossSize = new GSize(22, 28);
	icon_geb_s.dragCrossAnchor = new GPoint(15, 18);

	// Place unort
	var icon_ort = new GIcon();
	icon_ort.image = icon_image[2][0];
	icon_ort.iconSize = new GSize(22, 28);
	icon_ort.iconAnchor = new GPoint(16, 18);
	icon_ort.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_ort.dragCrossImage  = shadow_image;
	icon_ort.dragCrossSize = new GSize(22, 28);
	icon_ort.dragCrossAnchor = new GPoint(15, 18);
	var icon_ort_s = new GIcon();
	icon_ort_s.image = icon_image[2][1];
	icon_ort_s.iconSize = new GSize(22, 28);
	icon_ort_s.iconAnchor = new GPoint(16, 18);
	icon_ort_s.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_ort_s.dragCrossImage  = shadow_image;
	icon_ort_s.dragCrossSize = new GSize(22, 28);
	icon_ort_s.dragCrossAnchor = new GPoint(15, 18);

	// Street unort
	var icon_strasse = new GIcon();
	icon_strasse.image = icon_image[3][0];
	icon_strasse.iconSize = new GSize(22, 28);
	icon_strasse.iconAnchor = new GPoint(16, 18);
	icon_strasse.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_strasse.dragCrossImage  = shadow_image;
	icon_strasse.dragCrossSize = new GSize(22, 28);
	icon_strasse.dragCrossAnchor = new GPoint(15, 18);
	var icon_strasse_s = new GIcon();
	icon_strasse_s.image = icon_image[3][1];
	icon_strasse_s.iconSize = new GSize(22, 28);
	icon_strasse_s.iconAnchor = new GPoint(16, 18);
	icon_strasse_s.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_strasse_s.dragCrossImage  = shadow_image;
	icon_strasse_s.dragCrossSize = new GSize(22, 28);
	icon_strasse_s.dragCrossAnchor = new GPoint(15, 18);

	// Area unort
	var icon_areal = new GIcon();
	icon_areal.image = icon_image[4][0];
	icon_areal.iconSize = new GSize(22, 28);
	icon_areal.iconAnchor = new GPoint(16, 18);
	icon_areal.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_areal.dragCrossImage  = shadow_image;
	icon_areal.dragCrossSize = new GSize(22, 28);
	icon_areal.dragCrossAnchor = new GPoint(15, 18);
	var icon_areal_s = new GIcon();
	icon_areal_s.image = icon_image[4][1];
	icon_areal_s.iconSize = new GSize(22, 28);
	icon_areal_s.iconAnchor = new GPoint(16, 18);
	icon_areal_s.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_areal_s.dragCrossImage  = shadow_image;
	icon_areal_s.dragCrossSize = new GSize(22, 28);
	icon_areal_s.dragCrossAnchor = new GPoint(15, 18);

	// featured unort
	var icon_featured = new GIcon();
	icon_featured.image = icon_image[5][0];
	icon_featured.iconSize = new GSize(24, 31);
	icon_featured.iconAnchor = new GPoint(16, 28);
	icon_featured.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_featured.dragCrossImage  = shadow_image;
	icon_featured.dragCrossSize = new GSize(22, 28);
	icon_featured.dragCrossAnchor = new GPoint(15, 18);
	var icon_featured_s = new GIcon();
	icon_featured_s.image = icon_image[5][1];
	icon_featured_s.iconSize = new GSize(24, 31);
	icon_featured_s.iconAnchor = new GPoint(16, 28);
	icon_featured_s.infoWindowAnchor = new GPoint(0, 0);
	// Shadow image
	icon_featured_s.dragCrossImage  = shadow_image;
	icon_featured_s.dragCrossSize = new GSize(22, 28);
	icon_featured_s.dragCrossAnchor = new GPoint(15, 18);
	
} 
else {
	// alert("Entschuldigung, diese Seite läuft auf diesem Browser nicht, er wird nicht von Google Map unterstützt.");
}

