	var map = null;
	var pinID = 1;
	var findcontrol = false;
	var layerid=1;
	var zoom=11;
	var lattotal=0;
	var lontotal=0;
	var destination;

	var maplocation1 = new Array();
	maplocation1["lat"]=47.20025;
	maplocation1["lon"]=-120.9876;
	maplocation1["title"]="Suncadia Resort";
	maplocation1["desc"]="<img src=\"images/interior/map-inset.jpg\" alt=\"\" align=\"left\" style=\"margin-right:10px;\" />Suncadia Resort <br />3600 Suncadia Trail<br />Cle Elum, WA 98922";
	var maplocations=new Array(maplocation1);

	function GetMap() {
		map = new VEMap('map');
		map.LoadMap(new VELatLong( ( maplocation1["lat"] ), ( maplocation1["lon"] ) ), zoom ,'r' , false);

		for ( var i = 0; i < maplocations.length; i++) {
			var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(maplocations[i]["lat"], maplocations[i]["lon"]));
			shape.SetTitle(maplocations[i]["title"]);
			shape.SetDescription(maplocations[i]["desc"]);
			pinID++;
			map.AddShape(shape);
			lattotal += maplocations[i]["lat"];
			lontotal += maplocations[i]["lon"];
		}
		latavg = lattotal/maplocations.length;
		lonavg = lontotal/maplocations.length;
		map.SetCenter( new VELatLong( ( latavg ), ( lonavg ) ), zoom );
	}

	$(function() {
		//$('div#routefinder').hide();
		$('div#directions').hide();
		if (BrowserDetect.browser != "Opera") {
			GetMap();
		} else {
			$('div#map').html('<img src="images/interior/map.gif" alt="" />');	
		}

		$("form#route-form").submit(function() { 
			if (document.getElementById('txtStart').value == '3600 Suncadia Trail Cle Elum, WA 98922') {
				var startadd = new VELatLong(47.20025, -120.9876);
				var endadd = document.getElementById('txtEnd').value;
			} else if ( document.getElementById('txtEnd').value == '3600 Suncadia Trail Cle Elum, WA 98922' ) {
				var startadd = document.getElementById('txtStart').value;
				var endadd = new VELatLong(47.20025, -120.9876);
			}

			map.GetRoute(startadd,endadd,null,VERouteType.Quickest,onGotRoute); 
			return false;
		});
	});


	// Gets Directions when clicked from Info box
	function toDirections(direction){
		document.getElementById("directions").style.display = "block";
		document.getElementById("routefinder").style.display = "block";
		if (direction == 'to') { 
			document.getElementById('txtEnd').value = "3600 Suncadia Trail Cle Elum, WA 98922"; 
		} else {
			document.getElementById('txtStart').value = "3600 Suncadia Trail Cle Elum, WA 98922"; 
		}
	}
	
		
	// Displays the directions on the Page
	function onGotRoute(route) {
	   var routeinfo="<div class='driving-directions' style='position:relative;'><h4>Driving Directions</h4>";
	   routeinfo += "<p><strong>Route info:</strong><br />";
	   routeinfo += "<strong>Total distance:</strong>";
	   routeinfo += route.Itinerary.Distance+" ";
	   routeinfo += route.Itinerary.DistanceUnit+"<br />";
	
	   var steps="";
	   var stepsemail="Driving Directions%0D%0A";
	   var len = route.Itinerary.Segments.length;
	   for(var i = 0; i<len ;i++) {
		  if ((i == 0) && (route.Itinerary.Segments[i].LatLong =='47.20025, -120.9876') ) {
			  steps+='Depart Suncadia<br />';
		  } else if ((i > 0) && (route.Itinerary.Segments[i].LatLong =='47.20025, -120.9876') ) {
			  steps+='Arrive at Suncadia';
			  stepsemail+='Arrive at Suncadia';
		  } else {		  
			  steps+=route.Itinerary.Segments[i].Instruction+" -- (";
			  stepsemail+=route.Itinerary.Segments[i].Instruction+" -- (";
			  steps+=route.Itinerary.Segments[i].Distance+") ";
			  stepsemail+=route.Itinerary.Segments[i].Distance+") ";
			  steps+=route.Itinerary.DistanceUnit+"<br />";
			  stepsemail+=route.Itinerary.DistanceUnit+"%0D%0A";
		  }
		}
	   routeinfo += "<strong>Steps:</strong><br />"+steps;
	   routeinfo += "</p>";
	   routeinfo += "<span class='direction-function' style='position:absolute;top:30px;right:30px;font-size:1.2em;'><a href=\"javascript:print()\">Print</a></div>";
	   
	   if (destination == undefined) { destination = ""; }
	   //document.getElementById('directions'+destination).innerHTML += routeinfo;
	   
	   $('div#routefinder').show();
	   $('#directions').show().html(routeinfo);
	}
	
	
