<!--
// GLOBAL VARIABLES
var map;
var activeCenter = null;
var icons = new Array();
var markerLst = new Array();
markerTypes = {'green':{'markers':[],'order':0} , 'orange':{'markers':[],'order':1} };
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.

function loadIcons()
{
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/orange.png";
	anIcon.iconSize = new GSize(15, 25);
	anIcon.iconAnchor = new GPoint(4, 20);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['orange']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/green.png";
	anIcon.iconSize = new GSize(15, 25);
	anIcon.iconAnchor = new GPoint(4, 20);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['green']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/greenBig.png";
	anIcon.iconSize = new GSize(27, 45);
	anIcon.iconAnchor = new GPoint(8, 30);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['greenBig']=anIcon;
}


// Call this function when the page has been loaded

function initialize( mapCenter, mapZoom ) 
{
			map = new google.maps.Map2(document.getElementById("map"));
			
			// MANAGE CONROL BUTTONS
			//map.removeMapType(G_HYBRID_MAP);
			//map.removeMapType(G_SATELLITE_MAP);
			var mapControl = new GMapTypeControl();
			map.addControl(mapControl);
        
		      // ====== Restricting the range of Zoom Levels =====
		      // Get the list of map types      
		      var mt = map.getMapTypes();
		      // Overwrite the getMinimumResolution() and getMaximumResolution() methods
		      for (var i=0; i<mt.length; i++) {
		        mt[i].getMinimumResolution = function() {return 0;}
		        mt[i].getMaximumResolution = function() {return 16;}
		      }
      		map.addControl(new GLargeMapControl());
      		
   
      		map.setCenter(mapCenter, mapZoom);
			//map.setMapType(G_SATELLITE_MAP);
			map.setMapType(G_HYBRID_MAP);
      		//GEvent.addListener(map, "move", function() { checkBounds(); });
	 
			loadIcons();
			load_points_of_interest();
			var first = activateLinks(); // activate buttons according to existing markers and return the first category that contains markers
			if ( first != '' )
				{
					//hiliteLink( first ); // show the markers for the first category with markers
					//over ride default functionality and display all buttons as hilited ...
					hiliteAll();
				}
			window.onunload =  google.maps.Unload;
}

function activateLinks()
{
	var First = '';
	for (i in markerTypes)
	{
		if (markerTypes[i]['markers'].length > 0)
			{
				initializeLink(i, markerTypes[i]['order']);
				if (First=='') 
					{
						First = i;
					}
			}
	}
	return (First);
}
function initializeLink ( aKey, aTabnumber )
{
jQuery("#id_"+aKey).removeClass('disabled').addClass('default').children().unbind('click').click(
				function() {
					//alert(this.innerHTML);
					hiliteLink(aKey);
					this.blur(); // hide the auto-border around the clicked button
					return false; // cancel the link to avoid scrolling due to the link pointing at #
					}
				);	
}
function hiliteLink( aKey )
{
	for (i in markerTypes)
	{
		jQuery("#id_"+i).removeClass('selected').addClass('default');
	}
	jQuery("#id_"+aKey).removeClass('default').addClass('selected');
	showMarkerGroup(aKey); // show the related markers on the map
	//changeTab( markerTypes[aKey]['order']); // show the corresponding tab
}

function hiliteAll()
{
	for (i in markerTypes)
	{
		jQuery("#id_"+i).removeClass('default').addClass('selected');
	}
	showAllMarkerGroups();
}
function showMarkerGroup(type)
{
	activeCenter = null;
	for (var i in markerTypes)
	{
		for (var mrk_i = 0; mrk_i < markerTypes[i]['markers'].length; mrk_i++) 
		{
			var marker = markerTypes[i]['markers'][mrk_i];
			
			if (i.toString()==type.toString()) 
					marker.show();
			else 
					{
						marker.hide();
						marker.closeInfoWindow();
					}
		}
	}
	map.panTo(mapCenter);
}

function showAllMarkerGroups()
{
	activeCenter = null;
	for (var i in markerTypes)
	{
		for (var mrk_i = 0; mrk_i < markerTypes[i]['markers'].length; mrk_i++) 
		{
			var marker = markerTypes[i]['markers'][mrk_i];
			marker.show();
		}
	}
	map.panTo(mapCenter);
}

/*function createMarker( lat, lng, icon, desc )
{
	var aMarker = new google.maps.Marker( new google.maps.LatLng( lat,	lng ), { icon:icons[icon] });
	GEvent.addListener(aMarker, "click", function() {
          aMarker.openInfoWindowHtml(desc);
          //tb_init('a.thickbox');
         });
	map.addOverlay(aMarker);
}*/
function createMarker( lat, lng, mrkType, icon, desc )
{
	var aMarker = new google.maps.Marker( new google.maps.LatLng( lat,	lng ), { icon:icons[icon] });
	GEvent.addListener(aMarker, "click", function() {
		  if (!aMarker.infoWindowIsOpen)
			 { 
			  aMarker.infoWindowIsOpen = true;
			  activeCenter = map.getCenter();
			  aMarker.openInfoWindowHtml(desc);
			 }
         });
	
	GEvent.addListener(aMarker, "infowindowclose", function() {
			 if (activeCenter != null)
			  {
				  map.panTo(activeCenter);
			  }
			  aMarker.infoWindowIsOpen = false;
         });
	
	
	markerTypes[mrkType]['markers'].push( aMarker );
	map.addOverlay(aMarker);
	aMarker.hide();
	//markerMgr.addMarker( aMarker, 15 );
}

//-->

