﻿

var map;
var baseIcon;
	
baseIcon = new GIcon();
baseIcon.shadow = "/PlugIns/GoogleMapsEditor/icons/shadow_project.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(72, 49);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

var visibleMPs;
function displayCategoryPoints(cId, isActive)
{

	visibleMPs = new Array();

	$('#mapLinks a').each(function(){
	
		if(this.className == 'active')
			visibleMPs.push($(this).attr('id').replace('cLink',''));
	});
	
	//alert(isActive);
	map.clearOverlays();
	
	for(i = 0;i < mapCoordinates.length;i++)
	{
		if(($.inArray(mapCoordinates[i].CategoryID, visibleMPs) > -1) || mapCoordinates[i].CategoryID == 1 || cId == 0)
		{
			var currentMarker = null;
			if(mapCoordinates[i].IconURL)
			{
				var markerOptions;
				var letteredIcon = new GIcon(baseIcon);
				
				var point = new GLatLng(mapCoordinates[i].Y, mapCoordinates[i].X);
						
				letteredIcon.image = mapCoordinates[i].IconURL;
				letteredIcon.iconSize = new GSize(49, 48);
				letteredIcon.iconAnchor = new GPoint(25, 48);
				markerOptions = { icon:letteredIcon };
				currentMarker = new GMarker(point, markerOptions);

			}
			else
			{
				var point = new GLatLng(mapCoordinates[i].Y, mapCoordinates[i].X);
				currentMarker = new GMarker(point);
			}
			
			//GEvent.addListener(currentMarker, "click", function() {
				//	currentMarker.openInfoWindowHtml("Marker <b>" + letter + "</b>");
				//  });
			
			if(mapCoordinates[i].InfoTitle != '' && mapCoordinates[i].InfoText != '')
			{
				addInfoWindow(currentMarker, i);

				
            }
            
            map.addOverlay(currentMarker);
            
         
		}
		
		
	}
}

function addInfoWindow(m, index)
{
	GEvent.addListener(m, "click", function() {
		var newTitle = mapCoordinates[index].InfoTitle;
		var newText = mapCoordinates[index].InfoText;
		
		m.openInfoWindowHtml("<h2>" + newTitle + "</h2><p>" + newText + "</p>", {maxWidth:300});
	});
	 return m;
}
