//<![CDATA[
function load() 
{
	if (GBrowserIsCompatible()) 
	{
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(53.50, -7.80), 7);
		map.addControl(new GScaleControl());
		map.enableDoubleClickZoom();
		map.enableContinuousZoom();

		var icon = new GIcon();
		icon.image = "images/mapmarker.png";
		icon.shadow = "images/mapmarkershadow.png";
		icon.iconSize = new GSize(20, 34);
		icon.shadowSize = new GSize(33, 34);
		icon.iconAnchor = new GPoint(6, 35);
		icon.infoWindowAnchor = new GPoint(15, 1);

		function createMarker(point, name, url, address, tel) 
		{
			var marker = new GMarker(point, icon);
			GEvent.addListener(marker, "click", function() 
			{
				marker.openInfoWindowHtml("<b>" + name + "</b><br />" + address + "<br />Tel: " + tel + "<br /><br /><a href = '" + url + "' >More Information</a><br />");
			});

			return marker;
		}

		map.addOverlay(createMarker(new GLatLng(53.427141044667685, -6.244279146194458), 'Dublin Airport', 'dublinairport.htm', 'Arrivals Hall, Dublin Airport', '+353 (0) 1 8445150'));
		map.addOverlay(createMarker(new GLatLng(53.3674583343158, -6.255286931991577), 'Dublin City', 'dublincity.htm', '151 Lower Drumcondra Road, Dublin 9', '+353 (0) 1 8379611'));
		map.addOverlay(createMarker(new GLatLng(52.692368611091474, -8.92091989517212), 'Shannon Airport', 'shannonairport.htm','Arrivals Hall, Shannon Airport, Co. Clare','+353 (0) 61 471361'));
		map.addOverlay(createMarker(new GLatLng(53.247595, -7.200115), 'Cork City', 'corkairport.htm','Arrivals Hall, Cork Airport','+353 (0) 21 4314000'));
		map.addOverlay(createMarker(new GLatLng(54.66251377050263, -6.216716766357422), 'Belfast International Airport', 'belfastinternationalairport.htm','Arrivals Hall, Belfast Intl Airport, Crumlin, Co. Antrim','+44 (0) 2894 423332'));
		map.addOverlay(createMarker(new GLatLng(54.614830928309615, -5.870298743247986), 'Belfast City Airport', 'belfastcityairport.htm','Arrivals Hall, Belfast City Airport, Sydenham By-Pass, Belfast','+44 (0) 2890 451111'));
		map.addOverlay(createMarker(new GLatLng(54.59153577528998, -5.934194326400757), 'Belfast City', 'belfastcity.htm','96 - 102, Great Victoria Street, Belfast','+44 (0) 2890 230700'));
		map.addOverlay(createMarker(new GLatLng(53.30226171466455, -8.941068649291992), 'Galway Airport', 'galwayairport.htm','Arrivals Hall, Galway Airport','+353 (0) 91 564570'));
		map.addOverlay(createMarker(new GLatLng(53.274462099425875, -9.047901034355164), 'Galway City', 'galwaycity.htm','Eyre Square, Galway','+353 (0) 91 566376'));
		map.addOverlay(createMarker(new GLatLng(52.18154367967945, -9.536701440811157), 'Kerry Airport', 'kerryairport.htm','Arrivals Hall, Kerry Airport','+353 (0) 64 34341'));
		map.addOverlay(createMarker(new GLatLng(52.05788037608457, -9.507540464401245), 'Killarney Office', 'killarney.htm','International Hotel, Kenmare pl., Killarney, Co. Kerry','+353 (0) 64 34341'));
		map.addOverlay(createMarker(new GLatLng(53.79963698798814, -8.913731575012207), 'Knock Airport (Ireland West)', 'knockairport.htm','Arrivals Hall, Knock Airport (Ireland West)','+353 (0) 94 9367577'));

	}
}


var Status='off';
var DisStatus='off';
var Loco1Status;
var Loco2Status;
var OldDistance;

function lighton(Loco1, Loco2)
{
	document.getElementById(Loco1).style.color="orange";
	document.getElementById(Loco2).style.color="orange";
}

function lightoff(Loco1, Loco2)
{
	if(Status == 'off')
	{
		document.getElementById(Loco1).style.color="black";
		document.getElementById(Loco2).style.color="black";
	}

	if(((Loco1Status == Loco1)||(Loco2Status == Loco1))&&(Status == 'off'))
	{
		document.getElementById(Loco1).style.color="#1851B5";
	}

	if(((Loco2Status == Loco2)||(Loco1Status == Loco2))&&(Status == 'off'))
	{
		document.getElementById(Loco2).style.color="#1851B5";
	}

	Status ='off';
}

function lightactive(Loco1, Loco2, Distance)
{
	if((OldDistance != Distance)&&(DisStatus == 'on'))
	{
		document.getElementById(OldDistance).style.color="";
	}

	document.getElementById(Distance).style.color="#1851B5";

	//cycles through location name div and resets them to black
	locations=['DA', 'DC', 'SA', 'CA', 'BA', 'BH', 'BC', 'GA', 'GC', 'KA', 'KC', 'NA']
	for (var i = 0; i < locations.length; i++)
	{
		document.getElementById(locations[i]).style.color="black";
	}

	document.getElementById(Loco1).style.color="#1851B5";
	document.getElementById(Loco2).style.color="#1851B5";

	Status = 'on';
	DisStatus = 'on';
	Loco1Status = Loco1;
	Loco2Status = Loco2;
	OldDistance = Distance;

	document.getElementById('hiddenLoco1').value=Loco1;
	document.getElementById('hiddenLoco2').value=Loco2;
	document.getElementById('hiddenDistance').value=Distance;
}


function convertdistances()
{
	document.ChangeDistanceUnits.submit();
}

function loadsmallmap() 
{
	if (GBrowserIsCompatible()) 
	{
		var map;
		var directions;

		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallZoomControl());
		directions = new GDirections(map);
		directions.load("53.427141044667685, -6.244279146194458 to 52.18154367967945, -9.536701440811157");
		lightactive('DA', 'KA', 'DAKA');
	}
}

function initialize(start, end) 
{
	if (GBrowserIsCompatible()) 
	{
		var map;
		var directions;

		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallZoomControl());
		directions = new GDirections(map);
		directions.load(start + " to " + end);
	}
}

//]]>

