﻿<!--
	var map = null;
	var shape;
	var latLong = null;

	function GetRegionMap()
	{
		map = new VEMap('RegionMap');
		map.LoadMap(new VELatLong(41.99852846935915,-87.86865234375003),9,'r',false);
		map.HideDashboard();

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(1, new VELatLong(41.95360,-88.05070), 
		'http://www.accesschannel.com/offices/images/pushpins/1.gif', 
		'Addison Public Access Center', 
		'5N301 Medinah Road<br>Addison, IL 60101');
		map.AddPushpin(pin);

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(2, new VELatLong(41.92009,-87.94550), 
		'http://www.accesschannel.com/offices/images/pushpins/2.gif', 
		'Elmhurst Public Access Center', 
		'688 Industrial Drive<br>Elmhurst, IL 60126');
		map.AddPushpin(pin);

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(3, new VELatLong(41.56752,-87.64650), 
		'http://www.accesschannel.com/offices/images/pushpins/3.gif', 
		'Homewood Public Access Center', 
		'17700 Hoffman Way<br>Homewood, IL 60430');
		map.AddPushpin(pin);

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(4, new VELatLong(42.07354,-87.90770), 
		'http://www.accesschannel.com/offices/images/pushpins/4.gif', 
		'Mt. Prospect Public Access Center', 
		'350 N. Wolf Road<br>Mt. Prospect, IL 60056');
		map.AddPushpin(pin);

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(5, new VELatLong(41.67176,-88.06894), 
		'http://www.accesschannel.com/offices/images/pushpins/5.gif', 
		'Romeoville Public Access Center', 
		'1304 Marquette Drive<br>Romeoville, IL 60446');
		map.AddPushpin(pin);

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(6, new VELatLong(42.05605,-87.73906), 
		'http://www.accesschannel.com/offices/images/pushpins/6.gif', 
		'Skokie Public Access Center', 
		'9651 Gross Point Road<br>Skokie, IL 60076');
		map.AddPushpin(pin);

		//Add a pushpin to the map - number pin
		var pin = new VEPushpin(7, new VELatLong(42.32890,-87.89505), 
		'http://www.accesschannel.com/offices/images/pushpins/7.gif', 
		'Waukegan Public Access Center', 
		'1585 Waukegan Road<br>Waukegan, IL 60085');
		map.AddPushpin(pin);
	}

	function GetOfficeMap(lat,lon)
	{
		map = new VEMap('OfficeMap');
		map.LoadMap(new VELatLong(lat,lon), 16, 'r', false);
		map.HideDashboard();

		//Add a pushpin to the map - star pin
		var pin = new VEPushpin(1, new VELatLong(lat,lon), 
		'http://www.accesschannel.com/offices/images/pushpins/star.gif');
		map.AddPushpin(pin);
	}

	//New function to display traffic
	function Traffic()
	{
		if (document.getElementById('traffic').checked)
		{
			map.LoadTraffic(true);
		}
		else
		{
			map.ClearTraffic();
		}
	}

	function GetRoute(lat,lon)
	{

		var point = document.getElementById('pointaddress').value;
		point += ", " + document.getElementById('pointcity').value;
		point += " " + document.getElementById('pointstate').value;
		point += " " + document.getElementById('pointzipcode').value;

		var options = new VERouteOptions;

		// Draw the route on the map
		options.DrawRoute = true;

		// Display the driving directions in the screen
		options.RouteCallback  = ShowTurns;

		map.GetDirections([point, new VELatLong(lat,lon)], options)
	}

	function ShowTurns(route)
	{
		var turns = "<h3>Turn-by-Turn Directions</h3>(rounding errors are possible)";

		turns += "<p><b>Distance:</b> " + route.Distance.toFixed(1) + " miles";
		turns += "<br/><b>Time:</b> " + GetTime(route.Time) + "</p>";

		// Unroll route and populate DIV
		var legs          = route.RouteLegs;
		var leg           = null;
		var turnNum       = 0;  // The turn #

		// Get intermediate legs
		for(var i = 0; i < legs.length; i++)
		{
			// Get this leg so we don't have to derefernce multiple times
			leg = legs[i];  // Leg is a VERouteLeg object

			var legNum = i + 1;

			//turns += "<br/><b>Distance for leg " + legNum + ":</b> " + leg.Distance.toFixed(1) + " miles" +
			//"<br/><b>Time for leg "     + legNum + ":</b> " + GetTime(leg.Time) + "<br/><br/>";

			// Unroll each intermediate leg
			var turn        = null;  // The itinerary leg
			var legDistance = null;  // The distance for this leg
                  
			for(var j = 0; j < leg.Itinerary.Items.length; j ++)
			{
				turnNum++;
                     
				turn = leg.Itinerary.Items[j];  // turn is a VERouteItineraryItem object

				turns += "<b>" + turnNum + "</b>\t" + turn.Text;

				legDistance    = turn.Distance;

				// So we don't show 0.0 for the arrival
				if(legDistance > 0)
				{
					// Round distances to 1/10ths
					turns += " (" + legDistance.toFixed(1) + " miles";

					// Append time if found
					if(turn.Time != null)
					{
						turns += "; " + GetTime(turn.Time);
					}

					turns += ")<br/>";
				}
			}

			turns += "<br/>";
		}

		// Populate DIV with directions
		SetDirections(turns);
	}

	function SetDirections(s)
	{
		var d = document.getElementById("directions");
		d.innerHTML = s;
	}

         // time is an integer representing seconds
         // returns a formatted string
         function GetTime(time)
         {
            if(time == null)
            {
               return("");
            }

            if(time > 60)
            {                                 // if time == 100
               var seconds = time % 60;       // seconds == 40
               var minutes = time - seconds;  // minutes == 60
               minutes     = minutes / 60;    // minutes == 1


               if(minutes > 60)
               {                                     // if minutes == 100
                  var minLeft = minutes % 60;        // minLeft    == 40
                  var hours   = minutes - minLeft;   // hours      == 60
                  hours       = hours / 60;          // hours      == 1

                  return(hours + " hour(s), " + minLeft + " minute(s), " + seconds + " second(s)");
               }
               else
               {
                  return(minutes + " minutes, " + seconds + " seconds");
               }
            }
            else
            {
               return(time + " seconds");
            }
         }

	function ClearAll()
	{
		map.DeleteRoute();
		SetDirections("");
	}
//-->