﻿// JScript File
// Summary of Functions in order of navigation menu
// First pg upon entry, setting map, zoom and right content: Line x
// Canada's 13 Summits, set each mountain's lat/long, hover bubble contents, pins: Line 937
// 13 individual summits, set locations and zoom: Line x
// Fly The Route, set links to script: Line x
// Expedition Route > Climbing Schedule: see mid-left-page.html file
// Expedition Route > Planned Route (2D & 3D), map settings and right content: Line x
// Expedition Route > Camps: Hover bubble contents for pins, graphics, links to blogs & photos: Line - 325
// Follw The Climbs Live section - Locate Team by GPS setup: Line x
// Pre-Climb - by Day section, setting map and right content: Line x
// The Climb - by Day section, setting map (start and end lat & long's) and right content: Line 571
//		- hover content for the section (pix, comments): Line 634?
// Post Climb - by Day section, setting map and right content: Line x
// Weather Information: see mid-left-page.html file
// Live section - Intro, Techno, Broadcast Sched: see mid-left-page.html file
// Education Centre section: mid-left-page.html file
// Show Map of Schools: Line x
// Register Your School: see mid-left-page.html file
// Live From Logan Supporters: see mid-left-page.html file
// Logan Tips: see mid-left-page.html file
// Misc Stuff:
// Map transparency for Route: Line 494


var map = null; 
	var PanTo = 0;
    var pinID = 1; 
    var DayPin = 0;
    var layerid = 1;
    var layerid2 = 1;
    var hiRes = 0;
    var plan  = 0;  
    var GPS = 0;
    var Route = 0;
    var Route2 = 0;
    var Route3 = 0;
    var SetMap = 0;
    var schools = 0;
    var str = document.URL;
    var linecolorRed;
    var linecolorGreen;
    var linecolorBlue;
    var DocumentCall = null;
    var imagery = null;
    var spotloaded = "NO";
    //To Read URL for parameters
   
    hiRes = str.indexOf("res=1");
    var hiRes2 = str.indexOf("res=2")
    plan = str.indexOf("plan=1");
    Route =  str.indexOf("Route=1"); 
    Route2 =  str.indexOf("Route=2");
    Route3 =   str.indexOf("Route=3");
    schools =  str.indexOf("schools=1");
    var lat;
    var longitude;
    var lat2;
    var longitude2;
    var ZoomLevel = 7;
    lat = 60.56833333;       //set initial Load of map to this lat
    longitude = -140.4033333;   //Set initial Load of map to this long
     
    
    //Function call used to zoom in on locations specified under Expedition Route.
    if (Route > 0) 
    {
        PanToLocation()
    }
    if (Route2 > 0) 
    {
       DayByDayLocation()
    }




    //End Expedidition Route Call

    
    if (str.indexOf("Ridge=2") > 0)   //Wants to pan to a selected Ridge
    {
       LoadSpecificRidge()
    }



          
    function GetMap()
      {       

      //  var map = null;
        
 
        map = new VEMap('myMap');   


        if (str.indexOf("3D=1") > 0 )
        {
			

			//map.onLoadMap = set3D;
			map.LoadMap(new VELatLong(lat, longitude), 8, 'h', false, VEMapMode.Mode3D);
			map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);				//Get the units in KM. YL
			ZoomLevel =10;
   	 		
			if (Route3 > 0) 	//FLY THE ROUTE STARTS HERE!!
    			{
			map.HideDashboard();	//Hides VE's dashboard
			GetTiles();		//Calls by defaut the SPOT TILES.
			//GetTilesDEM();  	//get the DEM tiles dashed out so no conflict between tiles. Only load one, not both.
			Drawtheroute();		//Draw the route on Logan.
			AddCampPins(); 		//Adds all the camppins on Logan
	                AddCampPins2();
        	        AddCampPins3();
	                AddCampPins4();
	                AddCampPins5();
	                AddCampPins6();
        	        AddCampPins7();
			AddMyControls();	//Adds the custom controls
	       		fly3D();		//Calls the default view in 3D

    			}


        }
        else 
        {
			map.LoadMap(new VELatLong(lat, longitude), ZoomLevel, 'h', false);   //Initial Map load Lat Long Coordinates with initial ZoomLevel
			map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);              //Get the units in KM. YL
			Addhirescontrol2D();
//			map.LoadMap(new VELatLong(1,-1), 2 ,'h' , false);			entered these two lines of code here but it didn't work
//			map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
        }


	if (str.indexOf("GPS=1") > 0)
		     {
		       var FileIs =  'current.xml';  //This is for current postioning
		       var GpsIcon = 'canada-pin-mid.gif';
		       //The next statements are positioning by day.
			   
		  //     if (str.indexOf("Day=5") > 0)   //EXAMPLE!! This is for Day 5 Repeat this if statment for each day changing filename using syntax below.
		    //    {
		      //     FileIs = '2007-04-20.xml' ;
		        //} 

		       if (str.indexOf("Day=1") > 0)   //This is for Day 1 Repeat this if statment for each day changing filename using syntax below.
		        {
		           FileIs = '2007-05-03.xml' ;
			   DocumentCall = "./byday-pgs/preclimb-Day1.htm" ;  //change preclimb-Day1.htm to the page to display in the right frame (ex: Day2.htm or ./daypages/Day2.htm) Do this for everyday!
			   GetPage(DocumentCall);				//Calls the assigned page in the previous line
		        } 
		       if (str.indexOf("Day=2") > 0)   				//NOTE: Day=2 has to be assigned in the links of the mid-left-pg.htm page. When people click FOLLOW THE CLIMB, then a specific DAY.
		        {
		           FileIs = '2007-05-04.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day2.htm" ;    
			   GetPage(DocumentCall);
		        } 
		       if (str.indexOf("Day=3") > 0)   
		        {
		           FileIs = '2007-05-05.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day3.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=4") > 0)   
		        {
		           FileIs = '2007-05-06.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day4.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=5") > 0)   
		        {
		           FileIs = '2007-05-07.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day5.htm" ;    
			   GetPage(DocumentCall);
		        }  
		       if (str.indexOf("Day=6") > 0)   
		        {
		           FileIs = '2007-05-08.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day6.htm" ;    
			   GetPage(DocumentCall);
		        } 
		       if (str.indexOf("Day=7") > 0)   
		        {
		           FileIs = '2007-05-09.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day7.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=8") > 0)   
		        {
		           FileIs = '2007-05-10.xml' ;
		           DocumentCall = "./byday-pgs/preclimb-Day8.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=9") > 0)   
		        {
		           FileIs = '2007-05-11.xml' ;
		           DocumentCall = "./byday-pgs/Day01.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=10") > 0)   
		        {
		           FileIs = '2007-05-12.xml' ;
		           DocumentCall = "./byday-pgs/Day02.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=11") > 0)   
		        {
		           FileIs = '2007-05-13.xml' ;
		           DocumentCall = "./byday-pgs/Day03.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=12") > 0)   
		        {
		           FileIs = '2007-05-14.xml' ;
		           DocumentCall = "./byday-pgs/Day04.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=13") > 0)   
		        {
		           FileIs = '2007-05-15.xml' ;
		           DocumentCall = "./byday-pgs/Day05.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=14") > 0)   
		        {
		           FileIs = '2007-05-16.xml' ;
		           DocumentCall = "./byday-pgs/Day06.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=15") > 0)   
		        {
		           FileIs = '2007-05-17.xml' ;
		           DocumentCall = "./byday-pgs/Day07.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=16") > 0)   
		        {
		           FileIs = '2007-05-18.xml' ;
		           DocumentCall = "./byday-pgs/Day08.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=17") > 0)   
		        {
		           FileIs = '2007-05-19.xml' ;
		           DocumentCall = "./byday-pgs/Day09.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=18") > 0)   
		        {
		           FileIs = '2007-05-20.xml' ;
		           DocumentCall = "./byday-pgs/Day10.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=19") > 0)   
		        {
		           FileIs = '2007-05-21.xml' ;
		           DocumentCall = "./byday-pgs/Day11.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=20") > 0)   
		        {
		           FileIs = '2007-05-22.xml' ;
		           DocumentCall = "./byday-pgs/Day12.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=21") > 0)   
		        {
		           FileIs = '2007-05-23.xml' ;
		           DocumentCall = "./byday-pgs/Day13.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=22") > 0)   
		        {
		           FileIs = '2007-05-24.xml' ;
		           DocumentCall = "./byday-pgs/Day14.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=23") > 0)   
		        {
		           FileIs = '2007-05-25.xml' ;
		           DocumentCall = "./byday-pgs/Day15.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=24") > 0)   
		        {
		           FileIs = '2007-05-26.xml' ;
		           DocumentCall = "./byday-pgs/Day16.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=25") > 0)   
		        {
		           FileIs = '2007-05-27.xml' ;
		           DocumentCall = "./byday-pgs/Day17.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=26") > 0)   
		        {
		           FileIs = '2007-05-28.xml' ;
		           DocumentCall = "./byday-pgs/Day18.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=27") > 0)   
		        {
		           FileIs = '2007-05-29.xml' ;
		           DocumentCall = "./byday-pgs/Day19.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=28") > 0)   
		        {
		           FileIs = '2007-05-30.xml' ;
		           DocumentCall = "./byday-pgs/Day20.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=29") > 0)   
		        {
		           FileIs = '2007-05-31.xml' ;
		           DocumentCall = "./byday-pgs/Day21.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=30") > 0)   
		        {
		           FileIs = '2007-06-01.xml' ;
		           DocumentCall = "./byday-pgs/Day22.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=31") > 0)   
		        {
		           FileIs = '2007-06-02.xml' ;
		           DocumentCall = "./byday-pgs/Day23.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=32") > 0)   
		        {
		           FileIs = '2007-06-03.xml' ;
		           DocumentCall = "./byday-pgs/Day24.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=33") > 0)   
		        {
		           FileIs = '2007-06-04.xml' ;
		           DocumentCall = "./byday-pgs/Day25.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=34") > 0)   
		        {
		           FileIs = '2007-06-05.xml' ;
		           DocumentCall = "./byday-pgs/Day26.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=35") > 0)   
		        {
		           FileIs = '2007-06-06.xml' ;
		           DocumentCall = "./byday-pgs/Day27.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=36") > 0)   
		        {
		           FileIs = '2007-06-07.xml' ;
		           DocumentCall = "./byday-pgs/postclimb-Day1.htm" ;    
			   GetPage(DocumentCall);
		        }
		       if (str.indexOf("Day=37") > 0)   
		        {
		           FileIs = '2007-06-08.xml' ;
		           DocumentCall = "./byday-pgs/postclimb-Day2.htm" ;    
			   GetPage(DocumentCall);
		        }

		       getPositions(FileIs, GpsIcon);    //1st parameter = file name, 2nd is the icon to use

			//  importXML(FileIs);
		     }   


        if (DocumentCall == null)
           {
                DocumentCall = "blank.htm" ; 
               GetPage(DocumentCall);
                DocumentCall = null;
           }
       //Show DayPins
      
     
       if (str.indexOf("Ridge=1") > 0)
       {
	  LoadRidges()
          map.SetCenterAndZoom(new VELatLong(71.074865690586634,-102.65625000000001), 2);
       }         
       if (DayPin == 1)
       {
            AddDayPins();
       }
       
       
       if (str.indexOf("Ridge=2") > 0)   //Wants to pan to a selected Ridge
       {
          LoadSpecificPins()
       }   
       
       //Show Schools on map
        if (schools > 0) 
        {
           AddLayer(VELayerType.VECollection)
        }
       
       //VE Mashup
       if (hiRes > 0 )
       {
 	GetTiles();
       }
      
     //Turn off mashup
