 var map = null;

 /**
  *This initializes the map component
  */
function Init()
{
	GetMap();
	CreateLayers();
}

 /**
  *This method creates a map and loads the default pins
  */
 function GetMap()
 {
    map = new VEMap('myMap');

		MapControl.Features.ScaleBarKilometers = true;
    map.LoadMap(new VELatLong(53.3495, -6.2598), 14 ,'r' ,false);

		
		//map.ClearInfoBoxStyles();

 }

 /**
  *This method creates 3 layers.  Parking,
  *Info and Access.
  */
  function CreateLayers()
  {
	

	var infoTitle = "Info";
	CreateLayer(infoTitle);
	AddInfo(infoTitle);
	
	var parkingTitle = "Parking";
	CreateLayer(parkingTitle);
	AddParking(parkingTitle);

	var accessTitle = "Access";
	CreateLayer(accessTitle);
	AddAccess(accessTitle);



 }

  /**
  *This method creates a layer.
  *@param {String} title Title of the layer
  */
  function CreateLayer(title)
  {

	var layer = new VEShapeLayer();
	layer.SetTitle(title);
	map.AddShapeLayer(layer);
	return layer;

  }

 /**
  *This method shows the layer with
  *the given title
  *@param {String} title Title of the layer
  *@param {Boolean} state Optional flag to
  * 	show or hide layer.
  *		True will show layer, False will hide.
	  */
 function ToggleLayer(title,state)
 {

	var layer = GetLayer(title);

	if(layer != null)
	{
		var hideLayer = layer.IsVisible();
		if(state != null && state != 'undefined')
		{
			hideLayer = !state;
		}

		if(hideLayer)
		{
			layer.Hide();
		}
		else
		{
			layer.Show();
		}


	}

 }

 /**
  *This method gets a layer with
  *the given title
  *@param {String} title Title of the layer
  *@return VEShapeLayer
  */
 function GetLayer(title)
 {
	var layerCount = map.GetShapeLayerCount();
	for(var i = 0; i < layerCount; i++)
	{
		var layer = map.GetShapeLayerByIndex(i);

		if(layer != null && layer.GetTitle() == title)
		{
			return layer;
		}
	}
	return null;
 }



