 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.45068529497285,-6.220016811370843), 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.4556813374372, -6.221201419830312));
	pin4.SetDescription("For more info<br />Click <a href='http://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin4.SetTitle("Car parking at The Pavilions Centre");
	pin4.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin4);

	var pin5 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.45249978245155,-6.219291687011716));
	pin5.SetDescription("For more info<br />Click <a href='http://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin5.SetTitle("Car parking at The Pavilions Centre");
	pin5.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin5);

	

	var pin8 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.45331755428268,-6.217575073242203));
	pin8.SetDescription("For more info<br />Click <a href='http://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin8.SetTitle("Car parking at The Pavilions Centre");
	pin8.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin8);

	var pin9 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.454096978402575,-6.2222313880920455));
	pin9.SetDescription("For more info<br />Click <a href='http://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin9.SetTitle("Car parking at The Pavilions Centre");
	pin9.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin9);
	
	var pin22 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.453969204937,-6.217467784881602));
	pin22.SetDescription("For more info<br />Click <a href='http://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin22.SetTitle("Car parking at The Pavilions 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://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin23.SetTitle("Car parking at The Pavilions 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://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin24.SetTitle("Car parking at The Pavilions Centre");
	pin24.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin24);
	
	var pin25 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.44696663124043,-6.222488880157487));
	pin25.SetDescription("Parking at Airside" );
	pin25.SetTitle("Car parking at The Airside Centre");
	pin25.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin25);
	
	var pin26 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.44561198555036,-6.227467060089099));
	pin26.SetDescription("Parking at Airside" );
	pin26.SetTitle("Car parking at The Airside Centre");
	pin26.SetCustomIcon("<img src='parking.png' />");

	layer.AddShape(pin26);

}

/**
  *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.45626906849954,-6.221737861633315));
	pin1.SetTitle("Buses serving Swords");
	pin1.SetCustomIcon("<img src=' http://freeflow.ie/bus.png' />");
	pin1.SetDescription("<br />Buses <a href='http://www.dublinbus.ie/your_journey/viewer.asp?placeName=Swords' target='_blank'>More information</a><br />Check Dublin Bus Website<br />" );
	layer.AddShape(pin1);
	
	var layer = GetLayer(title);
	var pin1a = new VEShape(VEShapeType.Pushpin,  new VELatLong(53.44543306685235,-6.228647232055674));
	pin1a.SetTitle("Buses serving Airside Swords");
	pin1a.SetCustomIcon("<img src=' http://freeflow.ie/bus.png' />");
	pin1a.SetDescription("<br />Buses <a href='http://www.dublinbus.ie/your_journey/viewer.asp?placeName=Swords' target='_blank'>More information</a><br />Check Dublin Bus Website<br />" );
	layer.AddShape(pin1a);
	
	
	
	var pindual = new VEShape(VEShapeType.Pushpin,  new VELatLong(53.44478128522271,-6.228604316711435));
	
	pindual.SetTitle("Swords Express");
	pindual.SetCustomIcon("<img src=' http://freeflow.ie/sex.gif' />");
	pindual.SetDescription("<br />Buses  <a href='http://www.swordsexpress.com/'>More information</a> <br />Check Website<br />" );
	layer.AddShape(pindual);
	
	var pin10 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.447401131085115,-6.2259864807129075));

	pin10.SetDescription("Atlantic Homecare, Harvey Normans, B&Q, PCWorld, Homecare, Dixons plus many more" );
	pin10.SetTitle("Airside Business & Retail Park");
	pin10.SetCustomIcon("<img src='airside.png' />");

	layer.AddShape(pin10);

	var pin2 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.45537469191461,-6.2223601341247665));
	pin2.SetDescription("Swords Express bus route through the Port Tunnel<br />Click <a href='http://www.swordsexpress.com/' target='_blank'>here</a>" );
	pin2.SetTitle("Swords Express");
	pin2.SetCustomIcon("<img src='images/sex.gif' />");

	layer.AddShape(pin2);

	var pin3 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.454684731392746,-6.220986843109142));
	pin3.SetDescription("The Pavilions Centre Swords<br />For more information click <a href='http://homepage.eircom.net/~aroundswords/swordspavilions.htm' target='_blank'>here</a>" );
	pin3.SetTitle("Shopping in Swords");
	pin3.SetCustomIcon("<img src='pav.png' />");

	layer.AddShape(pin3);


	var pin6 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.45453140530999,-6.223089694976819));
	pin6.SetDescription("For information about URBUS service<br />Click <a href='http://www.urbus.ie/_routePlanner/routePlanner.asp' target='_blank'>here</a>" );
	pin6.SetTitle("URBUS Service");
	pin6.SetCustomIcon("<img src='urb.png' />");

	layer.AddShape(pin6);
	
	var pin7 = new VEShape(VEShapeType.Pushpin,new VELatLong(53.44421895578132,-6.228411197662352));
	pin7.SetDescription("For information about URBUS service<br />Click <a href='http://www.urbus.ie/_routePlanner/routePlanner.asp' target='_blank'>here</a>" );
	pin7.SetTitle("URBUS Service");
	pin7.SetCustomIcon("<img src='urb.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.45152865794986,-6.220493316650379),
new VELatLong(53.45195033315847,-6.219055652618394),

new VELatLong(53.452014222976366,-6.218862533569346),
new VELatLong(53.45220589185342,-6.2185835838317844),
new VELatLong(53.45232089276444,-6.218647956848144),
new VELatLong(53.452410337702176,-6.218862533569346),
new VELatLong( 53.45266589362915,-6.218926906585707),
new VELatLong(53.45280644873352,-6.219162940978994),
new VELatLong(53.45285755956523,-6.219356060028076),
new VELatLong( 53.45288311495801,-6.219549179077157),
new VELatLong(53.45295978104412,-6.219956874847407)

]);

	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.453815876270866,-6.214721202850355),
new VELatLong(53.45407142374022,-6.2149357795715225),

new VELatLong(53.45425030605382,-6.215450763702406),
new VELatLong(53.45428863788013,-6.215708255767814),new VELatLong(53.454326969671854,-6.216373443603506),
new VELatLong(53.454352524180436,-6.217360496521001),
new VELatLong(53.4543141924118,-6.217854022979732),
new VELatLong(53.454211974192916,-6.218068599700933),
new VELatLong(53.45398198230087,-6.218068599700933)

]);

	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.45606464122656,-6.220600605010979),
new VELatLong(53.4553363610686,-6.2185835838317844),
new VELatLong(53.4549019423957,-6.218326091766341),
new VELatLong(53.45451862811144,-6.218068599700933),
new VELatLong(53.454467519278786,-6.217982769012453),
new VELatLong(53.454378078673656,-6.217789649963371),
new VELatLong(53.454301415147874,-6.217832565307611)

]);

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


}