//      if (hiRes2 > 0 )
//       {
//         DeleteTileLayer();
//       }
      //show Daily line.
        if (Route2 > 0)
       {
        SetMap = 1;
       
        DrawPoly( 
                 pinID,    //pin id must be unique
                    [new VELatLong(lat,longitude),   
                    new VELatLong(lat2,longitude2)],
                    6,  //width of line
                    new VEColor(linecolorRed,linecolorGreen,linecolorBlue,1)); 
                    
        //fire off right panel details call
         GetPage(DocumentCall);           
       } 
   
      //show planned route with camps
       if (plan > 0) 
       {
            linecolorRed = 0;
            linecolorGreen = 0;
            linecolorBlue = 255;     
           
            if (Route > 0) 
               {
                    map.Pan(lat,longitude)
                   // ZoomLevel = 10;
               }
               else
               {
                   SetMap = 1;
                   if (hiRes > 0 )
                   {
                     SetMap = 0;
                   }
                   ZoomLevel = 10;
               }
            
             
            // map.SetZoomLevel(ZoomLevel);  //number between 0-19
            //To Add a PolyLine to Page
           if (str.indexOf("Zoom=2") > 0 )
           {    
               ZoomLevel = 10;
           }   
           //Set 3dMode here.
                   if (str.indexOf("3D=2") > 0 )
                    {
                      map.onLoadMap = set3D;
                      map.LoadMap(new VELatLong( 60.6377777, -140.82112034683303), ZoomLevel, 'h', false, VEMapMode.Mode3D);
                // 60.60166667, -140.742
//                60.652192618, -140.7676230  Good two
                   
                    }
           
           //                    [new VELatLong(60.60166667,-140.815),   
//                    new VELatLong(60.61,-140.6916667), 
//                    new VELatLong(60.5961666,-140.6083333),   
//                    new VELatLong(60.6,-140.5766667),
//                    new VELatLong(60.60166667,-140.535),
//                    new VELatLong(60.6,-140.44),
//                    new VELatLong(60.56833333,-140.40333334)],
           
           DrawPoly( 
                 pinID,    //pin id must be unique
                  [new VELatLong(60.601765478362,-140.815098754598),
new VELatLong(60.60337747243,-140.807378028904),
new VELatLong(60.604462505067,-140.801313951439),
new VELatLong(60.60526162409,-140.79442154986),
new VELatLong(60.605860963358,-140.788228377426),
new VELatLong(60.606660082382,-140.785431460844),
new VELatLong(60.60725942165,-140.781735535359),
new VELatLong(60.60759316389,-140.776287304388),
new VELatLong(60.608258320429,-140.772445776709),
new VELatLong(60.608657879941,-140.766352494153),
new VELatLong(60.609656778721,-140.759559982451),
new VELatLong(60.610056338232,-140.754965048065),
new VELatLong(60.610754932485,-140.748358348467),
new VELatLong(60.610754932485,-140.74256177271),
new VELatLong(60.610754932485,-140.736765196953),
new VELatLong(60.610754932485,-140.727806852601),
new VELatLong(60.610754932485,-140.723064199709),
new VELatLong(60.610256117988,-140.712012400542),
new VELatLong(60.610056338233,-140.703521760915),
new VELatLong(60.610056338233,-140.697328588481),
new VELatLong(60.610056338233,-140.691634865438),
new VELatLong(60.60759316389,-140.678272477949),
new VELatLong(60.604958356728,-140.666679326435),
new VELatLong(60.603064046775,-140.659470324734),
new VELatLong(60.601765478362,-140.654475830836),
new VELatLong(60.600215703836,-140.649816560596),
new VELatLong(60.598634819538,-140.643493023406),
new VELatLong(60.598107858106,-140.638750370514),
new VELatLong(60.597580896673,-140.636115563352),
new VELatLong(60.596814284711,-140.629198993113),
new VELatLong(60.596941220401,-140.621455916051),
new VELatLong(60.59719509178,-140.614982195884),
new VELatLong(60.59719509178,-140.610793318129),
new VELatLong(60.597004688245,-140.609968236147),
new VELatLong(60.596243074108,-140.608318072183),
new VELatLong(60.595989202729,-140.607556458046),
new VELatLong(60.596052670574,-140.60641403684),
new VELatLong(60.596116138419,-140.605398551324),
new VELatLong(60.596623881177,-140.603811855204),
new VELatLong(60.596814284711,-140.603240644601),
new VELatLong(60.597258559625,-140.600638462966),
new VELatLong(60.597236397339,-140.600004745113),
new VELatLong(60.597258559625,-140.599051766847),
new VELatLong(60.597580896673,-140.595539533052),
new VELatLong(60.598634819538,-140.591850803025),
new VELatLong(60.600215703836,-140.586054227268),
new VELatLong(60.600215703836,-140.581838535808),
new VELatLong(60.600067350436,-140.576761505782),
new VELatLong(60.600215703836,-140.572353230023),
new VELatLong(60.600067350436,-140.560079896162),
new VELatLong(60.60036702007,-140.556483860556),
new VELatLong(60.60036702007,-140.554585952874),
new VELatLong(60.601665588484,-140.551689146413),
new VELatLong(60.60186536824,-140.546095313248),
new VELatLong(60.601796588133,-140.539154659778),
new VELatLong(60.601765478362,-140.535007536794),
new VELatLong(60.601796588133,-140.528088469696),
new VELatLong(60.601796588133,-140.523345816804),
new VELatLong(60.601796588133,-140.515441395317),
new VELatLong(60.601765478362,-140.511733195229),
new VELatLong(60.602323549565,-140.506483050965),
new VELatLong(60.602850510998,-140.495943822316),
new VELatLong(60.603904433863,-140.483823709369),
new VELatLong(60.604958356728,-140.47117663499),
new VELatLong(60.604958356728,-140.459056522043),
new VELatLong(60.603763275921,-140.451299819062),
new VELatLong(60.601269626701,-140.445355524799),
new VELatLong(60.59986757068,-140.440012262852),
new VELatLong(60.59697076422,-140.432620411883),
new VELatLong(60.596071755318,-140.429024376277),
new VELatLong(60.595473050943,-140.423750106068),
new VELatLong(60.594419128078,-140.416372646013),
new VELatLong(60.591784320916,-140.412156954553),
new VELatLong(60.588380234715,-140.40924618044),
new VELatLong(60.586881886545,-140.408447061416),
new VELatLong(60.5861826574,-140.408546951294),
new VELatLong(60.585083868742,-140.40874673105),
new VELatLong(60.579664207969,-140.411103031689),
new VELatLong(60.578291357041,-140.411343867877),
new VELatLong(60.57755636224,-140.411103031689),
new VELatLong(60.577240312359,-140.410470931927),
new VELatLong(60.574795211312,-140.404950915688),
new VELatLong(60.573696422654,-140.402153999105),
new VELatLong(60.573646756024,-140.402080842997),
new VELatLong(60.573504030786,-140.401923845235),
new VELatLong(60.573261397882,-140.40186675514),
new VELatLong(60.573033037501,-140.401838210092),
new VELatLong(60.572790404597,-140.401795392521),
new VELatLong(60.572576316741,-140.401881027664),
new VELatLong(60.572333683837,-140.402123660568),
new VELatLong(60.571819872981,-140.402637471424),
new VELatLong(60.571334607173,-140.403322552565),
new VELatLong(60.570963521554,-140.403950543611),
new VELatLong(60.570678071079,-140.405020982894)],
                    6,  //width of line
                    new VEColor(linecolorRed,linecolorGreen,linecolorBlue,1));   
                    pinID++;
             //To Add a pin to a page.  I repeated the call 6 times for 6 camps - but can put in a loop passing
             //in all the data.   
             AddCampPins(); 
             AddCampPins2();
             AddCampPins3();
             AddCampPins4();
             AddCampPins5();
             AddCampPins6();
             AddCampPins7();    //Summit Pin
				if (PanTo == 0 )
				 {   
				   DocumentCall = "blank.htm" ;        
				 }
             GetPage(DocumentCall);
             
             if (str.indexOf("Zoom=2") > 0 )
               {    
                   map.SetZoomLevel(16);   //zoom level for Hi-Res link
               }   
        }        
       
       //To Delete a pushpin
       //  DeletePin(id)          
      }  
           
      function DeletePin(id)
      {
         map.DeletePushpin(id);
      }
         
      function AddCampPins() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.60166667, -140.815), 
                      'http://64.34.233.184/custompins/basecamp.gif',  //custom graphic path and name instead of standard pushpin
                      'Base Camp',     //title of Hover over
                      '<img src="./Images/camps/BaseCamp1.jpg"><BR>2,865 metres; 9,400 feet<BR>Located on lower Kings Trench in a wide valley.' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-basecamp.html\')">Audio</a>',  
                      'pinoffset',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }   
      function AddCampPins2() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.61, -140.6916667), 
                      'http://64.34.233.184/custompins/camp1.gif',  //custom graphic path and name instead of standard pushpin
                      'Camp I - Kings Trench',
                      '<img src="./Images/camps/KingsTrench1.jpg"><BR>3,400 metres; 11,155 feet<BR>Higher up Kings Trench in the middle of the glacier.' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-campI.html\')">Audio</a>',  
                      'pinoffset',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }  
        function AddCampPins3() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.5961666, -140.6083333), 
                      'http://64.34.233.184/custompins/camp2.gif',  //custom graphic path and name instead of standard pushpin
                      'Camp II - King Col',
                      '<img src="./Images/camps/KingCol1.jpg"><BR>4,190 metres; 13,747 feet<BR>At the base of the headwall away from avalanche slopes.' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-campII.html\')">Audio</a>',  
                      'pinoffsetcamp2',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }  
        function AddCampPins4() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.60, -140.5766667), 
                      'http://64.34.233.184/custompins/camp3.gif',  //custom graphic path and name instead of standard pushpin
                      'Camp III - Football Field',
                      '<img src="./Images/camps/camp3.jpg"><BR>4,468; metres 14,657 feet<BR>A flat section, setting camp in the lower bowl area.' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-campIII.html\')">Audio</a>',  
                      'pinoffsetcamp3',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }  
        function AddCampPins5() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.60166667, -140.535), 
                      'http://64.34.233.184/custompins/camp4.gif',  //custom graphic path and name instead of standard pushpin
                      'Camp IV Prospectors Col',
                      '<img src="./Images/camps/image4.jpg"><BR>5,102 metres; 16,739 feet<BR>On the east side of the Col, protected from the wind.' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-campIV.html\')">Audio</a>',  
                      'pinoffsetcamp4',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }  
          function AddCampPins6() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.60, -140.440), 
                      'http://64.34.233.184/custompins/camp5.gif',  //custom graphic path and name instead of standard pushpin
                      'Camp V - Plateau',
                      '<img src="./Images/camps/Camp5-plateau.jpg"><BR>5,227 metres; 17,149 feet<BR>Windy, cold setting close to the final climb up to the summit.' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-campV.html\')">Audio</a>',  
                      'pinoffsetcamp5',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }  
               function AddCampPins7() 
              {            
                var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(60.570678071079,-140.405020982894), 
                      'http://64.34.233.184/custompins/summit.gif',  //custom graphic path and name instead of standard pushpin
                      'Summit of Mount Logan',
                      '<img src="./Images/camps/LoganSummit.jpg"><BR>5,959 metres; 19,551 feet<BR>The Top Of Canada! What A View!' +
                      '<BR><a href="javascript:GetPage(\'pgs-camps-av/av-summit.html\')">Audio</a>',  
                      'pinoffsetsummit',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;   
              }  
                 
           
           
        function DrawPoly(id,points,width,color) 
           {          
             poly = new VEPolyline(id,points);  
             poly.SetWidth(width);     
             poly.SetColor(color);    
             map.AddPolyline(poly); 
             if (SetMap == 1 && str.indexOf("3D=2") < 1 )
                {
                  map.SetMapView(points);       //only want to run this when loading complete polyline - not if you zoom to a camp.   
                }   
            } 
            
       function GetPage(URLName)
            {
               parent.InfoFrame.document.location.href = URLName;  //to open in a different frame
            }
         
      
