<!--
// GLOBAL VARIABLES
var activeCenter = null;
var map;
var allowedBounds;
var markerLst = new Array();
var icons = new Array();
markerTypes = {'interest':{'markers':[],'order':0} , 'relax':{'markers':[],'order':1} , 'install':{'markers':[],'order':2} , 'access':{'markers':[],'order':3} };

// FUNCTIONS TO HANDLE CUSTOM MAP FEATURES
function toggleMarkerGroup(type) 
{
      for (var i = 0; i < markerTypes[type]['markers'].length; i++) {
        var marker = markerTypes[type]['markers'][i];
        if (marker.isHidden()) {
          marker.show();
        } else {
          marker.hide();
        }
      } 
}

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);
}
// 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/interest.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['interest']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/interest_monument.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['interest_monument']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/interest_museum.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['interest_museum']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/interest_church.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['interest_church']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/relax_plant.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['relax_plant']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/relax_cafe.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['relax_cafe']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/relax_theatre.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['relax_theatre']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/relax_zoo.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['relax_zoo']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/relax_lake.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['relax_lake']=anIcon;

	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/install.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['install']=anIcon;
	
	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/install_wc.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['install_wc']=anIcon;

	anIcon = new GIcon();
	anIcon.image = "/Portals/0/Skins/Attiko/layout/access.png";
	anIcon.iconSize = new GSize(25, 26);
	anIcon.iconAnchor = new GPoint(4, 25);
	anIcon.infoWindowAnchor = new GPoint(19, 0);
	icons['access']=anIcon;
}


// Call this function when the page has been loaded

function initialize( mapCenter, mapZoom, constrainSW, constrainNE ) 
{
			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 15;}
		        mt[i].getMaximumResolution = function() {return 19;}
		      }
      		map.addControl(new GLargeMapControl());
      		
      
      		map.setCenter(mapCenter, mapZoom);
			map.setMapType(G_SATELLITE_MAP);
			allowedBounds = new GLatLngBounds(constrainSW, constrainNE); 

      		//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
			var firstbytab = checkTabLinks();
			if ( firstbytab != '' )
				{ 
					hiliteLink( firstbytab ); 
				}
			else
				{
					if ( first != '' )
						{
							hiliteLink( first ); // show the markers for the first category with markers
						}
				}
			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 checkTabLinks()
{
	var First = '';
	if (sequencenum >= 0)
		{
			for (i in markerTypes)
			{
				if (markerTypes[i]['markers'].length > 0)
					{
						if (sequencenum==markerTypes[i]['order'])
							{
								First = i;
							}
					}
			}
		}
	return (First);
}

function initializeLink ( aKey, aTabnumber )
{
jQuery("#id_"+aKey).removeClass('disabled').addClass('default').children().unbind('click').click(
				function() {
					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 getActiveLink()
{
	for (i in markerTypes)
	{
		if ( jQuery("#id_"+i).hasClass('selected') )
			return i;
	}
}

// If the map position is out of range, move it back
      function checkBounds() {
        // Perform the check and return if OK
        if (allowedBounds.contains(map.getCenter())) {
          return;
        }
        // It`s not OK, so find the nearest allowed point and move there
        var C = map.getCenter();
        var X = C.lng();
        var Y = C.lat();

        var AmaxX = allowedBounds.getNorthEast().lng();
        var AmaxY = allowedBounds.getNorthEast().lat();
        var AminX = allowedBounds.getSouthWest().lng();
        var AminY = allowedBounds.getSouthWest().lat();

        if (X < AminX) {X = AminX;}
        if (X > AmaxX) {X = AmaxX;}
        if (Y < AminY) {Y = AminY;}
        if (Y > AmaxY) {Y = AmaxY;}
       // alert ("Restricting "+Y+" "+X);
        map.setCenter(new GLatLng(Y,X));
      }


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);
			  tb_init('a.thickbox');
			 }
         });
	
	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 );
}

//-->
