	var request = null;

	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	request = getRequestObject();

	if (request == null) {
		alert("Can not create the Ajax request object!");
	}

	var newwin = false;
	function openInfo(dir, title, desc, type, length) {
		if (newwin) {
			newwin.close();
		}
		newwin = window.open('/WebMgmt/ywbase61b.nsf/DocName/greenways_' + dir + '_details', 'moreinfo', 'left=10,top=10,width=320,height=600,toolbar=no,status=no,scrollbars=yes,resizable=yes');
		newwin.focus();
	} // openInfo

	function openMap(dir, title) {
		if (newwin) {
			newwin.close();
		}
		if (dir == 'rr') {
			width = 875;
			height = 680;
		} else {
			width = 680;
			height = 875;
		}
		newwin = window.open('', 'map', 'left=20,top=20,width=' + (width+20) + ',toolbar=0,status=0,scrollbars=1,resizable=1');
		newwin.focus();
		newwin.document.write("<title>" + title + " Map</title>\n");
		newwin.document.write("<style>body { background-color:#000;color:#fff;margin:0;padding:0;top:0;left:0; }</style>\n");
		newwin.document.write("<center><strong>" + title + " Map</strong><br>\n");
		newwin.document.write("<img src='/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/" + dir + "_map.jpg' width='" + width + "' height='" + height + "' /></center>\n");
		newwin.document.close();
	} // openMap

	var currentID;
	function showPopup_OLD(id) {
		currentID = id;
		overlayGreenway(id, true);
		overlayGreenway_OFF();
		document.getElementById('details_div_content').innerHTML = "Loading...";
		request.open("GET", id + '.csv', true);
		request.onreadystatechange = updatePopupContent;
		request.send(null);
		document.getElementById('details_div').style.visibility = 'visible';
		return false;
	} // showPopup_OLD

	function showPopup(id) {
		currentID = id;
		overlayGreenway(id, true);
		overlayGreenway_OFF();

		document.getElementById('details_div1').style.visibility = 'hidden';
		document.getElementById('details_div2').style.visibility = 'hidden';
		document.getElementById('details_div3').style.visibility = 'hidden';
		document.getElementById('details_div4').style.visibility = 'hidden';
		document.getElementById('details_div5').style.visibility = 'hidden';

		document.getElementById('details_div' + id).style.visibility = 'visible';
	} // showPopup

	function updatePopupContent() {
		if (request.readyState == 4) {
			if (request.status == 200) {
				var text = request.responseText;
				var ary = text.split("|");
				var dir = ary[0];
				var title = ary[1];
				var desc = ary[2];

				var type = ary[3];
				var length = ary[4];

				document.getElementById('details_div_title').innerHTML = title;				

				var html = "";
				html += '<center><img style="margin-top:5px;" src="/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/' + dir + '/main.jpg" /></center>\n';
				html += '<div style="width:100%;margin:0px auto 0px auto;vertical-align:middle;">\n';

				html += '	<div style="clear:both;">\n';
				html += '		<a class="reverse" onclick="openInfo(\'' + dir + '\', \'' + title + '\', \'' + desc.replace(/'/g, "\\'") + '\', \'' + type + '\', \'' + length + '\');">more info</a>&nbsp;&nbsp;\n';
				html += '		<a class="reverse" onclick="openMap(\'' + dir + '\', \'' + title + '\');">map</a>\n';
				html += '	</div>\n';

				html += '	<div style="clear:both;">\n';
				html += '	<center>\n';

				html += '		<div style="float:right;text-align:center;">\n';
				html += '			<div style="position:relative;top:15px;cursor:pointer;"><a onmousedown="Scroll(\'desc_scrollable\',\'up\');" onmouseup="clearTimeout(scrolling);" onmouseout="clearTimeout(scrolling);"><img src="/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/ArrowUp.gif" width="23" height="13" /></a></div>\n';
				html += '			<div style="position:relative;top:150px;cursor:pointer;"><a onmousedown="Scroll(\'desc_scrollable\',\'down\');" onmouseup="clearTimeout(scrolling);" onmouseout="clearTimeout(scrolling);"><img src="/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/ArrowDown.gif" width="23" height="13" /></a></div>\n';
				html += '		</div>\n';

				html += '		<div id="desc_scrollable" style="background-color:#ffffff;height:200px;overflow:hidden;width:90%;text-align:left;">' + desc + '</div>\n';
				html += '	</center>\n';
				html += '	</div>\n';
				html += '</div>\n';	
				document.getElementById('details_div_content').innerHTML = html;	
			}
		}
	} // updatePopupContent
	var scrolling = false;
	function Scroll(what, dir) {
		var d = document.getElementById(what);
		var pos = d.scrollTop;
		var delta = 0;
		if (dir == 'down') {
			delta = 10;
		} else if (dir == 'up') {
			delta = -10;
		}
		if (delta != 0) {
			pos += delta;
			if (pos < 0) {
				pos = 0;
			} else if (pos > d.scrollTop.scrollHeight) {
				pos = d.scrollTop.scrollHeight;
			}
			d.scrollTop = pos;
		}
		scrolling = setTimeout("Scroll('" + what + "', '" + dir + "')", 100);
	} // Scroll

	function overlayGreenway(idx, selected) {
		var layer = '';
		var which = '';
		if (!selected) {
			which = '_green';
			layer = '';
		} else {
			which = '_yellow';
			layer = '_current';
		}
		var img = '';
		switch(Number(idx)) {
			case 1:
				img = 'greenway_map_lickrun' + which + '.png';
				break;
			case 2:
				img = 'greenway_map_roanokeriver' + which + '.png';
				break;
			case 3:
				img = 'greenway_map_murrayrun' + which + '.png';
				break;
			case 4:
				img = 'greenway_map_millmountain' + which + '.png';
				break;
			case 5:
				img = 'greenway_map_tinkercreek' + which + '.png';
		}
		var d = document.getElementById('mainMap_overlays' + layer);
		//d.style.background = 'url(/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/' + img + ') no-repeat';
		d.src = '/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/' + img;

		if ((version >= 5.5) && (document.body.filters)) {
			 var imgID = (d.id) ? "id='" + d.id + "' " : ""
		         var imgClass = (d.className) ? "class='" + d.className + "' " : ""
		         var imgTitle = (d.title) ? "title='" + d.title + "' " : "title='" + d.alt + "' "
		         var imgStyle = "display:inline-block;" + d.style.cssText 
		         if (d.align == "left") imgStyle = "float:left;" + imgStyle
		         if (d.align == "right") imgStyle = "float:right;" + imgStyle
		         if (d.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
		         var strNewHTML = "<span " + imgID + imgClass + imgTitle
		         + " style=\"" + "width:" + d.width + "px; height:" + d.height + "px;" + imgStyle + ";"
		         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		         + "(src=\'" + d.src + "\', sizingMethod='scale');\"></span>" 
		         d.outerHTML = strNewHTML
		}
	} // overlayGreenway

	function overlayGreenway_OFF() {
		var d = document.getElementById('mainMap_overlays');
		//d.style.background = 'url(/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/blank_1x1.gif) no-repeat';
		d.src = '/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/blank_1x1.gif';
	} // overlayGreenway_OFF
	function overlayGreenway_OFF2() {
		var d = document.getElementById('mainMap_overlays_current');
		d.src = '/85256A8D0062C8D5/vwFilesByName/GreenWaysSite/$File/blank_1x1.gif';
	} // overlayGreenway_OFF2