//ADDS the SPOT Tiles.
      function GetTiles()         
           { 
           //Old topo mashup
//                 var bounds = [new VELatLongRectangle(new VELatLong(60.6858057243,-140.773428894), new VELatLong(60.4555997042,-140.08501059))]; 
//                 var tileSourceSpec = new VETileSourceSpecification(); 
//                
//                 tileSourceSpec.ID = "spot";      
//                 tileSourceSpec.TileSource = "https://s3.amazonaws.com/vetiles/MT_LOGAN/LAYERS/color-dem-LL-01_layer/%4.png";  
//                 tileSourceSpec.NumServers = 1;    
//                 tileSourceSpec.Bounds = bounds;    
//                 tileSourceSpec.MinZoom = 5;   
//                 tileSourceSpec.MaxZoom = 19;    
//                 map.AddTileSource(tileSourceSpec); 
//                 var tileLayer = new VELayerSpecification(VELayerType.VETileSource,"1", "spot"); 
//                 tileLayer.ZIndex = 100;       
//                 tileLayer.Opacity=0.5;     
//                 map.AddLayer(tileLayer); 
//                 map.SetCenterAndZoom(new VELatLong(60.60166667,-140.815), 9); 

//New Hi-Res Mashup 


  var bounds = [new VELatLongRectangle(new VELatLong(60.6764890718,-140.817484071), new VELatLong(60.5025556459,-140.241530005))]; 

                 var tileSourceSpec = new VETileSourceSpecification(); 

                 tileSourceSpec.ID = "spot";      
                 tileSourceSpec.TileSource = "http://64.34.233.184/LAYERS/SPOT-opticaldata_layer/%4.png";  
                 tileSourceSpec.NumServers = 1;    
                 tileSourceSpec.Bounds = bounds;    
                 tileSourceSpec.MinZoom = 5;   
                 tileSourceSpec.MaxZoom = 19;    

                 map.AddTileSource(tileSourceSpec); 
                 var tileLayer = new VELayerSpecification(VELayerType.VETileSource,layerid, "spot");   //For some unknown reason, layerid has to be put here so it will load the spottiles (follow the climb). Layerid was also added to the DeleteTileLayer() Function.

                 tileLayer.ZIndex = 50;   //was 100, should fix the line color problem. YL      
                 tileLayer.Opacity = 1.0;     


                 map.AddLayer(tileLayer); 

		 imagery = "SPOT";				//Imagery has to be set to SPOT so when we remove it, we know it is created. 

//Imagery is checked when we are calling the TOPO Tiles.


		if (spotloaded=="NO")
		{
			 if (str.indexOf("PanTo=0")>0)
                 {
                     	var m2=map.GetMapMode();          
      			if (m2==VEMapMode.Mode2D)
			{map.SetCenterAndZoom(new VELatLong(60.5861666,-140.6083333), 11);}
                 }
		spotloaded = "YES";
		}
//                 else
  //                   {
    //                 map.SetCenterAndZoom(new VELatLong(60.61,-140.6916667), 12); 
      //           }
               }  






//ADDS the TOPO tiles.

	function GetTilesDEM()         
           { 
 		var boundsDEM = [new VELatLongRectangle(new VELatLong(60.7364823461,-140.945285591), new VELatLong(60.4096167592,-140.009379779))]; 

                 var tileSourceSpec = new VETileSourceSpecification(); 

                 tileSourceSpec.ID = "DEM";      
                 tileSourceSpec.TileSource = "http://64.34.233.184/LAYERS/newDEM-LL-50mcontours_layer/%4.png";  
                 tileSourceSpec.NumServers = 1;    
                 tileSourceSpec.Bounds = boundsDEM;    
                 tileSourceSpec.MinZoom = 5;   
                 tileSourceSpec.MaxZoom = 16;    

                 map.AddTileSource(tileSourceSpec); 
                 var tileLayer = new VELayerSpecification(VELayerType.VETileSource,"2", "DEM"); 

                 tileLayer.ZIndex = 50;   //was 100, should fix the line color problem. YL      
                 tileLayer.Opacity = 1.0;     

                 map.AddLayer(tileLayer); 
		imagery = "DEM";		//Imagery here is set to DEM so we know if the DEM tiles are there.


//			 if (str.indexOf("PanTo=0")>0)
  //               {
    //			var m2=map.GetMapMode();          
      //  		if (m2!=VEMapMode.Mode3D)
	//		{map.SetCenterAndZoom(new VELatLong(60.5861666,-140.6083333), 12);}
          //       }



	}








             
             
             function PanMap(x,y,latlong)     
             {   
              if (x!=null & y!=null)       
                {            
                   map.Pan(x,y);   
                }          
                else if (latlong!=null)          
                {           
                   map.PanToLatLong(latlong);       
                }      
             }   
             
             function PanToLocation()
             {
              //The If statements below pan to the location of camps
              if (str.indexOf("PanTo=1") > 0)     //Pan to Base Camp Kings Trench.  Repeat this if statement
               {                                  
                lat = 60.59166667;                
                longitude = -140.815;   
                DocumentCall = "camps/SummaryBaseCamp.htm"          
                }
               if (str.indexOf("PanTo=2") > 0)     //Pan to  Kings Trench.  Repeat this if statement
               {                                  
                lat = 60.60;                
                longitude = -140.6916667; 
                DocumentCall = "camps/CampI.htm" ;           
                }
                if (str.indexOf("PanTo=3") > 0)     //Pan to  Kings Col.  Repeat this if statement
               {                                  
                lat = 60.5861666;               
                longitude = -140.6083333;  
                DocumentCall = "camps/CampII.htm" ;           
                }
                if (str.indexOf("PanTo=4") > 0)     //Pan to Football Field.  Repeat this if statement
               {                                 
                lat = 60.59;                      
                longitude = -140.5766667;  
                DocumentCall = "camps/CampIII.htm" ;           
                }
                if (str.indexOf("PanTo=5") > 0)     //Pan to Prospectors Col.  Repeat this if statement
               {                                  
                lat = 60.59166667;               
                longitude = -140.535; 
                DocumentCall = "camps/CampIV.htm" ;             
                }
                if (str.indexOf("PanTo=6") > 0)     //Pan to Plateau.  
               {                                  
                lat = 60.59;                     
                longitude = -140.44;  
                DocumentCall = "camps/CampV.htm" ;           
                }
                if (str.indexOf("PanTo=7") > 0)     //Pan to Summit.  
               {                                  
                lat = 60.55833333;                     
                longitude = -140.4033333;  
                DocumentCall = "camps/Summit.htm" ;           
                }

               //End Panning to Camp locations
           
               ZoomLevel = 13;    //number between 0-19
			   PanTo = 1;
               GetPage(DocumentCall);
             }  
             
