// Javascript common to all route pages displaying OS map

//variables for map and layer for route
var osMap;
var vectorLayer;// = new OpenLayers.Layer.Vector("Vector Layer");

//Style of line drawn on map
var style_route =
{
     strokeColor: "#000CFF",
     strokeOpacity: 0.6,
     strokeWidth: 6,
     pointRadius: 6,
     pointerEvents: "visiblePainted"
};

//function passed to supportService.getTileCount in pages
function tileCountResults(tilesUsed, maxTiles)
{
	if(parseFloat(tilesUsed) >= parseFloat(maxTiles))
	{
		document.getElementById('tilecount').innerHTML = maxTiles;
		document.getElementById('map').style.display='none';
		document.getElementById('nomap').style.display='block';
	}
	else
	{
		document.getElementById('map').style.display='block';
		document.getElementById('nomap').style.display='none';
	}
}

//centre on a point
function centreToMark(Easting, Northing)
{ 
	pos = new OpenSpace.MapPoint(Easting, Northing);
	osMap.setCenter(pos, 7);
}

//Add a marker corresponding to a numbered instruction in text
function AddNumberedMarker(Easting, Northing,Num)
{
	pos = new OpenSpace.MapPoint(Easting, Northing);
	var markicon = new OpenSpace.Icon('images/marker_blue_' + Num + '.png',new OpenLayers.Size(33, 45),new OpenLayers.Pixel(-17, -45));
	var marker = osMap.createMarker(pos,markicon);
}
	
//Add a photo marker with popup
function AddPhotoMarker(Easting, Northing, thumbURL, photoURL, width, height,offsetX,offsetY)
{ 
	var pos = new OpenSpace.MapPoint(Easting, Northing); 
	var content = '<a href=\"javascript:void(0)\" onClick=\"MM_openBrWindow(\'' + photoURL + '\',\'photoWin\',\'width=' + width +',height=' + height + '\')\"><img src=\"' + thumbURL + '\" width=\"100\" height=\"75\" border=\"0\"/><p class=\"minilink\">Click to view the full size photograph</p></a>'; 
	var popUpSize = new OpenLayers.Size(175,200)
	var iconsize = new OpenLayers.Size(29, 20);
	var offset = new OpenLayers.Pixel(offsetX, offsetY);
	var infoWindowAnchor = new OpenLayers.Pixel(15, 10);
	var icon = new OpenSpace.Icon('images/camera.png',iconsize,offset, null, infoWindowAnchor);
	//add the marker to the map 
	var marker = osMap.createMarker(pos, icon, content, popUpSize ); 
}

function AddPhotoMarkerPortrait(Easting, Northing, thumbURL, photoURL, width, height,offsetX,offsetY)
{ 
	var pos = new OpenSpace.MapPoint(Easting, Northing); 
	var content = '<a href=\"javascript:void(0)\" onClick=\"MM_openBrWindow(\'' + photoURL + '\',\'photoWin\',\'width=' + width +',height=' + height + '\')\"><img src=\"' + thumbURL + '\" width=\"75\" height=\"100\" border=\"0\"/><p class=\"minilink\">Click to view the full size photograph</p></a>'; 
	var popUpSize = new OpenLayers.Size(160,250)
	var iconsize = new OpenLayers.Size(29, 20);
	var offset = new OpenLayers.Pixel(offsetX, offsetY);
	var infoWindowAnchor = new OpenLayers.Pixel(15, 10);
	var icon = new OpenSpace.Icon('images/camera.png',iconsize,offset, null, infoWindowAnchor);
	//add the marker to the map 
	var marker = osMap.createMarker(pos, icon, content, popUpSize ); 
}

function MM_openBrWindow(theURL,winName,features) 
{
  window.open(theURL,winName,features);
}