/**
  *This method adds
  *an array of pins.
  *@param title Title of the layer
  */
 function AddParking(title)
{
	var layer = GetLayer(title);


	var pin4 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.340,-6.25691));
	pin4.SetDescription("Located in Schoolhouse Lane<br />Click<a href='http://www.q-park.ie/web/qparkie.nsf/pages/AMSM_6ZBKU6?opendocument' target='_blank'> More information....</a><br /><br /><img src='http://www.dto.ie/grid.jpg'>" );
	pin4.SetTitle("Dawson Street Car Park");
	pin4.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin4);

	var pin5 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.350,-6.26481));
	pin5.SetDescription("For more info<br />Click <a href='http://www.q-park.ie/web/qparkie.nsf/pages/AMSM_6ZCLL4?opendocument' target='_blank'>here</a><br /><br /><img src='http://www.dto.ie/grid2.jpg'>" );
	pin5.SetTitle("Car parking at the ILAC Centre");
	pin5.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin5);

	

	var pin8 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.35225,-6.25864));
	pin8.SetDescription("Clerys Car Park serving Central Dublin Shopping<br />Located on corner of Marlborough and Sean McDermott<br /><br />For more info<br /><a href='http://www.q-park.ie/web/qparkie.nsf/pages/WGOR_67PHPC?opendocument ' target='_blank'> More information....</a><br /><br /><img src='http://www.dto.ie/grid2.jpg'>" );
	pin8.SetTitle("Clerys Car Park");
	pin8.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin8);

	var pin9 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34523,-6.27816));
	pin9.SetDescription("<br>Located off Ushers Quay<br>serves Four Courts<br><a href='http://www.q-park.ie/web/qparkie.nsf/pages/WGOR_67PHPE?opendocument' target='_blank'> More information....</a><br /><br /><img src='http://www.dto.ie/grid2.jpg'>" );
	pin9.SetTitle("Car parking at Ushers Quay");
	pin9.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin9);
	
	var pin22 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34195,-6.25581));
	pin22.SetDescription("<br>Located on Frederick Lane South<br>Setanta Centre<br><a href='http://www.q-park.ie/web/qparkie.nsf/pages/WGOR_67PHPD?opendocument' target='_blank'> More information....</a> <br /><br /><img src='http://www.dto.ie/grid3.jpg'>" );
	pin22.SetTitle("Car parking at Setanta Centre");
	pin22.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin22);
	
	var pin23 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.33940,-6.26381));
	pin23.SetDescription("Located on Glovers Alley<br>off Stephens Green<br><a href='http://www.q-park.ie/web/qparkie.nsf/pages/WGOR_67PHPF?opendocument' target='_blank'> More information....</a><br /><br /><img src='http://www.dto.ie/grid3.jpg'>" );
	pin23.SetTitle("Car parking near Saint Stephen's Green");
	pin23.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin23);

	var pin24 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34891,-6.24632));
	pin24.SetDescription("<br>Located on Commons Street<br>off Customs House Quay<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'> More information....</a>" );
	pin24.SetTitle("Car parking at IFSC");
	pin24.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin24);
	
	var pin25 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34533,	-6.26053));
	pin25.SetDescription("<br>Located on Fleet Street<br>off Westmoreland Street<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'> More information....</a>" );
	pin25.SetTitle("Car parking near Temple Bar");
	pin25.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin25);
	
	var pin26 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34961,-6.25557));
	pin26.SetDescription("<br>Located in Irish Life Mall<br>off Abbey Street Lower<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'>more information..</a>" );
	pin26.SetTitle("Car parking at Irish Life Centre");
	pin26.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin26);
	
	var pin27 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.35057,-6.26809));
	pin27.SetDescription("<br>Located in Loftus Lane<br>off Parnell Street<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'>more information..</a>" );
	pin27.SetTitle("Car parking around Capel St and Parnell Street");
	pin27.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin27);
	
	var pin28 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34876,-6.26234));
	pin28.SetDescription("<br>Located in Princes Street<br>off O'Connell Street<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'>more information..</a>" );
	pin28.SetTitle("Car parking near O'Connell Street");
	pin28.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin28);
	
	var pin29 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34267,	-6.2703));
	pin29.SetDescription("<br>Located in Werburgh Street<br>off Christchurch Place<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'>more information..</a>" );
	pin29.SetTitle("Car parking near Christchurch");
	pin29.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin29);
	
	var pin30 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34165,-6.26419));
	pin30.SetDescription("<br>Located in Drury Street<br>off Stephen Street Lower<br><a href='http://www.parkrite.ie/information.htm#city' target='_blank'>more information..</a>" );
	pin30.SetTitle("Car parking in Drury Street");
	pin30.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin30);
	
	var pin31 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34791,-6.26588));
	pin31.SetDescription("<br>Located in Jervis Centre<br>off Jervis Street<br><a href='http://www.jervis.ie/about.htm'  target='_blank'>more information..</a>" );
	pin31.SetTitle("Car parking in Jervis Centre");
	pin31.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin31);
	
	var pin32 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34721,-6.26661));
	pin32.SetDescription("<br>Located across from Jervis Centre<br>off Ormond Quay<br><a href='http://www.aaroadwatch.ie/parking/carparks_details.asp?id=119&aid=10' target='_blank' >more information</a>" );
	pin32.SetTitle("Car parking near Jervis Centre");
	pin32.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin32);
	
	var pin33 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.35869,	-6.26639));
	pin33.SetDescription("<br>Located in Eccles Street<br>between Mater & Mater Private hospitals<br><a href='http://www.mater.ie/patient/transport.htm' target='_blank'>more information..</a>" );
	pin33.SetTitle("Car parking near Mater Hospital");
	pin33.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin33);
	
	var pin34 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34344,-6.26255));
	pin34.SetDescription("Trinity Street<br>Opposite Central Bank, just off Dame Street<br><a href='http://www.aaroadwatch.ie/parking/carparks_details.asp?id=34&aid=10' target='_blank'>more information</a>" );
	pin34.SetTitle("Car parking near Grafton Street");
	pin34.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin34);
	
	var pin35 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34276,-6.26092));
	pin35.SetDescription("<br>Located in Clarendon Street" );
	pin35.SetTitle("Car parking near Grafton Street");
	pin35.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin35);
	
	var pin36 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.35194,-6.24568));
	pin36.SetDescription("<br>Located in Sheriff Street<br>off Amiens Street and Commons Street<br><a href='http://www.aaroadwatch.ie/parking/carparks_details.asp?id=99&aid=10' target='_blank' >more information</a>" );
	pin36.SetTitle("Car parking near Connolly Station");
	pin36.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin36);
	
	var pin37 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.33991,	-6.26345));
	pin37.SetDescription("<br>Located on Mercer Street Lower<br>off Stephens Street<br><a href='http://www.q-park.ie/web/qparkie.nsf/pages/WGOR_67PHPF?opendocument' target='_blank'> More information....</a><br /><br /><img sr		c='http://www.dto.ie/grid3.jpg'>" );
	pin37.SetTitle("Car parking near St Stephen Green Centre");
	pin37.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin37);
	
	var pin38 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.34373,-6.28017));
	pin38.SetDescription("<br>Located in Oliver Bond Street<br>Just off Thomas Street<br><a href='http://www.aaroadwatch.ie/parking/carparks_details.asp?id=37&aid=10' target='_blank'>more information</a>" );
	pin38.SetTitle("Car parking near Thomas Street");
	pin38.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin38);
}