//Samantha says its an old function she had at the beginning. It is only being called once in the mid-left-pg.htm but could be removed. I'm scared to remove it.           

  function DayByDayLocation()
             {
               //If statements below set lat and long for day by day 
               //Set Line color variables to a different color.
               
                linecolorRed = 255;
                linecolorGreen = 0;
                linecolorBlue = 0;

                  if (str.indexOf("PanTo=1") > 0)     //Pan to Day 1 location - change lat long as appropriate.  
               {                                  
                
                lat = 60.60166667;              //Start Lat
                longitude = -140.815;      //Start Long		
                lat2 = 60.61;              //End Lat   
                longitude2 = -140.6916667;      //End Long  
                DocumentCall = "pgs-byday/Day1.htm"
                DayPin = 1; 
                }
                  if (str.indexOf("PanTo=2") > 0)     //Pan to Day 2 location - change lat long as appropriate.  
               {                                  
                
                lat = 60.58768;              //Start Lat      
                longitude = -147.56836;      //Start Long
                lat2 = 64.37794;              //End Lat      
                longitude2 = -143.83301;      //End Long      
                DocumentCall = "pgs-byday/Day2.htm"
                DayPin = 1; 
                }
                  if (str.indexOf("PanTo=3") > 0)     //Pan to Day 3 location - change lat long as appropriate.  
               {                                  
                
                lat = 60.58768;              //Start Lat      
                longitude = -147.56836;      //Start Long
                lat2 = 64.37794;              //End Lat      
                longitude2 = -143.83301;      //End Long      
                DocumentCall = "pgs-byday/Day3.htm"
                DayPin = 1; 
                }
                if (str.indexOf("PanTo=4") > 0)     //Pan to Day 4 location - change lat long as appropriate.  
               {                                  
                
                lat = 60.58768;              //Start Lat      
                longitude = -147.56836;      //Start Long
                lat2 = 64.37794;              //End Lat      
                longitude2 = -143.83301;      //End Long      
                DocumentCall = "pgs-byday/Day4.htm"
                DayPin = 1; 
                }
                   if (str.indexOf("PanTo=5") > 0)     //Pan to Day 5 location - change lat long as appropriate.  
               {                                  
                
                lat = 60.58768;              //Start Lat      
                longitude = -147.56836;      //Start Long
                lat2 = 64.37794;              //End Lat      
                longitude2 = -143.83301;      //End Long      
                DocumentCall = "pgs-byday/Day5.htm"
                DayPin = 1; 
                }
                ///Add the additional if section above for the rest of the days.
                
             }
             
             function AddDayPins()
             {
                 var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(lat, longitude), 
                      './Images/play.gif',  //custom graphic path and name instead of standard pushpin
                      'Summary of Day',
                      '<img src="./Images/image5.jpg"><BR>Summary Description of how the day started.',   
                      'iconStyle',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++; 
                  var pin = new VEPushpin( 
                      pinID, 
                      new VELatLong(lat2, longitude2), 
                      './Images/stop.gif',  //custom graphic path and name instead of standard pushpin
                      'Summary of Day',
                      '<img src="./Images/image5.jpg"><BR>Summary Description of what happened in between and how the day ended.',
                      'iconStyle',
                      'titleStyle',
                      'detailsStyle'  
                                        );           
                 map.AddPushpin(pin);       
                 pinID++;     
             }
             
             
             function AddLayer(type)
             {
                  
                DocumentCall = "pgs-rightframe/Schools.htm" ;           
                GetPage(DocumentCall);
                  var veLayerSpec = new VELayerSpecification();
                  veLayerSpec.Type = type;  
                  veLayerSpec.ID = layerid;   
                  veLayerSpec.LayerSource = "2CBB476FC0FE167F!197";
                  veLayerSpec.Method = 'get';        
                  map.AddLayer(veLayerSpec);
                  veLayerSpec.FnCallback = onFeedLoad; 
                  layerid++;
                  
                  
             }
             function onFeedLoad(feed)        
              {           
                alert('Schools have been loaded. There are '+feed.length+' schools in this list.'); 
                map.SetCenterAndZoom(new VELatLong(63.074865690586634,-102.65625000000001), 3);
               }
               
               function UnloadMap() //dispose map etc
                {
                  if (map != null)
                  {
                    map.Dispose();
                  }

                } 

            function LoadRidges()
            {
               AddAllRidges();
            }   
                
            function AddAllRidges()
            {
                   var pin = new VEPushpin(pinID, 
                    new VELatLong(81.9136666666667,-75.0111444444444), 
                    './Images/mountain-pin5.gif', 
                    'Barbeau Peak, Nunavut',
                    'Elevation: 8,583ft (2,616m)',
		    'canadapinoffset'
                    );

		          map.AddPushpin(pin);
                  pinID++;
                 
                 var pin = new VEPushpin(pinID, 
                    new VELatLong(52.1469444444444,-117.438888888889), 
                    './Images/mountain-pin5.gif', 
                    'Mount Columbia, Alberta',
                    'Elevation: 12,293ft (3,747m)',
		    'canadapinoffset'
                    );

		          map.AddPushpin(pin);
                  pinID++;
               
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(58.9079222222222,-137.523566666667), 
                            './Images/mountain-pin5.gif', 
                            'Fairweather Mountain, British Columbia',
                            'Elevation: 15,299ft (4,663m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;
                
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(60.5681694444445,-140.405827777778), 
                            './Images/mountain-pin5.gif', 
                            'Mount Logan, Yukon',
                            'Elevation: 15,551ft (5,959m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(51.4721361111111,-100.716672222222), 
                            './Images/mountain-pin5.gif', 
                            'Baldy Mountain, Manitoba',
                            'Elevation: 2,730ft (832m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 var pin = new VEPushpin(pinID, 
                            new VELatLong(49.552,-109.984338888889), 
                            './Images/mountain-pin5.gif', 
                            'Cypress Hills, Saskatchewan',
                            'Elevation: 4,816ft (1,468m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 var pin = new VEPushpin(pinID, 
                            new VELatLong(47.3166666666667,-80.75), 
                            './Images/mountain-pin5.gif', 
                            'Ishpatina Ridge, Ontario',
                            'Elevation: 2,274ft (693m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;


                 var pin = new VEPushpin(pinID, 
                            new VELatLong(58.8833333333333,-63.7102805555556), 
                            './Images/mountain-pin5.gif', 
                            'Mont D`Iberville, Quebec',
                            'Elevation: 5,417ft (1,651m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 var pin = new VEPushpin(pinID, 
                            new VELatLong(47.3729416666667,-66.8834361111111), 
                            './Images/mountain-pin5.gif', 
                            'Mount Carleton, New Brunswick',
                            'Elevation: 2,960ft (820m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 var pin = new VEPushpin(pinID, 
                            new VELatLong(46.6999694444444,-60.5943972222222), 
                            './Images/mountain-pin5.gif', 
                            'White Hill (Cape Breton Highlands), Nova Scotia',
                            'Elevation: 1,745ft (532m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;


                 var pin = new VEPushpin(pinID, 
                            new VELatLong(46.3323666666667,-63.419), 
                            './Images/mountain-pin5.gif', 
                            'Springton (Queens County), Prince Edward Island',
                            'Elevation: 459ft (140m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 var pin = new VEPushpin(pinID, 
                            new VELatLong(61.875,-127.683055555556), 
                            './Images/mountain-pin5.gif', 
                            'Un-named Summit, North West Territories',
                            'Elevation: 9,098ft (2,773m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 var pin = new VEPushpin(pinID, 
                            new VELatLong(58.8874944444444,-63.7103361111111), 
                            './Images/mountain-pin5.gif', 
                            'Mount Caubvick, Newfoundland and Labrador',
                            'Elevation: 5,420ft (1,652m)',
		    	    'canadapinoffset'
                            );

		          map.AddPushpin(pin);
                  pinID++;

		         
                }
          
          function LoadSpecificRidge()
          {
                if (str.indexOf("lat=1") > 0)     //Pan to Mount Logan
               {                                  
                    lat = 60.5681694444445;                
                    longitude = -140.405827777778;   
                    DocumentCall = "summits/Logan.htm"          
                }   
                 if (str.indexOf("lat=2") > 0)     //Pan to Ispatina
               {                                  
                    lat = 47.3166666666667;                
                    longitude = -80.75; 
                    DocumentCall = "summits/Ishpatina.htm"          
                }    
                  if (str.indexOf("lat=3") > 0)     //Pan to Barbareau
               {                                  
                    lat = 81.9136666666667;                
                    longitude = -75.0111444444444;   
                    DocumentCall = "summits/Barbeau.htm"          
                }    
                  if (str.indexOf("lat=4") > 0)     //Pan to Baldy
               {                                  
                    lat = 51.4721361111111;                
                    longitude = -100.716672222222  ;   
                    DocumentCall = "summits/Baldy.htm"      
             
                }    
                  if (str.indexOf("lat=5") > 0)     //Pan to CypressHill
               {                                  
                    lat = 49.552;                
                    longitude = -109.984338888889;   
                    DocumentCall = "summits/cypress.htm"          
                }    
                  if (str.indexOf("lat=6") > 0)     //Pan to Fairweather
               {                                  
                    lat = 58.9079222222222;                
                    longitude = -137.523566666667;   
                    DocumentCall = "summits/fairweather.htm"          
                } 
                     if (str.indexOf("lat=7") > 0)     //Pan to Carleton
               {                                  
                    lat = 47.3729416666667;                
                    longitude = -66.8834361111111;   
                    DocumentCall = "summits/carleton.htm"          
                }        
                   if (str.indexOf("lat=8") > 0)     //Pan to Caubvik
               {                                  
                    lat = 58.8874944444444;                
                    longitude = -63.7103361111111;   
                    DocumentCall = "summits/caubvick.htm"          
                }     
               
                   if (str.indexOf("lat=9") > 0)     //Pan to Columbia
               {                                  
                    lat = 52.1469444444444;                
                    longitude = -117.438888888889;   
                    DocumentCall = "summits/columbia.htm"          
                }     
                   if (str.indexOf("lat=10") > 0)     //Pan to Dlbeville
               {                                  
                    lat = 58.8833333333333;                
                    longitude = -63.7102805555556;   
                    DocumentCall = "summits/dlberville.htm"          
                }     
                   if (str.indexOf("lat=11") > 0)     //Pan to Queens
               {                                  
                    lat = 46.3323666666667;                
                    longitude = -63.419;   
                    DocumentCall = "summits/queens.htm"          
                }     
                   if (str.indexOf("lat=12") > 0)     //Pan to Mount Nirvana
               {                                  
                    lat = 61.875;                
                    longitude = -127.683055555556;   
                    DocumentCall = "summits/unnamed.htm"          
                }     
                   if (str.indexOf("lat=13") > 0)     //Pan to White Hill
               {                                  
                    lat = 46.6999694444444;                
                    longitude = -60.5943972222222;   
                    DocumentCall = "summits/white.htm"          
                }     
                ZoomLevel = 6;   
                GetPage(DocumentCall);
				PanTo = 1;
           }   
           
//function used by Samantha to set a specific 3D setting.         
           
          function set3D() 
          {
              map.SetAltitude(11586.4246567441);   
              map.SetPitch(-12.9347702049429);  
              map.SetHeading(97.4725050234393); 
//                map.SetAltitude(5433.985266551);   
//                map.SetPitch(-13.1208272425603);  
//                map.SetHeading(97.3333130750332);  
          } 
          
           function LoadSpecificPins()
          {
              
                if (str.indexOf("lat=1") > 0)     //Pan to Mount Logan
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(60.5681694444445,-140.405827777778), 
                            './Images/mountain-pin5.gif', 
                            'Mount Logan, Yukon',
                            'Elevation: 15,551ft (5,959m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;

                 } 
                 if (str.indexOf("lat=2") > 0)     //Pan to Ishpatina
               {                                   
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(47.3166666666667,-80.75), 
                            './Images/mountain-pin5.gif', 
                            'Ishpatina Ridge, Ontario',
                            'Elevation: 2,274ft (693m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;

              }
                if (str.indexOf("lat=3") > 0)     //Pan to Barbeau Peak
               {  
                 var pin = new VEPushpin(pinID, 
                    new VELatLong(81.9136666666667,-75.0111444444444), 
                    './Images/mountain-pin5.gif', 
                    'Barbeau Peak, Nunavut',
                    'Elevation: 8,583ft (2,616m)'
                    );
                   map.AddPushpin(pin);
                  pinID++;
               }   
               
                 if (str.indexOf("lat=4") > 0)     //Pan to Baldy Mountain
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(51.4721361111111,-100.716672222222), 
                            './Images/mountain-pin5.gif', 
                            'Baldy Mountain, Manitoba',
                            'Elevation: 2,730ft (832m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
                }
                if (str.indexOf("lat=5") > 0)     //Pan to Cypress Hills
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(49.552,-109.984338888889), 
                            './Images/mountain-pin5.gif', 
                            'Cypress Hills, Saskatchewan',
                            'Elevation: 4,816ft (1,468m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
                }
                  if (str.indexOf("lat=6") > 0)     //Pan to Fairweather
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(58.9079222222222,-137.523566666667), 
                            './Images/mountain-pin5.gif', 
                            'Fairweather Mountain, British Columbia',
                            'Elevation: 15,299ft (4,663m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
                }
                if (str.indexOf("lat=7") > 0)     //Pan to Mount Carleton
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(47.3729416666667,-66.8834361111111), 
                            './Images/mountain-pin5.gif', 
                            'Mount Carleton, New Brunswick',
                            'Elevation: 2,960ft (820m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
                } 
              
               if (str.indexOf("lat=8") > 0)     //Pan to Mount Cabvick
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(58.8874944444444,-63.7103361111111), 
                            './Images/mountain-pin5.gif', 
                            'Mount Caubvick, Newfoundland and Labrador',
                            'Elevation: 5,420ft (1,652m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
              }
                if (str.indexOf("lat=9") > 0)     //Pan to Mount Columbia
               {    
                var pin = new VEPushpin(pinID, 
                    new VELatLong(52.1469444444444,-117.438888888889), 
                    './Images/mountain-pin5.gif', 
                    'Mount Columbia, Alberta',
                    'Elevation: 12,293ft (3,747m)'
                    );

		          map.AddPushpin(pin);
                  pinID++;
               }
                  
              if (str.indexOf("lat=10") > 0)     //Pan to Mont D'Iberville
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(58.8833333333333,-63.7102805555556), 
                            './Images/mountain-pin5.gif', 
                            'Mont D`Iberville, Quebec',
                            'Elevation: 5,417ft (1,651m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
              }
               if (str.indexOf("lat=11") > 0)     //Pan to Springton
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(46.3323666666667,-63.419), 
                            './Images/mountain-pin5.gif', 
                            'Springton (Queens County), Prince Edward Island',
                            'Elevation: 459ft (140m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
               }
               if (str.indexOf("lat=12") > 0)     //Pan to Un-named summit-nirvana
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(61.875,-127.683055555556), 
                            './Images/mountain-pin5.gif', 
                            'Un-named Summit, North West Territories',
                            'Elevation: 9,098ft (2,773m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
                 }
                if (str.indexOf("lat=13") > 0)     //Pan to White Hill
               {                                  
                 var pin = new VEPushpin(pinID, 
                            new VELatLong(46.6999694444444,-60.5943972222222), 
                            './Images/mountain-pin5.gif', 
                            'White Hill (Cape Breton Highlands), Nova Scotia',
                            'Elevation: 1,745ft (532m)'
                            );

		          map.AddPushpin(pin);
                  pinID++;
               }
            
              
         }  
               function get3DSettings()
      {
         alert('Altitude: '+ map.GetAltitude()+'\nHeading: '+map.GetHeading()+'\nPitch: '+map.GetPitch()+'\nLat, long of map center: '+map.GetCenter());
      }
 
 
 		
