 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.3926703277002, -6.389794349670417), 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.394656829526745, -6.390266418457028));
	pin4.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin4.SetTitle("Car parking at Blanchardstown Centre");
	pin4.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin4);

	var pin5 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.39508866548111, -6.3932007551193175));
	pin5.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin5.SetTitle("Car parking at Blanchardstown Centre");
	pin5.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin5);

	

	var pin8 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.39554928566953, -6.389493942260735));
	pin8.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin8.SetTitle("Car parking at Blanchardstown Centre");
	pin8.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin8);

	var pin9 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.39380913879987, -6.386682987213127));
	pin9.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin9.SetTitle("Car parking at Blanchardstown Centre");
	pin9.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin9);
	
	var pin22 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.39174902001998, -6.393721103668208));
	pin22.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin22.SetTitle("Car parking at Blanchardstown Centre");
	pin22.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin22);
	
	var pin23 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.39034142811245,-6.386983394622809));
	pin23.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin23.SetTitle("Car parking at Blanchardstown Centre");
	pin23.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin23);

	var pin24 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.391339543538706,-6.389665603637695));
	pin24.SetDescription("For more info<br />Click <a href='http://www.blanchardstowncentre.ie/about/location.aspx' target='_blank'>here</a>" );
	pin24.SetTitle("Car parking at Blanchardstown Centre");
	pin24.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin24);

}

/**
  *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);

}