/**
  *This method adds
  *an array of pins.
  *@param title Title of the layer
  */
 function AddInfo(title)
{

var layer = GetLayer(title);
	var pin1 = new VEShape(VEShapeType.Pushpin,  new VELatLong(53.39395628632573,-6.392068862915055));
	pin1.SetTitle("Buses serving The Blanchardstown Centre");
	pin1.SetCustomIcon("<img src=' http://freeflow.ie/bus.png' />");
	pin1.SetDescription("<br />Buses  <a href='http://www.dublinbus.ie/your_journey/viewer.asp?placeName=Blanchardstown' target='_blank'>More information</a> <br />Check Dublin Bus Website<br />" );
	layer.AddShape(pin1);
	
	var pindual = new VEShape(VEShapeType.Pushpin,  new VELatLong(53.28546674001226,-6.3731056451797325));
	
	pindual.SetTitle("Buses serving The Square");
	pindual.SetCustomIcon("<img src=' http://freeflow.ie/dualway.png' />");
	pindual.SetDescription("<br />Buses  <a href='http://www.dualway.com/311groute.htm'>More information</a> <br />Check Dualway Website<br />" );
	layer.AddShape(pindual);
	
	var pin10 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.29037317133547,-6.3779711723327725));

	pin10.SetDescription("For more info<br />Click <a href='http://www.amnch.ie/' target='_blank'>here</a>" );
	pin10.SetTitle("Adelaide & Meath Hospital");
	pin10.SetCustomIcon("<img src='images/hosp.png' />");

	layer.AddShape(pin10);

	var pin2 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28581950877473,-6.367135047912589));
	pin2.SetDescription("The Tallaght Plaza Hotel.<br />Click <a href='http://www.tallaghtplazahotel.com/' target='_blank'>here</a>" );
	pin2.SetTitle("The Plaza Hotel Tallaght");
	pin2.SetCustomIcon("<img src='images/Plaza.png' />");

	layer.AddShape(pin2);

	var pin3 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.39342847218781,-6.390695571899431));
	pin3.SetDescription("The Blanchardstown Centre<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin3.SetTitle("Shopping at The Blanchardstown Centre");
	pin3.SetCustomIcon("<img src='blanch.png' />");

	layer.AddShape(pin3);


	var pin6 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.2941680537992,-6.133726537227637));
	pin6.SetDescription("For what is on<br />Click <a href='http://www.paviliontheatre.ie/' target='_blank'>here</a>" );
	pin6.SetTitle("Pavilion Theatre");
	pin6.SetCustomIcon("<img src='pt.png' />");

	layer.AddShape(pin6);
	
	var pin7 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28805150543276,-6.372263431549075));
	pin7.SetDescription("For more info<br />Click <a href='http://www.luas.ie/red-line.php' target='_blank'>here</a>" );
	pin7.SetTitle("LUAS Tallaght Stop");
	pin7.SetCustomIcon("<img src='LUAS.png' />");

	layer.AddShape(pin7);
	
	var pin7x = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28956509199285,-6.3789153099059925));
	pin7x.SetDescription("For more info<br />Click <a href='http://www.luas.ie/red-line.php' target='_blank'>here</a>" );
	pin7x.SetTitle("LUAS Hospital Stop");
	pin7x.SetCustomIcon("<img src='LUAS.png' />");

	layer.AddShape(pin7x);
}
/**
*This method adds
*an array of pins.
*@param title Title of the layer
*/
function AddAccess(title)
{
	var layer = GetLayer(title);
	var line = new VEShape(VEShapeType.Polyline, [new VELatLong(53.39350844444763, -6.397862434387199),
new VELatLong(53.393162963207615,-6.397014856338503),
new VELatLong(53.393111780563174,-6.396628618240372),
new VELatLong(53.39307339353946, -6.396135091781609),
new VELatLong(53.39302860863471,-6.394021511077889),
new VELatLong(53.39368118401602,-6.392605304718025),
new VELatLong(53.39416101247195, -6.393077373504636)


]);

	var lineColor = new VEColor(191,0,0,0.6);
	line.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line.SetLineWidth(lineWidth);

	line.HideIcon();

	layer.AddShape(line);
	
	var line1 = new VEShape(VEShapeType.Polyline, [new VELatLong(53.39617783225864,-6.390228867530825),
new VELatLong(53.396297782842936, -6.390666067600235),

new VELatLong(53.39629938218178,-6.3909262418746815),
new VELatLong(53.39620342174498,-6.391108632087719),
new VELatLong(53.39604668589957,-6.391183733940123),
new VELatLong(53.39586276044687,-6.39109522104264),
new VELatLong(53.39556367997009,-6.390682160854352),
new VELatLong(53.395138246365825,-6.390025019645701),
new VELatLong(53.39425377868275,-6.388557851314555),

new VELatLong(53.39412582523566,-6.388812661170961),
new VELatLong(53.39397707886989,-6.38866245746612)

]);

	var lineColor = new VEColor(191,0,0,0.6);
	line1.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line1.SetLineWidth(lineWidth);

	line1.HideIcon();

	layer.AddShape(line1);
	
	var line2 = new VEShape(VEShapeType.Polyline, [new VELatLong(53.39133314543744,-6.382155418396005),
new VELatLong(53.39185138852481,-6.382477283477774),
new VELatLong(53.39236322735591,-6.383196115493782),
new VELatLong(53.392574359080626,-6.383861303329476),
new VELatLong(53.39283027491862,-6.385406255722061),

new VELatLong(53.391704233721704,-6.387004852294929),
new VELatLong(53.39117959071831,-6.386586427688602)
]);

	var lineColor = new VEColor(191,0,0,0.6);
	line2.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line2.SetLineWidth(lineWidth);

	line2.HideIcon();

	layer.AddShape(line2);

var line3 = new VEShape(VEShapeType.Polyline, [new VELatLong(53.38902336803656,-6.388088464736947),
new VELatLong(53.38996392963993,-6.389118432998649),
new VELatLong(53.390251852506665,-6.389515399932854),
new VELatLong(53.39172342785531,-6.391832828521733),
new VELatLong(53.39205612479585,-6.390985250473036)

]);

	var lineColor = new VEColor(191,0,0,0.6);
	line3.SetLineColor(lineColor);

	//Set the line width
	var lineWidth = 6;
	line3.SetLineWidth(lineWidth);

	line3.HideIcon();

	layer.AddShape(line3);

}