//Samantha's function to draw the GEORSS files (XML files).


		function getPositions(fileName, iconURL)
		        {
		           var baseURL = "GeoRSS/";
		           var imageURL = "Images/";
		           var positionLayer = new VELayerSpecification();

		           positionLayer.Type        = VELayerType.GeoRSS;
		           positionLayer.ID          = layerid;
		           positionLayer.LayerSource = baseURL + fileName;

		           positionLayer.Method      = "get";
		           positionLayer.IconUrl     = imageURL + iconURL;
		           positionLayer.FnCallback = function () {
		           
		           if (fileName=='2007-05-03.xml')
		           {map.SetZoomLevel(10);}
		           if (fileName=='2007-05-06.xml')
		           {map.SetZoomLevel(6);}   
		           if (fileName=='2007-05-09.xml')
		           {map.SetZoomLevel(10);}   
		           if (fileName=='2007-05-11.xml')
		           {map.SetZoomLevel(8);}
		           if (fileName=='2007-06-06.xml')
		           {map.SetZoomLevel(7);}
		           if (fileName=='2007-06-08.xml')
		           {map.SetZoomLevel(4);}
		           else if (fileName!='2007-05-03.xml')
		           {
		           map.SetZoomLevel(12);
		           }
		           };
   
		           map.AddLayer(positionLayer);
			   layerid++;
			importXML(fileName);
		       GetTiles();
			Drawtheroute();		//Draw the route on Logan. Dash out this line if you dont want to see the planned route.
			AddCampPins(); 		//Adds all the camppins on Logan
	                AddCampPins2();
        	        AddCampPins3();
	                AddCampPins4();
	                AddCampPins5();
	                AddCampPins6();
        	        AddCampPins7();
		        } 



//This function is called when the browser is resized. It checks for the browser type (IE, Firefox, etc.) and resizes accordingly.

	function resizeit()
	{

	var BrowserDim = new Object();
	if( typeof( window.innerWidth ) == 'number' )
	{

	//Non-IE
	BrowserDim.Width = window.innerWidth;
	BrowserDim.Height = window.innerHeight;
	} 

	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{

	//IE 6+ in 'standards compliant mode'
	BrowserDim.Width = document.documentElement.clientWidth;
	BrowserDim.Height = document.documentElement.clientHeight;
	}

	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{

	//IE 4 compatible
	BrowserDim.Width = document.body.clientWidth;
	BrowserDim.Height = document.body.clientHeight;
	}

	map.Resize(BrowserDim.Width, BrowserDim.Height);
	}


//This function was used in FLY THE ROUTE when we had the option of flying from camps to camps. It was used to pause between camps to let the people see the tiles before being prompted to continue.

        function pausecomp(millis) 
	{
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); } 
	while(curDate-date < millis);
	} 





//This is the main function being called in FLY THE ROUTE

	function fly3D()
	{ 
        var m=map.GetMapMode();          
      	if (m==VEMapMode.Mode3D)         
      	{            
	//gotobasecamp();	//This function was calling the function below (between ******) to fly from camps to camps and being prompted to keep going.
        // var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);   //this is the old viewspecs when we reseted the view. To keep in case.
        var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 12000,     -25,     61);  
     	map.SetMapView(viewspec);
	}
        }



//******************************************************************************************************************************************************

      	function gotobasecamp()
    	{  
   	var viewspec = new VEMapViewSpecification(new VELatLong(60.62072096, -140.7433677), null, 4342,     -7,     80);  
     	map.SetMapView(viewspec);
     	pausecomp(2000);
     	var r=confirm('Welcome to Base Camp. Do you want to fly to Camp 1?');
    	
	if (r==true)
	{
	    	gotocamp1();
    	}
    	else
    	{
    	var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);  
     	map.SetMapView(viewspec);

  	}
	}
	
	
	function gotocamp1()
	{
	var viewspec = new VEMapViewSpecification(new VELatLong(60.6101131, -140.682535), null, 4400,     -11,     111);
      	map.SetMapView(viewspec);
     	pausecomp(2000);      	
      	var r=confirm('Welcome to Camp 1. Do you want to fly to Camp 2?');
     	
	if (r==true)
	{
	    	gotocamp2();
    	}
    	else
    	{
    	var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);  
     	map.SetMapView(viewspec);

 	}
	}

		
		
	function gotocamp2()
	{
	var viewspec = new VEMapViewSpecification(new VELatLong(60.595413673, -140.599465044), null, 5960,     -20,     98);
      	map.SetMapView(viewspec);
     	pausecomp(2000);       	
      	var r=confirm('Welcome to Camp 2. Do you want to fly to Camp 3?');
     	
	if (r==true)
	{
		gotocamp3();
    	}
    	else
    	{
    	var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);  
     	map.SetMapView(viewspec);

  	}
	}
		

	function gotocamp3()
	{  
	var viewspec = new VEMapViewSpecification(new VELatLong(60.5984320, -140.55645704422), null, 5960,     -20,     98);
      	map.SetMapView(viewspec);
     	pausecomp(2000);       	
      	var r=confirm('Welcome to Camp 3. Do you want to fly to Camp 4?');
     	
	if (r==true)
	{
		gotocamp4();
    	}
    	else
    	{
    	var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);  
     	map.SetMapView(viewspec);

  	} 
	}
		


	function gotocamp4()
	{
	var viewspec = new VEMapViewSpecification(new VELatLong(60.6017562809, -140.52673299), null, 6481,     -21.7,     99);
      	map.SetMapView(viewspec);
     	pausecomp(2000);       	
      	var r=confirm('Welcome to Camp 4. Do you want to fly to Camp 5?');
     	
	if (r==true)
	{
		gotocamp5();
    	}
    	else
    	{
    	var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);  
     	map.SetMapView(viewspec);

  	}     	
	}  


	function gotocamp5()
	{
	var viewspec = new VEMapViewSpecification(new VELatLong(60.5989727147, -140.42547459146), null, 6458,     -17,     123);
      	map.SetMapView(viewspec);
     	pausecomp(2000);       	
      	var r=confirm('Welcome to Camp 5. Do you want to fly to the Summit?');
     	
	if (r==true)
	{
		gotosummit();
    	}
    	else
    	{
    	var viewspec = new VEMapViewSpecification(new VELatLong(60.5883098079, -140.7097689688), null, 8318,     -25,     61);  
     	map.SetMapView(viewspec);

  	}
	}


	function gotosummit()
	{
	var viewspec = new VEMapViewSpecification(new VELatLong(60.56647259170, -140.40278231172013), null, 7340,     -26,     307);
      	map.SetMapView(viewspec);
    	
       	}

