 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.286550692935215,-6.240706443786609), 15 ,'r' ,false);

		map.ShowMiniMap(418,1);
		//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.28569122956172,-6.240384578704839));
	pin4.SetDescription("For more info<br />Click <a href='http://www.dundrum.ie/directions.asp' target='_blank'>here</a>" );
	pin4.SetTitle("Car parking at Dundrum Centre");
	pin4.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin4);

	var pin5 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28665331427222,-6.239569187164306));
	pin5.SetDescription("For more info<br />Click <a href='http://www.dundrum.ie/directions.asp' target='_blank'>here</a>" );
	pin5.SetTitle("Car parking at Dundrum Centre");
	pin5.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin5);

	

	var pin8 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28871851628792,-6.24452590942383));
	pin8.SetDescription("For more info<br />Click <a href='http://www.dundrum.ie/directions.asp' target='_blank'>here</a>" );
	pin8.SetTitle("Car parking at Dundrum Centre");
	pin8.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin8);

	var pin9 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28868003517548,-6.243367195129408));
	pin9.SetDescription("For more info<br />Click <a href='http://www.dundrum.ie/directions.asp' target='_blank'>here</a>" );
	pin9.SetTitle("Car parking at Dundrum Centre");
	pin9.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin9);
	
	var pin22 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.2872690371185,-6.241414546966539));
	pin22.SetDescription("For more info<br />Click <a href='http://www.dundrum.ie/directions.asp' target='_blank'>here</a>" );
	pin22.SetTitle("Car parking at Dundrum Centre");
	pin22.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin22);
	
	
}

/**
  *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.28805150543276,-6.241554021835338));
	pin1.SetTitle("Buses serving The Dundrum 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=Dundrum%20Shopping%20Centre' 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.292470258324094,-6.245502233505248));
	pin2.SetDescription("Dundrum LUAS Stop. For more information<br />Click <a href='http://www.luas.ie/green-line.php' target='_blank'>here</a>" );
	pin2.SetTitle("LUAS Green Line Dundrum");
	pin2.SetCustomIcon("<img src='LUAS.png' />");

	layer.AddShape(pin2);

	var pin3 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.286473726770694,-6.241714954376222));
	pin3.SetDescription("The Dundrum Centre<br />Click <a href='http://www.dundrum.ie/index.asp' target='_blank'>here</a>" );
	pin3.SetTitle("Shopping at The Dundrum Centre");
	pin3.SetCustomIcon("<img src='dundrum.png' />");

	layer.AddShape(pin3);


	var pin6 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.28578743900759,-6.236388087272649));
	pin6.SetDescription("For more information<br />Click <a href='http://www.luas.ie/green-line.php' target='_blank'>here</a>" );
	pin6.SetTitle("Balally LUAS Stop");
	pin6.SetCustomIcon("<img src='LUAS.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.29581,-6.24868),
new VELatLong(53.29537,-6.24834),
new VELatLong(53.29478,-6.24789),
new VELatLong(53.29428,-6.24742),
new VELatLong(53.29406,-6.24717),
new VELatLong(53.29321,-6.24616),
new VELatLong(53.29226,-6.24495),
new VELatLong(53.29175,-6.2443),
new VELatLong(53.29115,-6.24348),
new VELatLong(53.29061,-6.24275),
new VELatLong(53.28951,-6.24132),
new VELatLong(53.28897,-6.24058),
new VELatLong(53.28836,-6.23979),
new VELatLong(53.28805,-6.23937),
new VELatLong(53.28705,-6.23806),
new VELatLong(53.28632,-6.23711),
new VELatLong(53.28596,-6.23655),
new VELatLong(53.28561,-6.23593),
new VELatLong(53.28530,-6.23529),
new VELatLong(53.28505,-6.23471),
new VELatLong(53.28482,-6.2341),
new VELatLong(53.28446,-6.233),
new VELatLong(53.28414,-6.23176),
new VELatLong(53.28398,-6.23107),
new VELatLong(53.28367,-6.22959),
new VELatLong(53.28337,-6.22771),
new VELatLong(53.28316,-6.22589),
new VELatLong(53.28306,-6.22465),
new VELatLong(53.28296,-6.22327),
new VELatLong(53.28287,-6.22236),
new VELatLong(53.28275,-6.2215),
new VELatLong(53.28268,-6.22107),
new VELatLong(53.28248,-6.22001),
new VELatLong(53.28230,-6.21923),
new VELatLong(53.28219,-6.2188)

]);

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

	//Set the line width
	var lineWidth = 4;
	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);

}
