// JavaScript Document     

         var map = null;
         
         function GetMap(warea)
         {
            var scrwidth;
			var scrheight;
        	var latLong = null;
			
			// Get screen size
			scrwidth= screen.availWidth -35;
			scrheight = screen.availHeight - 250;
			//alert(warea);
			map = new VEMap('myMap');
			// Set map style to roads
			// With latitiude & long Worcesterish
			// Co-ords are Wick, zoom 10, Show roads.
 			switch(warea)
			{
				case 'kent':
           			map.LoadMap(new VELatLong(51.27, 0.52), 8 ,VEMapStyle.Road ,false);
					break;
				case 'west':
           			map.LoadMap(new VELatLong(52.27, -2.208), 8 ,VEMapStyle.Road ,false);
					break;
				case 'east':
					//alert('in east')
					 map.LoadMap(new VELatLong(52.7, -0.5), 8 ,VEMapStyle.Road ,false);
					break;
				default: alert(myarea + ' - area not recognised');
			}
			//
			//map.SetMapMode(VEMapStyle.Road);
			//map.HideMiniMap();
			
			//map.Resize('1000','600');

			map.Resize(scrwidth,scrheight);
 
			// Load collection
			//AddMyLayer(VEDataType.VECollection);
			AddMyLayer(warea);
 			//latLong = map.GetCenter();
          	//map.SetCenterAndZoom(latLong, 1);
			//map.Zoomout();
			
         }   
         function AddMyLayer(myarea)
         {
            // Collection maintained within Bing maps - must be shared, else won't load
			// This is the collection id as specified if you request an email link
			//var ctype = VEDataType.VECollection;
			//var collectionid = "C26E879CD89BDAEE!113";
			var collectionid
			var ctype = VEDataType.ImportXML;
			//var collectionid = "http://www.tollrides.org.uk/WMCollection.kml"; //- real one oct 09
			//var collectionid ;
			//var collectionid = "http://www.tollrides.org.uk/trotCollection2.kml";
			//var collectionid = "http://www.sipeda.com/trot/docs/trotCollection2.kml";
			//var collectionid = "http://www.sipeda.com/trot/test2.kml";
			//alert(collectionid);
            var layer = new VEShapeLayer();
            var layer2 = new VEShapeLayer();
			switch(myarea)
			{
				case 'kent':
					collectionid = "http://www.tollrides.org.uk/"+"KentCollection.kml";
					break;
				case 'west':
					collectionid = "http://www.tollrides.org.uk/"+"WMCollection.kml";
					break;
				case 'east':
					//alert('in east')
					collectionid = "http://www.tollrides.org.uk/"+"EMCollection.kml";
					break;
				default: alert(myarea + ' - area not recognised');
			}
			
			if (myarea=='kent'){ //add extra fc points on new layer
				collectionid2 = "http://www.tollrides.org.uk/"+"KentfcCollection.kml";
          		var veLayerSpec2 = new VEShapeSourceSpecification(ctype, collectionid2, layer2);
  				map.ImportShapeLayerData(veLayerSpec2, function()
				{
  				 var numShapes = layer2.GetShapeCount();
   				var s, n, icon;
   
   				for(var i = 0; i < numShapes; ++i)
   				{
      				s = layer2.GetShapeByIndex(i);
      
     				 n = i + 1;
      				icon = "<img src='images/green_pushpin.png'>";
      				//icon = "<img src='images/orange_pushpin.png'><span class='pinText'>" + " " + n + "</span ";
      				s.SetCustomIcon(icon);
   					}
				}, true);
			}
            // Main layer
			var veLayerSpec = new VEShapeSourceSpecification(ctype, collectionid, layer);
            map.ImportShapeLayerData(veLayerSpec, onFeedLoad,layer);
			//map.SetZoomLevel(1);

			//alert(myarea);
			//if (myarea =='west'){
			//		var collectionid = "http://www.tollrides.org.uk/"+"WMCollection.kml";	
			//}
         }
         function onFeedLoad(feed)
         {
			 //alert('Points of interest loaded');
            //alert('RSS or Collection loaded. There are '+feed.length+' items in this list.');
         }