//********************************************************************************************************************************************************       	



//This function is called when in FLY THE ROUTE to draw the route on LOGAN. I know it's there twice put I couldn't get it to call the first one with Samantha's code.

function Drawtheroute()
         {
        
DrawPoly(
            '2', 
            [new VELatLong(60.601765478362,-140.815098754598),
new VELatLong(60.60337747243,-140.807378028904),
new VELatLong(60.604462505067,-140.801313951439),
new VELatLong(60.60526162409,-140.79442154986),
new VELatLong(60.605860963358,-140.788228377426),
new VELatLong(60.606660082382,-140.785431460844),
new VELatLong(60.60725942165,-140.781735535359),
new VELatLong(60.60759316389,-140.776287304388),
new VELatLong(60.608258320429,-140.772445776709),
new VELatLong(60.608657879941,-140.766352494153),
new VELatLong(60.609656778721,-140.759559982451),
new VELatLong(60.610056338232,-140.754965048065),
new VELatLong(60.610754932485,-140.748358348467),
new VELatLong(60.610754932485,-140.74256177271),
new VELatLong(60.610754932485,-140.736765196953),
new VELatLong(60.610754932485,-140.727806852601),
new VELatLong(60.610754932485,-140.723064199709),
new VELatLong(60.610256117988,-140.712012400542),
new VELatLong(60.610056338233,-140.703521760915),
new VELatLong(60.610056338233,-140.697328588481),
new VELatLong(60.610056338233,-140.691634865438),
new VELatLong(60.60759316389,-140.678272477949),
new VELatLong(60.604958356728,-140.666679326435),
new VELatLong(60.603064046775,-140.659470324734),
new VELatLong(60.601765478362,-140.654475830836),
new VELatLong(60.600215703836,-140.649816560596),
new VELatLong(60.598634819538,-140.643493023406),
new VELatLong(60.598107858106,-140.638750370514),
new VELatLong(60.597580896673,-140.636115563352),
new VELatLong(60.596814284711,-140.629198993113),
new VELatLong(60.596941220401,-140.621455916051),
new VELatLong(60.59719509178,-140.614982195884),
new VELatLong(60.59719509178,-140.610793318129),
new VELatLong(60.597004688245,-140.609968236147),
new VELatLong(60.596243074108,-140.608318072183),
new VELatLong(60.595989202729,-140.607556458046),
new VELatLong(60.596052670574,-140.60641403684),
new VELatLong(60.596116138419,-140.605398551324),
new VELatLong(60.596623881177,-140.603811855204),
new VELatLong(60.596814284711,-140.603240644601),
new VELatLong(60.597258559625,-140.600638462966),
new VELatLong(60.597236397339,-140.600004745113),
new VELatLong(60.597258559625,-140.599051766847),
new VELatLong(60.597580896673,-140.595539533052),
new VELatLong(60.598634819538,-140.591850803025),
new VELatLong(60.600215703836,-140.586054227268),
new VELatLong(60.600215703836,-140.581838535808),
new VELatLong(60.600067350436,-140.576761505782),
new VELatLong(60.600215703836,-140.572353230023),
new VELatLong(60.600067350436,-140.560079896162),
new VELatLong(60.60036702007,-140.556483860556),
new VELatLong(60.60036702007,-140.554585952874),
new VELatLong(60.601665588484,-140.551689146413),
new VELatLong(60.60186536824,-140.546095313248),
new VELatLong(60.601796588133,-140.539154659778),
new VELatLong(60.601765478362,-140.535007536794),
new VELatLong(60.601796588133,-140.528088469696),
new VELatLong(60.601796588133,-140.523345816804),
new VELatLong(60.601796588133,-140.515441395317),
new VELatLong(60.601765478362,-140.511733195229),
new VELatLong(60.602323549565,-140.506483050965),
new VELatLong(60.602850510998,-140.495943822316),
new VELatLong(60.603904433863,-140.483823709369),
new VELatLong(60.604958356728,-140.47117663499),
new VELatLong(60.604958356728,-140.459056522043),
new VELatLong(60.603763275921,-140.451299819062),
new VELatLong(60.601269626701,-140.445355524799),
new VELatLong(60.59986757068,-140.440012262852),
new VELatLong(60.59697076422,-140.432620411883),
new VELatLong(60.596071755318,-140.429024376277),
new VELatLong(60.595473050943,-140.423750106068),
new VELatLong(60.594419128078,-140.416372646013),
new VELatLong(60.591784320916,-140.412156954553),
new VELatLong(60.588380234715,-140.40924618044),
new VELatLong(60.586881886545,-140.408447061416),
new VELatLong(60.5861826574,-140.408546951294),
new VELatLong(60.585083868742,-140.40874673105),
new VELatLong(60.579664207969,-140.411103031689),
new VELatLong(60.578291357041,-140.411343867877),
new VELatLong(60.57755636224,-140.411103031689),
new VELatLong(60.577240312359,-140.410470931927),
new VELatLong(60.574795211312,-140.404950915688),
new VELatLong(60.573696422654,-140.402153999105),
new VELatLong(60.573646756024,-140.402080842997),
new VELatLong(60.573504030786,-140.401923845235),
new VELatLong(60.573261397882,-140.40186675514),
new VELatLong(60.573033037501,-140.401838210092),
new VELatLong(60.572790404597,-140.401795392521),
new VELatLong(60.572576316741,-140.401881027664),
new VELatLong(60.572333683837,-140.402123660568),
new VELatLong(60.571819872981,-140.402637471424),
new VELatLong(60.571334607173,-140.403322552565),
new VELatLong(60.570963521554,-140.403950543611),
new VELatLong(60.570678071079,-140.405020982894)],
            3,
            new VEColor(0,0,255,1));
      
           
      }


//This function is called to reset the view when in FLY THE ROUTE

function flyagain()
{
fly3D();
}

   
//These functions are called from the custom controls when people want to zoom from camps to camps.

      function gotobasecamponly()
    	{  
   	    var viewspec = new VEMapViewSpecification(new VELatLong(60.62072096, -140.7433677), null, 4342,     -7,     80);  
     	map.SetMapView(viewspec);
     	}
      
      
      function gotocamp1only()
    	{  
		var viewspec = new VEMapViewSpecification(new VELatLong(60.6101131, -140.682535), null, 4400,     -11,     111);
      	map.SetMapView(viewspec);
     	}
     	
     	
      function gotocamp2only()
    	{ 
		var viewspec = new VEMapViewSpecification(new VELatLong(60.595413673, -140.599465044), null, 5960,     -20,     98);
      	map.SetMapView(viewspec);      
      	}
      
      function gotocamp3only()
    	{ 
		var viewspec = new VEMapViewSpecification(new VELatLong(60.5984320, -140.55645704422), null, 5960,     -20,     98);
      	map.SetMapView(viewspec);
      	}

      function gotocamp4only()
    	{ 
		var viewspec = new VEMapViewSpecification(new VELatLong(60.6017562809, -140.52673299), null, 6481,     -21.7,     99);
      	map.SetMapView(viewspec);
      	}
      	
      function gotocamp5only()
    	{       	
		var viewspec = new VEMapViewSpecification(new VELatLong(60.5989727147, -140.42547459146), null, 6458,     -17,     123);
      	map.SetMapView(viewspec);
      	}
      	
      function gotosummitonly()
    	{ 
   		var viewspec = new VEMapViewSpecification(new VELatLong(60.56647259170, -140.40278231172013), null, 7340,     -26,     307);
      	map.SetMapView(viewspec);      
        }
      


//When clicking FLY THE ROUTE, this function is called to add the custom controls

	function AddMyControls()
	{
	AddMyControl1();
	AddToggleUp();
	Addhirescontrol();
	}


//Function to SHOW/HIDE the custom control of the camps or the tiles, in FLY THE ROUTE ONLY.

	function controlUP()
	{
		var mycontrol1 = document.getElementById('myControl');
		var myshim1 = document.getElementById('myShim');

		var mycontrol2 = document.getElementById('myhirescontrol');
		var myshim2 = document.getElementById('myShimH');
		
		if (mycontrol1.style.display=='')
		{
			mycontrol1.style.display='none';
			myshim1.style.display='none';

			mycontrol2.style.display='none';

			myshim2.style.display='none';
		}
		else if (mycontrol1.style.display=='none')
		{
			mycontrol1.style.display='';
			myshim1.style.display='';

			mycontrol2.style.display='';
			myshim2.style.display='';
		}
	}



//functions to remove the custom controls when displaying a collection

         function RemoveMyControl1()
         {
            var mycontrol = document.getElementById("myControl");
            if (mycontrol!=null) mycontrol.parentNode.removeChild(mycontrol);
            mycontrol = null;
            var myShim = document.getElementById("myShim");
            if (myShim!=null) myShim.parentNode.removeChild(myShim);
            myShim = null;
          }


         function RemoveMyControl2()
         {
            var mycontrol6 = document.getElementById("myControlTUP");
            if (mycontrol6!=null) mycontrol6.parentNode.removeChild(mycontrol6);
            mycontrol6 = null;
            var myShim6 = document.getElementById("myShimTUP");
            if (myShim6!=null) myShim6.parentNode.removeChild(myShim6);
            myShim6 = null;
          }


         function RemoveMyControl3()
         {
            var mycontrol7 = document.getElementById("myhirescontrol");
            if (mycontrol7!=null) mycontrol7.parentNode.removeChild(mycontrol7);
            mycontrol7 = null;
            var myShim7 = document.getElementById("myShimH");
            if (myShim7!=null) myShim7.parentNode.removeChild(myShim7);
            myShim7 = null;
          }


         function RemoveMyControl4()
         {
            var mycontrol8 = document.getElementById("myhirescontrol2");
            if (mycontrol8!=null) mycontrol8.parentNode.removeChild(mycontrol8);
            mycontrol8 = null;
            var myShim8 = document.getElementById("myShimH2");
            if (myShim8!=null) myShim8.parentNode.removeChild(myShim8);
            myShim8 = null;
          }




