// JavaScript Document

function showDirections() {
	
	var tabDirections, tabSearch, tabInterestPoints
	tabDirections = $("tabDirections");
	tabSearch = $("tabSearch");
	tabInterestPoints = $("tabInterestPoints");
	
	var dirResults, searchResults, interestResults
	dirResults = $("direction_results");
	searchResults = $("search_results");
	interestResults = $("interest_list");
	
	tabDirections.blur();
	
	tabDirections.className = "selected";
	tabSearch.className = "";
	tabInterestPoints.className = "";
	
	dirResults.style.display = "block";
	searchResults.style.display = "none";
	interestResults.style.display = "none";
	
}

function showSearch() {
	
	var tabDirections, tabSearch, tabInterestPoints
	tabDirections = $("tabDirections");
	tabSearch = $("tabSearch");
	tabInterestPoints = $("tabInterestPoints");
	
	var dirResults, searchResults, interestResults
	dirResults = $("direction_results");
	searchResults = $("search_results");
	interestResults = $("interest_list");
	
	tabSearch.blur();
	
	tabDirections.className = "";
	tabSearch.className = "selected";
	tabInterestPoints.className = "";
	
	dirResults.style.display = "none";
	searchResults.style.display = "block";
	interestResults.style.display = "none";
	
}

function showInterestPoints() {
	
	var tabDirections, tabSearch, tabInterestPoints
	tabDirections = $("tabDirections");
	tabSearch = $("tabSearch");
	tabInterestPoints = $("tabInterestPoints");
	
	var dirResults, searchResults, interestResults
	dirResults = $("direction_results");
	searchResults = $("search_results");
	interestResults = $("interest_list");
	
	tabInterestPoints.blur();
	
	tabDirections.className = "";
	tabSearch.className = "";
	tabInterestPoints.className = "selected";
	
	dirResults.style.display = "none";
	searchResults.style.display = "none";
	interestResults.style.display = "block";
	
}

function switchDirections() {
	
	var toBox, fromBox;
	toBox = $("txtTo");
	fromBox = $("txtFrom")
	
	var currTo = toBox.value;
	var currFrom = fromBox.value;
	
	toBox.value = currFrom;
	fromBox.value = currTo;
	
	
}

function printDirections() {
	
	var directionsPanel = $("direction_results_list");
	var htmlContent = directionsPanel.innerHTML;
	
	if (htmlContent !== "") {
		
		OpenWindow=window.open("", "newwin", "height=550, width=550,toolbars=no,scrollbars=yes,menubar=false,resizable=true");
		OpenWindow.document.write("<link href='styles.css' type='text/css' rel='stylesheet' /><body id='printbody' onload='window.print();'>" + htmlContent + "</body>")
		OpenWindow.document.close();
	
		self.name="main";
		
	}
	else {
		alert("No directions listed to print.");	
	}
	
}

function enlargeMap() {
	
	var theMap = $("map_canvas");
	var theMapContainer = $("mapContainer");
	var enlargeButton = $("enlargeMap");
	var shrinkButton = $("shrinkMap");
	
	var pageWidth = document.viewport.getWidth();
	var totalMargin = pageWidth - 940;
	var singleMargin = totalMargin / 2;
	
	enlargeButton.hide();
	shrinkButton.show();
	
	theMap.style.width = "550px";
	theMap.style.height = "600px";
	
	theMapContainer.className = "largeMap";
	theMapContainer.style.left = singleMargin + "px";
	theMapContainer.style.right = singleMargin + "px";
	
}

function shrinkMap() {
	
	var theMap = $("map_canvas");
	var theMapContainer = $("mapContainer");
	var enlargeButton = $("enlargeMap");
	var shrinkButton = $("shrinkMap");
	
	enlargeButton.show();
	shrinkButton.hide();

	theMap.style.width = "";
	theMap.style.height = "";
	
	theMapContainer.className = "";
	theMapContainer.style.left = "";
	theMapContainer.style.right = "";
	
}