//This function add the custom control to fly to different camps in FLY THE ROUTE only.

	function AddMyControl1()
	{
		var el = document.createElement("div"); 
		el.id = "myControl";
		el.style.top ="35px"; 
		el.style.left = "10px"; 
		el.style.border = "1px solid white";
		el.style.background ="rgb(241,247,247)";
		el.style.width = "80";
		el.style.padding = "2px";
		el.innerHTML = "<a href='#' onclick='fly3D();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Reset View</font>  </a><br>"+
		"<a href='#' onclick='gotobasecamponly();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Base Camp</font></a>  <br>"+
		"<a href='#' onclick='gotocamp1only();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Camp I</font></a>  <br> "+
		"<a href='#' onclick='gotocamp2only();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Camp II</font></a>  <br> "+
		"<a href='#' onclick='gotocamp3only();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Camp III</font></a>  <br> "+
		"<a href='#' onclick='gotocamp4only();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Camp IV</font></a>  <br> "+
		"<a href='#' onclick='gotocamp5only();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Camp V</font></a>  <br> "+
		"<a href='#' onclick='gotosummitonly();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'>Summit</font></a>";
		map.AddControl(el);
		addShim(el);
		
		
	}

	function addShim(el)
	{
		var shim = document.createElement("iframe");
		shim.id = "myShim";
		shim.frameBorder = "0";
		shim.style.position = "absolute";
		shim.style.zIndex = "1";
		shim.style.top = el.offsetTop;
		shim.style.left = el.offsetLeft;
		shim.width = el.offsetWidth;
		shim.height = el.offsetHeight;
		el.shimElement = shim;
		el.parentNode.insertBefore(shim, el);
	}





//This function adds the SHOW/HIDE custom control when in FLY THE ROUTE only.

	function AddToggleUp()
	{
		var elTUP = document.createElement("div"); 
		elTUP.id = "myControlTUP";
		elTUP.style.top ="10px"; 
		elTUP.style.left = "10px"; 
		elTUP.style.border = "2px solid white";
		elTUP.style.background = "rgb(241,247,247)";
		elTUP.style.width = "80";
		elTUP.style.padding = "2px";
		elTUP.innerHTML = "<p align=center'><a href='#' onclick='controlUP();'><font style='font-size: 9pt' face ='Arial' color='rgb(70,70,70)'><b>Show/Hide</b></font></a></p>";
		map.AddControl(elTUP);
		addShim2(elTUP);
	}

	function addShim2(elTUP)
	{
		var shimTUP = document.createElement("iframe");
		shimTUP.id = "myShimTUP";
		shimTUP.frameBorder = "0";
		shimTUP.style.position = "absolute";
		shimTUP.style.zIndex = "1";
		shimTUP.style.top = elTUP.offsetTop;
		shimTUP.style.left = elTUP.offsetLeft;
		shimTUP.width = elTUP.offsetWidth;
		shimTUP.height = elTUP.offsetHeight;
		elTUP.shimElement = shimTUP;
		elTUP.parentNode.insertBefore(shimTUP, elTUP);
	}







//Function to call the custom control for the tiles when people click the FLY THE ROUTE only.

	function Addhirescontrol()
	{
		var elH = document.createElement("div"); 
		elH.id = "myhirescontrol";
		elH.style.top ="188px"; 
		elH.style.left = "10px"; 
		elH.style.border = "1px solid white";
		elH.style.background = "rgb(241,247,247)";
		elH.style.width = "80";
		elH.style.padding = "1px";
	
elH.innerHTML = "<input type='radio' name='showhires' value='showhires' checked onclick='showhires(this.checked);'><a><font style='font-size:9pt' face ='Arial' color='rgb(70,70,70)'>High Res</font></a>"+
           "<br> <input type='radio' name='showhires' value='showDEM'  onclick='showDEM(this.checked);'><a><font style='font-size:9pt' face ='Arial' color='rgb(70,70,70)'>Topo</font></a>"+
           "<br> <input type='radio' name='showhires' value='shownone' onclick='shownoimages(this.checked);'><a><font style='font-size:9pt' face ='Arial' color='rgb(70,70,70)'>None</font></a>";

		map.AddControl(elH);
		addShimH(elH);
	}

	function addShimH(elH)
	{
		var shimH = document.createElement("iframe");
		shimH.id = "myShimH";
		shimH.frameBorder = "0";
		shimH.style.position = "absolute";
		shimH.style.zIndex = "1";
		shimH.style.top = elH.offsetTop;
		shimH.style.left = elH.offsetLeft;
		shimH.width = elH.offsetWidth;
		shimH.height = elH.offsetHeight;
		elH.shimElement = shimH;
		elH.parentNode.insertBefore(shimH, elH);
	}






//This function is called by default when people are loading anything on the map. It allows to toggle between Tiles.
function Addhirescontrol2D()
	{
		var elH2 = document.createElement("div"); 
		elH2.id = "myhirescontrol2";
		elH2.style.top ="235px"; 
		elH2.style.left = "13px"; 
		elH2.style.border = "1px solid white";
		elH2.style.background = "rgb(241,247,247)";
		elH2.style.width = "75";
		elH2.style.padding = "1px";
	
elH2.innerHTML = "<input type='radio' name='showhires' value='showhires' checked onclick='showhires(this.checked);'><a><font style='font-size:8pt' face ='Arial' color='rgb(70,70,70)'>High Res</font></a>"+
           "<br> <input type='radio' name='showhires' value='showDEM'  onclick='showDEM(this.checked);'><a><font style='font-size:8pt' face ='Arial' color='rgb(70,70,70)'>Topo</font></a>"+
           "<br> <input type='radio' name='showhires' value='shownone' onclick='shownoimages(this.checked);'><a><font style='font-size:8pt' face ='Arial' color='rgb(70,70,70)'>None</font></a>";

		map.AddControl(elH2);
		addShimH2(elH2);
	}
function addShimH2(elH2)
	{
		var shimH2 = document.createElement("iframe");
		shimH2.id = "myShimH2";
		shimH2.frameBorder = "0";
		shimH2.style.position = "absolute";
		shimH2.style.zIndex = "1";
		shimH2.style.top = elH2.offsetTop;
		shimH2.style.left = elH2.offsetLeft;
		shimH2.width = elH2.offsetWidth;
		shimH2.height = elH2.offsetHeight;
		elH2.shimElement = shimH2;
		elH2.parentNode.insertBefore(shimH2, elH2);
	}









//we have 3 times this type of function, this one calls the schools, the next ones, the parks, the landscapes and the federal parks



 function fnLoadCollection()
          {
	     map.ShowDashboard();					//unhides the VE dashboard
             map.SetMapMode(VEMapMode.Mode2D);  			//Set the mapmode in 2D
	     RemoveMyControl1();					//Removes ALL THE LEFT CUSTOM CONTROLS!
	     RemoveMyControl2();
	     RemoveMyControl3();
	     RemoveMyControl4();
	     if (imagery=="DEM")					//Deletes what ever tiles is being displayed
	     {
	        DeleteTileLayerDEM();
 	     }
	     if (imagery=="SPOT")
	     { 		   
  		DeleteTileLayer();    
	     }
	     map.DeleteAllPolylines();					//Removes the route on Logan
	     map.DeleteAllPushpins();					//Removes the pins on Logan
	     map.SetCenterAndZoom(new VELatLong(0,0), 2);		//Zooms to the center of the map at a world scale
	     map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);	//sets units in KM

	top.InfoFrame.document.getElementById('searchresults').innerHTML = "<center><b>Loading Collection...</b></center>";
                
                var veLayerSpec = new VELayerSpecification();
                veLayerSpec.Type = VELayerType.VECollection;
                veLayerSpec.ID = "MYLAYER";
                //you can specify any gif image in this next line
                veLayerSpec.IconUrl ="./Images/schoolspin2.gif";
                veLayerSpec.FnCallback = fnLayerLoaded;
                veLayerSpec.LayerSource = "2CBB476FC0FE167F!197"; //Schools
                      
                map.AddLayer(veLayerSpec);                            
          }
          
       

  function fnLayerLoaded(points)
          {
                top.InfoFrame.document.getElementById('searchresults').innerHTML = "<center>Loaded " + points.length + " Locations";
                var outline = "";
                var cnt=0;
                for (cnt=0;cnt < points.length; cnt++) {
                      //var lnk = "<a href='#' onclick='top.ShowFrame.NavigateCenter(" + 
                      var lnk = "<a href='javascript:top.ShowFrame.NavigateCenter(" +
                            points[cnt].LatLong.Latitude + "," + 
                            points[cnt].LatLong.Longitude + ")'>";
                      outline = outline + "<b>" + lnk + (cnt+1) + ". " + 
                            points[cnt].Title + "</a></b><br>" +
                            points[cnt].Details +  "<br><br>";

                }


 
                outline = outline + "";
                
                top.InfoFrame.document.getElementById('searchresults').innerHTML = outline;
          }
          
          function NavigateCenter(lat, long)
          {
		map.SetCenterAndZoom(new VELatLong(lat,long),13);
          }


////calling the ontario PARKS BELOW




 function fnLoadCollectionONT()
          {
	     map.ShowDashboard();
             map.SetMapMode(VEMapMode.Mode2D);  
	     RemoveMyControl1();
	     RemoveMyControl2();
	     RemoveMyControl3();
	     RemoveMyControl4();
	     if (imagery=="DEM")
	     {
	        DeleteTileLayerDEM();
 	     }
	     if (imagery=="SPOT")
	     { 		   
  		DeleteTileLayer();    
	     }
	     map.DeleteAllPolylines();
	     map.DeleteAllPushpins();
	     map.SetCenterAndZoom(new VELatLong(50,-85), 5);
	     map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);

           top.InfoFrame.document.getElementById('searchresultsONT').innerHTML = "<center><b>Loading Collection...</b></center>";
                
                var veLayerSpecONT = new VELayerSpecification();
                veLayerSpecONT.Type = VELayerType.VECollection;
                veLayerSpecONT.ID = "MYLAYERONT";
                //you can specify any gif image in this next line
                veLayerSpecONT.IconUrl ="./Images/ontarioparks.gif";
                veLayerSpecONT.FnCallback = fnLayerLoadedONT;
                veLayerSpecONT.LayerSource = "2CBB476FC0FE167F!490"; //Ontario Parks
                      
                map.AddLayer(veLayerSpecONT);                            
          }
          
       

  function fnLayerLoadedONT(points)
          {
                top.InfoFrame.document.getElementById('searchresultsONT').innerHTML = "<center>Loaded " + points.length + " Locations";
                var outline = "";
                var cnt=0;
                for (cnt=0;cnt < points.length; cnt++) {
                      //var lnk = "<a href='#' onclick='top.ShowFrame.NavigateCenterONT(" + 
                      var lnk = "<a href='javascript:top.ShowFrame.NavigateCenterONT(" +
                            points[cnt].LatLong.Latitude + "," + 
                            points[cnt].LatLong.Longitude + ")'>";
                      outline = outline + "<b>" + lnk + (cnt+1) + ". " + 
                            points[cnt].Title + "</a></b><br>" +
                            points[cnt].Details +  "<br><br>";

                }


 
                outline = outline + "";
                
                top.InfoFrame.document.getElementById('searchresultsONT').innerHTML = outline;
          }
          
          function NavigateCenterONT(lat, long)
          {
		map.SetCenterAndZoom(new VELatLong(lat,long),13);
          }


//calling the ontario landscapes

 function fnLoadCollectionLAND()
          {
	     map.ShowDashboard();
             map.SetMapMode(VEMapMode.Mode2D);  
	     RemoveMyControl1();
	     RemoveMyControl2();
	     RemoveMyControl3();
	     RemoveMyControl4();
	     if (imagery=="DEM")
	     {
	        DeleteTileLayerDEM();
 	     }
	     if (imagery=="SPOT")
	     { 		   
  		DeleteTileLayer();    
	     }
	     map.DeleteAllPolylines();
	     map.DeleteAllPushpins();
	     map.SetCenterAndZoom(new VELatLong(50,-85), 5);
	     map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);

             top.InfoFrame.document.getElementById('searchresultsLAND').innerHTML = "<center><b>Loading Collection...</b></center>";
                
                var veLayerSpecLAND = new VELayerSpecification();
                veLayerSpecLAND.Type = VELayerType.VECollection;
                veLayerSpecLAND.ID = "MYLAYERLAND";
                //you can specify any gif image in this next line
                veLayerSpecLAND.IconUrl ="./Images/ontario-landscapes.gif";
                veLayerSpecLAND.FnCallback = fnLayerLoadedLAND;
                veLayerSpecLAND.LayerSource = "2CBB476FC0FE167F!423"; //Ontario Landscapes
                      
                map.AddLayer(veLayerSpecLAND);                            
          }
          
       

  function fnLayerLoadedLAND(points)
          {
                top.InfoFrame.document.getElementById('searchresultsLAND').innerHTML = "<center>Loaded " + points.length + " Locations";
                var outline = "";
                var cnt=0;
                for (cnt=0;cnt < points.length; cnt++) {
                      //var lnk = "<a href='#' onclick='top.ShowFrame.NavigateCenterLAND(" + 
                      var lnk = "<a href='javascript:top.ShowFrame.NavigateCenterLAND(" +
                            points[cnt].LatLong.Latitude + "," + 
                            points[cnt].LatLong.Longitude + ")'>";
                      outline = outline + "<b>" + lnk + (cnt+1) + ". " + 
                            points[cnt].Title + "</a></b><br>" +
                            points[cnt].Details +  "<br><br>";

                }


 
                outline = outline + "";
                
                top.InfoFrame.document.getElementById('searchresultsLAND').innerHTML = outline;
          }
          
          function NavigateCenterLAND(lat, long)
          {
		map.SetCenterAndZoom(new VELatLong(lat,long),13);
          }






//calling the canadian parks

 function fnLoadCollectionPARK()
          {
	     map.ShowDashboard();
             map.SetMapMode(VEMapMode.Mode2D);  
	     RemoveMyControl1();
	     RemoveMyControl2();
	     RemoveMyControl3();
	     RemoveMyControl4();
	     if (imagery=="DEM")
	     {
	        DeleteTileLayerDEM();
 	     }
	     if (imagery=="SPOT")
	     { 		   
  		DeleteTileLayer();    
	     }
	     map.DeleteAllPolylines();
	     map.DeleteAllPushpins();
	     map.SetCenterAndZoom(new VELatLong(57,-95), 3);
	     map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);

             top.InfoFrame.document.getElementById('searchresultsPARK').innerHTML = "<center><b>Loading Collection...</b></center>";
                
                var veLayerSpecPARK = new VELayerSpecification();
                veLayerSpecPARK.Type = VELayerType.VECollection;
                veLayerSpecPARK.ID = "MYLAYERPARK";
                //you can specify any gif image in this next line
                veLayerSpecPARK.IconUrl ="./Images/canadaparks.gif";
                veLayerSpecPARK.FnCallback = fnLayerLoadedPARK;
                veLayerSpecPARK.LayerSource = "2CBB476FC0FE167F!445"; //Canadian Parks
                      
                map.AddLayer(veLayerSpecPARK);                            
          }
          
       

  function fnLayerLoadedPARK(points)
          {
                top.InfoFrame.document.getElementById('searchresultsPARK').innerHTML = "<center>Loaded " + points.length + " Locations";
                var outline = "";
                var cnt=0;
                for (cnt=0;cnt < points.length; cnt++) {
                      //var lnk = "<a href='#' onclick='top.ShowFrame.NavigateCenterPARK(" + 
                      var lnk = "<a href='javascript:top.ShowFrame.NavigateCenterPARK(" +
                            points[cnt].LatLong.Latitude + "," + 
                            points[cnt].LatLong.Longitude + ")'>";
                      outline = outline + "<b>" + lnk + (cnt+1) + ". " + 
                            points[cnt].Title + "</a></b><br>" +
                            points[cnt].Details +  "<br><br>";

                }


 
                outline = outline + "";
                
                top.InfoFrame.document.getElementById('searchresultsPARK').innerHTML = outline;
          }
          
          function NavigateCenterPARK(lat, long)
          {
		map.SetCenterAndZoom(new VELatLong(lat,long),13);
          }











function showhires(active)				//onclick action for the checkbox when we click the HIRES check box
		{
   		 if (active==true)
  		  {
			if (imagery =="DEM")
			{DeleteTileLayerDEM();}
			GetTiles();
 		   }
		else
 		   {

 		   }
			} 



function showDEM(active)				//onclick action for the checkbox when we click the TOPO check box
		{
   		 if (active==true)
  		  {
			if (imagery =="SPOT")
			{DeleteTileLayer();}
			GetTilesDEM();
                        
 		   }
 		//   if (active!=true)
 		//   {
 		//   DeleteTileLayerDEM();
 		//   }
			} 



function shownoimages(active)				//onclick action for the checkbox when we click the None check box
		{
   		 if (active==true)
  		  {
 		     if (imagery=="DEM")
			{
			   DeleteTileLayerDEM();
			   imagery=null;		//Important Reminder: Imagery checks to see which tile is loaded. We cannot delete a tile that is not loaded allready!
			}
		     if (imagery=="SPOT")
			{ 		   
  		           DeleteTileLayer();
     			   imagery=null;
			}
		  }
 		   else
 		   {

 		   }
			} 






function DeleteTileLayer()               //Deletes the SPOT Tiles.
         {
            map.DeleteLayer(layerid);
            map.DeleteTileSource("spot");
         } 


function DeleteTileLayerDEM()		//Deletes the DEM tiles.
         {
            map.DeleteLayer("2");
            map.DeleteTileSource("DEM");
         } 





function importXML(fileNAME)		//checks if the browser can load xml files, then loads the Fileis, assigned earlier.
{
	if (document.implementation && document.implementation.createDocument)
	{
		xmlDoc = document.implementation.createDocument("", "", null);
		xmlDoc.onload = getxmllatlon;
	}
	else if (window.ActiveXObject)
	{
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.onreadystatechange = function () {
			if (xmlDoc.readyState == 4) getxmllatlon()
		};
 	}
	else
	{
		alert('Your browser can\'t handle this script');
		return;
	}
	
 var filelocation = "./GeoRSS/";
 var filelocationall = filelocation + fileNAME;

	xmlDoc.load(filelocationall);				//loads the assigned xml file earlier and calls the getxmllatlon function.
}





function getxmllatlon()			//stores the x, y and gpstime of the first and last recorded position in the loaded xml file.
{

	var x = xmlDoc.getElementsByTagName('geo:point');    //get the lat lon child
	var gpstime = xmlDoc.getElementsByTagName('title');  //get the time stamps

	var newEl = document.createElement('TABLE');
	newEl.setAttribute('cellPadding',5);
	var tmp = document.createElement('TBODY');
	newEl.appendChild(tmp);
	var row = document.createElement('TR');


	for (j=0;j<x[0].childNodes.length;j++)
	{
		if (x[0].childNodes[j].nodeType != 1) continue;
		var container = document.createElement('TH');
		var theData = document.createTextNode(x[0].childNodes[j].nodeName);
		container.appendChild(theData);
		row.appendChild(container);
	}
	tmp.appendChild(row);
	for (i=0;i<1;i++)                 //x.length;i++)
	{
		var row = document.createElement('TR');
		for (j=0;j<x[i].childNodes.length;j++)
		{
			if (x[i].childNodes[j].nodeType != 1) continue;
 		    var container = document.createElement('TD');
			var theData = document.createTextNode(x[i].childNodes[j].firstChild.nodeValue);
			container.appendChild(theData);
			row.appendChild(container);

		}
		y1 = x[0].childNodes[0].firstChild.nodeValue; //x[0] to get the first lat lon of the file, which is the last lat lon of the DAY!
		x1 = x[0].childNodes[1].firstChild.nodeValue;

		y2 = x[x.length-1].childNodes[0].firstChild.nodeValue;  //x.length-1. To get the last lat lon of the file, which is the first lat lon of the DAY!
		x2 = x[x.length-1].childNodes[1].firstChild.nodeValue;

		//alert(x1 + ' ' + y1);
		//alert(x2 + ' ' + y2);
		//tmp.appendChild(row);


		gpstime1 = gpstime[1].childNodes[0].nodeValue;				//get last time stamp
		gpstime2 = gpstime[gpstime.length-1].childNodes[0].nodeValue;		//get the first time stampe

		AddPinfromXML();							//Adds the pins


	}

}



      function AddPinfromXML()
      { 
	
	var label1 = gpstime1 + '  Lat:' + y1 + '   Lon:' + x1;     //sets the label for the time stamp and lat lon
	var label2 = gpstime2 + '  Lat:' + y2 + '   Lon:' + x2;

         var pin = new VEPushpin(pinID, 
                    new VELatLong(y1, x1), 		//last lat lon of the day
                    './Images/canada-pin-end.gif', 	//change this gif for the end pin icon
                    'Last location of the day',		//title label
                    label1				//information label
                    );

		  map.AddPushpin(pin);
          pinID++;


         var pin = new VEPushpin(pinID, 
                    new VELatLong(y2, x2),  //first lat lon of the day
                    './Images/canada-pin-start.gif', 
                    'First location of the day',
                    label2
                    );

		  map.AddPushpin(pin);
          pinID++;
          
          

		var y3 = ((parseFloat(y1)+parseFloat(y2))/2);  //Get Y center of the points
		var x3 = ((parseFloat(x1)+parseFloat(x2))/2);  //Get X center of the points
                map.SetCenter(new VELatLong(y3,x3));           //Set center to the middle of the points
        } 
      



