UO_APP = function (){}

var UOM;

var bladeNames = ["accessDiv","buildingsDiv","librariesDiv","parkingDiv","restaurantsDiv","atmDiv"];
var bladeTextNames = ["accessTextDiv","buildingsTextDiv","librariesTextDiv","parkingTextDiv","restaurantsTextDiv","atmTextDiv"];
var accessBlade = false;
var buildingsBlade = false;
var librariesBlade = false;
var parkingBlade = false;
var restaurantsBlade = false;
var atmBlade = false;
var startingPointDropdown = false;
var destinationDropdown = false;

function initialize(){
	UOM = new UO_APP;
	UOM.init();
}

UO_APP.prototype.getUrlParam = function (name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if(results == null) {
		return "";
	} else {
		return results[1];
	}
}

UO_APP.prototype.init = function (){
	this._map = new CustomMap('uo_map');
	
	this._campus = this.getUrlParam("campus");
	this._buildingId = this.getUrlParam("buildingId");
	this._poiCategory = this.getUrlParam("poiCategory");
	this._poiType = this.getUrlParam("poiType");
	this._poiId = this.getUrlParam("poiId");
	this._priority = this.getUrlParam("priority");
	
	this._map.initialize();
	
	this._heightOfOpenBlade = 100;
	this._heightOfClosedBlade = 34;
	this._maxHeightBuildingBlade = 194;
	this._maxHeightRestBlade = 169;
	this._maxHeightLibBlade = 164;

	//shortest path variables
	this._firstTime = true;
	this._adjacencyMatrix;
	this._shortestPoly = null;
	this._insidePolylines = new Array();
	//this._lightedPolylines = new Array();
	this._shortestPathThickness = 4;
	//this._lightedPathThickness = 10;
	this._graphNodes = new Array();
	//this._insidePathColor = "#228188";
	this._insidePathColor = "#22884e";
	this._shortestPathColor = "#ff8a00";
	//this._lightedPathColor = "#ffff00";
	this._routingAlgorithm = null;
	//walking speed in meters/minute 
	this._walkingSpeed = 85;
	this._directionsWindow = null;
	this._directionsMarkers = new Array();
	
	this._selBuildingId = -1;
	this._brooksBuildingId = -1;
	
	if (this._campus != "") {
		setTimeout("UOM.createTileOverlayParam()",500);
	} else {
		setTimeout("UOM.createTileOverlay()",500);
	}
	//Print function
	if (this.isIE()) {
		setTimeout("updatePrint()",1000);
	} else {
		if (e("tools-print")) {
			e("tools-print").href = "javascript:void(0);";
			e("tools-print").onclick = openPrintPage;
		}
	}
}

UO_APP.prototype.createTileOverlay = function(){
	this._map.createTileOverlay("main");
	this._map.createTileOverlay("lees");
}

UO_APP.prototype.createTileOverlayParam = function(){
	if (this._campus == "main") {
		this._map.createTileOverlay("main");
		this._map.createTileOverlay("lees");
	} else if (this._campus == "altaVista") {
		this._map.createTileOverlay("altaVista");
	} else if (this._campus == "mba") {
		this._map.createTileOverlay("mba");
	}
}

UO_APP.prototype.showBuildingMarkers = function (){
	this._map.showBuildingMarkers('');
}

UO_APP.prototype.toggleBlade = function (el,el2,openBlade){
	if(el.style.height == openBlade+"px"){
		this.collapse(el);
		el2.style.background="url(images/blade_closed_new.gif)";
	}else{
		this.collapseAll();
		this.expand(el,openBlade);
		el2.style.background="url(images/blade_open_new.gif)";
	}
	
}

UO_APP.prototype.expand = function (el,openBlade){
	new Effect.Morph(el,
	{style:'height: '+openBlade+'px;',
		duration:0.5});
}

UO_APP.prototype.collapse = function (el){
		new Effect.Morph(el,
		       {style:'height: '+this._heightOfClosedBlade+'px;',
			duration:0.5});
}

UO_APP.prototype.collapseAll = function (){
	for (var i = 0; i < bladeTextNames.length; i++) {
		e(bladeTextNames[i]).style.background="url(images/blade_closed_new.gif)";
	}
	for (var i = 0; i < bladeNames.length; i++) {
		new Effect.Morph(e(bladeNames[i]),
			       {style:'height: '+this._heightOfClosedBlade+'px;',
				duration:0.5});	
	}
}

UO_APP.prototype.changeCheckboxIcon = function (el) {
	if (el.src.indexOf("unchecked") == -1) {
		el.src = "images/button_unchecked.png";
	} else {
		el.src = "images/button_checked.png";
	}
}

UO_APP.prototype.changeClass = function (el,mouseOver,className){
	if (this.isIE6()) return;
	if (mouseOver) {
		el.className = el.className + " " + className;
	} else {
		if (el.className.indexOf(className)==-1) {
			el.className = "";
		} else {
			el.className = className;
		}
	}
}

UO_APP.prototype.changeBuildingsClass = function (el,click,className){
	if (click) {
		el.className = className;
	} else {
		if (el.className != "uo_buildings_table_click") {
			el.className = className;
		}
	}
}

UO_APP.prototype.changeClassName = function (el,defaultClass,className) {
	if (el.className == defaultClass) {
		el.className = el.className + " " + className;
	} else {
		el.className = defaultClass;
	}
}

UO_APP.prototype.toggleEntrances = function (map,type) {
	map.toggleEntrances(type);
}

UO_APP.prototype.toggleRestaurants = function (map,code){
	map.toggleRestaurants(code);
}

UO_APP.prototype.toggleLibraries = function (map,index) {
	map.toggleLibraries(index);
}

UO_APP.prototype.toggleAtm = function (map,id) {
	map.toggleAtm(id);
}

UO_APP.prototype.toggleParking = function (map,type) {
	map.toggleParking(type);
}

UO_APP.prototype.toggleAccess = function (map,type) {
	map.toggleAccess(type);
	if (type == "overpass") {
		UOM.changeCheckboxIcon(e("overpassCheck"));
	}
}

UO_APP.prototype.toggleOverpass = function (map) {
	map.toggleAccess("overpass");
	this.populateAccessBlade(getCampus(),false);
	UOM.changeClassName(e("overpassDiv"), "uo_filter_blade_poi uo_buildings_table_bottom_border", "uo_filter_blade_poi_bold");
}

UO_APP.prototype.showShuttleLees = function (type,direction) {
	if (!this._map.showShuttleLees(type,direction)) {
		this.populateAccessBlade(getCampus(),false);
		UOM.changeClassName(e("shuttleBusDiv"), "uo_filter_blade_poi uo_buildings_table_bottom_border", "uo_filter_blade_poi_bold");
	}
}

UO_APP.prototype.openBuildingInfoWindow = function (map,i){
	if (e("radioValue").value=="codes") {
		map.openBuildingInfoWindow(i,"buildingCodes");
	} else {
		map.openBuildingInfoWindow(i,"buildingNames");
	}
}

UO_APP.prototype.hideMarkers = function (map,type) {
	map.hideMarkers(type);
}

UO_APP.prototype.clearPoi = function (map,campus){
	// Close info window
	map.gmap.closeInfoWindow();
	// Center map on campus
	map.setCenter(campus);
	// Hide markers (except buildings)
	map.hideAllMarkers(false);
	// Collapse and populate blades
	this.collapseAll();
	accessBlade = false;
	buildingsBlade = false;
	librariesBlade = false;
	restaurantsBlade = false;
	parkingBlade = false;
	atmBlade = false;
	this.clearBlade(e("accessDiv"),"accessTextDiv","Access");
	this.clearBlade(e("buildingsDiv"),"buildingsTextDiv","Buildings");
	this.clearBlade(e("librariesDiv"),"librariesTextDiv","Libraries and Computer Labs");
	this.clearBlade(e("parkingDiv"),"parkingTextDiv","Parking");
	this.clearBlade(e("restaurantsDiv"),"restaurantsTextDiv","Restaurants");
	this.clearBlade(e("atmDiv"),"atmTextDiv","ATM");
	// Show building markers for that campus
	//this.changeBuildings(map,"codes");
	// Change checkbox icons
	e("wheelchairCheck").src = "images/button_unchecked.png";
	e("overpassCheck").src = "images/button_unchecked.png";
	e("entrancesCheck").src = "images/button_unchecked.png";
}

UO_APP.prototype.clearDirections = function (){
	if (this._shortestPoly != null) {
		this._map.gmap.removeOverlay(this._shortestPoly);
		this._shortestPoly = null;
		this._map.setCenter(getCampus());
		//if (this._directionsWindow != null) {
			//this._directionsWindow.hide();
		//}
		for (var i = 0; i < this._directionsMarkers.length; i++) {
			this._directionsMarkers[i].hide();
		}
		this._directionsMarkers = new Array();
		e("uo_path_distance").innerHTML = "";
		this._map.showBuildingMarkers(e("radioValue").value);
		e("uo_start_location").selectedIndex = 0;
		e("uo_end_location").selectedIndex = 0;
		this._map.shortestPolyArray = new Array();
		this._map.insidePolyArray = new Array();
	}
	for (var i = 0; i < this._insidePolylines.length; i++) {
		this._map.gmap.removeOverlay(this._insidePolylines[i]);
	}
	this._insidePolylines = new Array();
//	for (var i = 0; i < this._lightedPolylines.length; i++) {
//		this._map.gmap.removeOverlay(this._lightedPolylines[i]);
//	}
//	this._lightedPolylines = new Array();
}

//UO_APP.prototype.toggleLightedPath = function (el){
//	alert('Lighted Pathway currently unavailable');
//	this.changeCheckboxIcon(el);
//	//return;
//	if (el.src.indexOf("unchecked") == -1) {
//		//show
//		for (var i = 0; i < this._lightedPolylines.length; i++) {
//			this._lightedPolylines[i].show();
//		}
//	} else {
//		//hide
//		for (var i = 0; i < this._lightedPolylines.length; i++) {
//			this._lightedPolylines[i].hide();
//		}
//	}
//}

UO_APP.prototype.changeBuildings = function (map,value) {
	if (value=="codes") {
		map.hideMarkers("buildingNames");
		map.showBuildingMarkers(value);
		e("codesRadio").src = "images/radio_checked.png";
		e("namesRadio").src = "images/radio_unchecked.png";
		e("radioValue").value = "codes";
	} else {
		map.hideMarkers("buildingCodes");
		map.showBuildingMarkers(value);
		e("namesRadio").src = "images/radio_checked.png";
		e("codesRadio").src = "images/radio_unchecked.png";
		e("radioValue").value = "names";
	}
}

UO_APP.prototype.changeRouting = function (map,value,fromInfo) {
	if (e("routingValue").value == value) return;
	if (value=="shortest") {
		e("shortestRadio").src = "images/radio_checked.png";
		e("warmestRadio").src = "images/radio_unchecked.png";
		e("routingValue").value = "shortest";
	} else {
		e("warmestRadio").src = "images/radio_checked.png";
		e("shortestRadio").src = "images/radio_unchecked.png";
		e("routingValue").value = "warmest";
	}
	if (this._shortestPoly != null && !fromInfo) {
		this.getShortestRouteBetweenBuildings(e('uo_start_location').options[e('uo_start_location').selectedIndex].value,e('uo_end_location').options[e('uo_end_location').selectedIndex].value,value);
	}
}

UO_APP.prototype.showBuildingCodes = function () {
	e("codesRadio").src = "images/radio_checked.png";
	e("namesRadio").src = "images/radio_unchecked.png";
	e("radioValue").value = "codes";
	this._map.showBuildingMarkers("codes");
}

UO_APP.prototype.changeCampus = function(map,newCampus,oldCampusEl) {
	map.gmap.closeInfoWindow();
	// Center map on campus
	map.setCenter(newCampus);
	// Show tiles for new campus
	if (map.tileLayers[newCampus].length > 0) {
		var overlay = map.tileLayers[newCampus][0];
		overlay.show();
		if (newCampus == "main") {
			overlay = map.tileLayers["lees"][0];
			overlay.show();
		}
	} else {
		map.createTileOverlay(newCampus);
		if (newCampus == "main") {
			map.createTileOverlay("lees");
		}
	}
	// Hide tiles for old campus
	(map.tileLayers[oldCampusEl.value][0]).hide();
	if (oldCampusEl.value == "main") {
		(map.tileLayers["lees"][0]).hide();
	}
	// Hide markers
	map.hideAllMarkers(true);
	if (newCampus == "main") {
		map.showPaths();
	} else {
		map.hidePaths();
	}
	// Collapse and populate blades
	this.collapseAll();
	accessBlade = false;
	buildingsBlade = false;
	librariesBlade = false;
	restaurantsBlade = false;
	parkingBlade = false;
	atmBlade = false;
	this.clearBlade(e("accessDiv"),"accessTextDiv","Access");
	this.clearBlade(e("buildingsDiv"),"buildingsTextDiv","Buildings");
	this.clearBlade(e("librariesDiv"),"librariesTextDiv","Libraries and Computer Labs");
	this.clearBlade(e("parkingDiv"),"parkingTextDiv","Parking");
	this.clearBlade(e("restaurantsDiv"),"restaurantsTextDiv","Restaurants");
	this.clearBlade(e("atmDiv"),"atmTextDiv","ATM");
	startingPointDropdown = false;
	destinationDropdown = false;
	// Show building markers for that campus
	this.showBuildingCodes();
	// Change checkbox icons
	e("wheelchairCheck").src = "images/button_unchecked.png";
	e("overpassCheck").src = "images/button_unchecked.png";
	e("entrancesCheck").src = "images/button_unchecked.png";
	// Set the oldCampus
	oldCampusEl.value = newCampus;
	if (this._shortestPoly != null) {
		map.gmap.removeOverlay(this._shortestPoly);
		for (var i = 0; i < this._directionsMarkers.length; i++) {
			this._directionsMarkers[i].hide();
		}
		this._directionsMarkers = new Array();
		e("uo_path_distance").innerHTML = "";
		this._shortestPoly = null;
		for (var i = 0; i < this._insidePolylines.length; i++) {
			this._map.gmap.removeOverlay(this._insidePolylines[i]);
		}
		this._insidePolylines = new Array();
//		for (var i = 0; i < this._lightedPolylines.length; i++) {
//			this._map.gmap.removeOverlay(this._lightedPolylines[i]);
//		}
//		this._lightedPolylines = new Array();
		this._map.shortestPolyArray = new Array();
		this._map.insidePolyArray = new Array();
	}
	e("uo_start_location").selectedIndex = 0;
	e("uo_end_location").selectedIndex = 0;
}

UO_APP.prototype.clearBlade = function(blade,bladeTextId,bladeText) {
	var children = blade, child;
	while(child=children.firstChild) {
	    children.removeChild(child);
	}
	blade.innerHTML = "<div id='"+bladeTextId+"' class='uo_filter_blade_text'>"+bladeText+"</div>";
}

UO_APP.prototype.populateAccessBlade = function(campus,isExpand) {
	if (!accessBlade) {
		var mainDiv = e("accessDiv");
		var children = mainDiv, child;
		while(child=children.firstChild) {
		    children.removeChild(child);
		}
		var count = 0;
		var openBlade = this._heightOfClosedBlade;
		var accessTypes = new Array();
		for (var i in ACCESS) {
			for (var j = 0; j < ACCESS[i].length ; j++) {
				if (ACCESS[i][j].campus == campus) {
					count++;
					if (count%2 == 1) {
						openBlade += 26;
					}
					accessTypes.push(i);
					break;
				}
			}
		}
		var html = "<div id='accessTextDiv' class='uo_filter_blade_text' onmousedown='UOM.toggleBlade(e(\"accessDiv\"),this,"+(count>0?openBlade:openBlade+26)+");'>Access</div><div class='uo_filter_blade_pois'>";
		if (count > 0) {
			for (var i = 0; i < accessTypes.length; i++) {
				html += "<div id='"+accessTypes[i]+"Div' class='uo_filter_blade_poi uo_buildings_table_bottom_border' onmousedown='UOM.toggleAccess(UOM._map, \""+accessTypes[i]+"\");UOM.changeClassName(this, \"uo_filter_blade_poi uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\""+accessTypes[i]+"Span\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\""+accessTypes[i]+"Span\"),false,\"uo_filter_blade_poi_bold\");'>" +
						" <div class='uo_blade_img_div'><img src='"+ACCESS_ICON_MAP[accessTypes[i]]+"' width='20px' height='20px' /></div>" +
						" <div class='uo_blade_span_div'><span id='"+accessTypes[i]+"Span' class=''>"+ACCESS_DESC_MAP[accessTypes[i]]+"</span></div>" +
						"</div>";
	    	}
		} else {
			html += "<div class='uo_empty_blade'>No points of interest of this type</div>";
		}
		html += "</div>";
		mainDiv.innerHTML = html;
		accessBlade = true;
		if (isExpand) {
			UOM.toggleBlade(mainDiv,e("accessTextDiv"),count>0?openBlade:openBlade+26);
		}
	}
}

UO_APP.prototype.populateBuildingsBlade = function(campus) {
	if (!buildingsBlade) {
		var mainDiv = e("buildingsDiv");
		var children = mainDiv, child;
		while(child=children.firstChild) {
		    children.removeChild(child);
		}
		var count = 0;
		var openBlade = this._heightOfClosedBlade;
		for (var i = 0; i < BUILDINGS.length ; i++) {
			if (BUILDINGS[i].campus == campus) {
				count++;
				if (openBlade < this._maxHeightBuildingBlade) {
					openBlade += 20;
				}
			}
		}
		var textDiv = document.createElement("div");
		textDiv.id = "buildingsTextDiv";
		textDiv.className = "uo_filter_blade_text";
		if (count > 0) {
			textDiv.onclick = function (evt) { UOM.toggleBlade(mainDiv,textDiv,openBlade); };
		}
		var text = document.createTextNode("Buildings");
		textDiv.appendChild(text);
		mainDiv.appendChild(textDiv);
	    var div = document.createElement("div");
	    div.className = "uo_buildings_blade";
	    var table = document.createElement("table");
	    table.id = "buildingsTable";
	    table.style.width = "100%";
	    table.cellSpacing = "0px";
	    div.appendChild(table);
		//var table = e("buildingsTable");
		var tableBody = document.createElement("tbody");
	    //var rows = table.rows; 
	    //while(rows.length) {
	        //table.deleteRow(rows.length-1);
	    //}
		for (var i = 0; i < BUILDINGS.length ; i++) {
			if (BUILDINGS[i].campus == campus && BUILDINGS[i].show) {
				if (UOM.isIE()) {
					var tr = document.createElement('<tr onclick="UOM.openBuildingInfoWindow(UOM._map,'+i+');UOM.changeBuildingsClass(this, true, \'uo_buildings_table_click\');">');
				} else {
					var tr = document.createElement("tr");
					tr.setAttribute("onclick", "UOM.openBuildingInfoWindow(UOM._map,"+i+");UOM.changeBuildingsClass(this, true, 'uo_buildings_table_click');");
				}
				tr.onmouseover = function (evt) { UOM.changeBuildingsClass(this, false, 'uo_buildings_table_mo');};
				tr.onmouseout = function (evt) { UOM.changeBuildingsClass(this, false, '');};
				tableBody.appendChild(tr);
				var td = document.createElement("td");
				td.width = "275px";
				td.className = "uo_buildings_table_bottom_border uo_buildings_table uo_bold_font";
				tr.appendChild(td);
				var text = document.createTextNode(BUILDINGS[i].name);
				td.appendChild(text);
				td = document.createElement("td");
				td.width = "100px";
				td.className = "uo_buildings_table_bottom_border uo_buildings_table";
				tr.appendChild(td);
				text = document.createTextNode(BUILDINGS[i].code);
				td.appendChild(text);
			}
		}
		table.appendChild(tableBody);
		mainDiv.appendChild(div);
		buildingsBlade = true;
		UOM.toggleBlade(mainDiv,textDiv,openBlade);
	}
}

UO_APP.prototype.populateLibrariesBlade = function(campus) {
	if (!librariesBlade) {
		var mainDiv = e("librariesDiv");
		var children = mainDiv, child;
		while(child=children.firstChild) {
		    children.removeChild(child);
		}
		var count = 0;
		var openBlade = this._heightOfClosedBlade;
		for (var i = 0; i < LIBRARIES.length ; i++) {
			if (LIBRARIES[i].campus == campus) {
				count++;
				if (openBlade < this._maxHeightLibBlade) {
					openBlade += 26;
				}
			}
		}
		var html = "<div id='librariesTextDiv' class='uo_filter_blade_text' onmousedown='UOM.toggleBlade(e(\"librariesDiv\"),this,"+(count>0?openBlade:openBlade+26)+");'>Libraries and Computer Labs</div><div class='uo_filter_blade_pois uo_filter_blade_lib_scroll'>";
		if (count > 0) {
			for (var i = 0; i < LIBRARIES.length; i++) {
				if (LIBRARIES[i].campus == campus) {
					if (LIBRARIES[i].abbreviation) {
						var name = LIBRARIES[i].abbreviation;
					} else {
						var name = LIBRARIES[i].name;
					}
					html += "<div id='"+LIBRARIES[i].id+"Div' class='uo_filter_blade_poi_lib uo_buildings_table_bottom_border' onmousedown='UOM.toggleLibraries(UOM._map, \""+i+"\");UOM.changeClassName(this, \"uo_filter_blade_poi_lib uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\""+LIBRARIES[i].id+"Span\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\""+LIBRARIES[i].id+"Span\"),false,\"uo_filter_blade_poi_bold\");'>" +
							" <div class='uo_blade_img_div'><img src='"+LIBRARIES[i].icon+"' width='20px' height='20px' /></div>" +
							" <div class='uo_blade_span_div_lib'><span id='"+LIBRARIES[i].id+"Span' class=''>"+name+"</span></div>" +
							"</div>";
					if (LIBRARIES[i].isLastLibrary) {
						html += "<div id='allLibrariesDiv' class='uo_filter_blade_poi_lib uo_buildings_table_bottom_border' onmousedown='UOM._map.toggleAllLibraries();UOM.changeClassName(this, \"uo_filter_blade_poi_lib uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\"allLibrariesSpan\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\"allLibrariesSpan\"),false,\"uo_filter_blade_poi_bold\");'>" +
								" <div class='uo_blade_img_div'><img src='images/icons/icon_library.png' width='20px' height='20px' /></div>" +
								" <div class='uo_blade_span_div_lib'><span id='allLibrariesSpan' class=''>Display All Libraries</span></div>" +
								"</div>";
					}
					if (LIBRARIES[i].isLastComputerLab) {
						html += "<div id='allComputersDiv' class='uo_filter_blade_poi_lib uo_buildings_table_bottom_border' onmousedown='UOM._map.toggleAllComputerLabs();UOM.changeClassName(this, \"uo_filter_blade_poi_lib uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\"allComputersSpan\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\"allComputersSpan\"),false,\"uo_filter_blade_poi_bold\");'>" +
								" <div class='uo_blade_img_div'><img src='images/icons/icon_computer_lab.png' width='20px' height='20px' /></div>" +
								" <div class='uo_blade_span_div_lib'><span id='allComputersSpan' class=''>Display All Computer Labs</span></div>" +
								"</div>";
					}
				}
	    	}
			
		} else {
			html += "<div class='uo_empty_blade'>No points of interest of this type</div>";
		}
		html += "</div>";
		mainDiv.innerHTML = html;
		librariesBlade = true;
		UOM.toggleBlade(mainDiv,e("librariesTextDiv"),count>0?openBlade:openBlade+26);
	}
}

UO_APP.prototype.populateParkingBlade = function(campus) {
	if (!parkingBlade) {
		var mainDiv = e("parkingDiv");
		var children = mainDiv, child;
		while(child=children.firstChild) {
		    children.removeChild(child);
		}
		var count = 0;
		var openBlade = this._heightOfClosedBlade;
		var parkingTypes = new Array();
		for (var i in PARKING) {
			for (var j = 0; j < PARKING[i].length; j++) {
				if (PARKING[i][j].campus == campus) {
					count++;
					if (count%2 == 1) {
						openBlade += 26;
					}
					parkingTypes.push(i);
					break;
				}
			}
		}
		var html = "<div id='parkingTextDiv' class='uo_filter_blade_text' onmousedown='UOM.toggleBlade(e(\"parkingDiv\"),this,"+(count>0?openBlade:openBlade+26)+");'>Parking</div><div class='uo_filter_blade_pois'>";
		if (count > 0) {
			for (var i = 0; i < parkingTypes.length; i++) {
				html += "<div id='"+parkingTypes[i]+"Div' class='uo_filter_blade_poi uo_buildings_table_bottom_border' onmousedown='UOM.toggleParking(UOM._map, \""+parkingTypes[i]+"\");UOM.changeClassName(this, \"uo_filter_blade_poi uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\""+parkingTypes[i]+"Span\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\""+parkingTypes[i]+"Span\"),false,\"uo_filter_blade_poi_bold\");'>" +
						" <div class='uo_blade_img_div'><img src='"+PARKING_ICON_MAP[parkingTypes[i]]+"' width='20px' height='20px' /></div>" +
						" <div class='uo_blade_span_div'><span id='"+parkingTypes[i]+"Span' class=''>"+PARKING_DESC_MAP[parkingTypes[i]]+"</span></div>" +
						"</div>";
	    	}
		} else {
			html += "<div class='uo_empty_blade'>No points of interest of this type</div>";
		}
		html += "</div>";
		mainDiv.innerHTML = html;
		parkingBlade = true;
		UOM.toggleBlade(mainDiv,e("parkingTextDiv"),count>0?openBlade:openBlade+26);
	}
}

UO_APP.prototype.populateRestaurantsBlade = function(campus) {
	if (!restaurantsBlade) {
		var mainDiv = e("restaurantsDiv");
		var children = mainDiv, child;
		while(child=children.firstChild) {
		    children.removeChild(child);
		}
		var count = 0;
		var openBlade = this._heightOfClosedBlade;
		for (var i = 0; i < RESTAURANTS.length ; i++) {
			if (RESTAURANTS[i].show && RESTAURANTS[i].campus == campus) {
				count++;
				if (count%2 == 1 && openBlade < this._maxHeightRestBlade) {
					openBlade += 27;
				}
			}
		}
		var html = "<div id='restaurantsTextDiv' class='uo_filter_blade_text' onmousedown='UOM.toggleBlade(e(\"restaurantsDiv\"),this,"+(count>0?openBlade:openBlade+26)+");'>Restaurants</div><div class='uo_filter_blade_pois uo_filter_blade_rest_scroll'>";
		if (count > 0) {
			for (var i = 0; i < RESTAURANTS.length; i++) {
				if (RESTAURANTS[i].show && RESTAURANTS[i].campus == campus) {
					html += "<div class='uo_filter_blade_poi_scroll uo_buildings_table_bottom_border' onmousedown='UOM.toggleRestaurants(UOM._map, \""+RESTAURANTS[i].code+"\");'>" +
							" <img src='images/icons/"+RESTAURANTS[i].icon+".png' height='20px' title='"+RESTAURANTS[i].name+"' />" +
							"</div>";
				}
	    	}
		} else {
			html += "<div class='uo_empty_blade'>No points of interest of this type</div>";
		}
		html += "</div>";
		mainDiv.innerHTML = html;
		restaurantsBlade = true;
		UOM.toggleBlade(mainDiv,e("restaurantsTextDiv"),count>0?openBlade:openBlade+26);
	}
}

UO_APP.prototype.populateAtmBlade = function(campus) {
	if (!atmBlade) {
		var mainDiv = e("atmDiv");
		var children = mainDiv, child;
		while(child=children.firstChild) {
		    children.removeChild(child);
		}
		var count = 0;
		var openBlade = this._heightOfClosedBlade;
		for (var i = 0; i < ATM.length ; i++) {
			if (ATM[i].show && ATM[i].campus == campus) {
				count++;
				if (count%2 == 1) {
					openBlade += 26;
				}
			}
		}
		if ((count > 0) && ((count+1)%2 == 1)) {
			openBlade += 26;
		}
		var html = "<div id='atmTextDiv' class='uo_filter_blade_text' onmousedown='UOM.toggleBlade(e(\"atmDiv\"),this,"+(count>0?openBlade:openBlade+26)+");'>ATM</div><div class='uo_filter_blade_pois'>";
		if (count > 0) {
			for (var i = 0; i < ATM.length; i++) {
				if (ATM[i].show && ATM[i].campus == campus) {
					html += "<div id='"+ATM[i].id+"Div' class='uo_filter_blade_poi uo_buildings_table_bottom_border' onmousedown='UOM.toggleAtm(UOM._map, \""+ATM[i].id+"\");UOM.changeClassName(this, \"uo_filter_blade_poi uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\""+ATM[i].id+"Span\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\""+ATM[i].id+"Span\"),false,\"uo_filter_blade_poi_bold\");'>" +
							" <div class='uo_blade_img_div'><img src='"+ATM_ICON+"' width='20px' height='20px' /></div>" +
							" <div class='uo_blade_span_div'><span id='"+ATM[i].id+"Span' class=''>"+ATM[i].desc+"</span></div>" +
							"</div>";
				}
	    	}
			html += "<div id='allAtmDiv' class='uo_filter_blade_poi uo_buildings_table_bottom_border' onmousedown='UOM._map.toggleAllAtm();UOM.changeClassName(this, \"uo_filter_blade_poi uo_buildings_table_bottom_border\", \"uo_filter_blade_poi_bold\");' onmouseover='UOM.changeClass(e(\"allAtmSpan\"),true,\"uo_filter_blade_poi_underline\");' onmouseout='UOM.changeClass(e(\"allAtmSpan\"),false,\"uo_filter_blade_poi_bold\");'>" +
					" <div class='uo_blade_img_div'><img src='images/icons/icon_atm.png' width='20px' height='20px' /></div>" +
					" <div class='uo_blade_span_div'><span id='allAtmSpan' class=''>Display All ATMs</span></div>" +
					"</div>";
		} else {
			html += "<div class='uo_empty_blade'>No points of interest of this type</div>";
		}
		html += "</div>";
		mainDiv.innerHTML = html;
		atmBlade = true;
		UOM.toggleBlade(mainDiv,e("atmTextDiv"),count>0?openBlade:openBlade+26);
	}
}

UO_APP.prototype.buildAdjacencyMatrix = function (){
	//the names vector will have indexes 0-POINTS.length for the points
	//and indexes POINTS.length+1 - POINTS.length+DOORS.length+1 for the doors
	
	//first we get all the points
	//POINTS is defined in PATHS.js
	//these are all the points that make up all possible path segments
	for(var p in POINTS){
		this._graphNodes.push(p);
	}

	//then we get all the doors
	//doors are defined in ENTRANCES.js

	for(var d in ENTRANCES){
		this._graphNodes.push(d);
	}


	this._adjacencyMatrix= new Array(this._graphNodes.length);

	//initialize the matrix
	for(var i=0; i < this._graphNodes.length; i++){
		this._adjacencyMatrix[i] = new Array(this._graphNodes.length);
		for (var j=0; j < this._graphNodes.length; j++){
			if(i==j){
				this._adjacencyMatrix[i][j] = 0;
			}else{
				this._adjacencyMatrix[i][j] = this._routingAlgorithm.infinite;
			}
		}
	}


	//build the matrix
	for(var s in SEGMENTS){
		var startPoint = SEGMENTS[s][0];
		var endPoint = SEGMENTS[s][1];
		var distance = SEGMENTS[s][2];
		var isWarmest = false;
		if (SEGMENTS[s][3]) {
			isWarmest = SEGMENTS[s][3];
		}
		var isCentral = false;
		if (SEGMENTS[s][4]) {
			isCentral = SEGMENTS[s][4];
		}
//		var isLighted = false;
//		if (SEGMENTS[s][5]) {
//			isLighted = SEGMENTS[s][5];
//		}
		
		if(startPoint == undefined || endPoint == undefined || distance == undefined){
			continue;
		}
		var indexOfStartPoint = this._graphNodes.indexOf(startPoint);
		var indexOfEndPoint = this._graphNodes.indexOf(endPoint);

		//the matrix again will have the first POINTS.length columns for the point nodes
		//and the rest of the columns after that for the door nodes
		this._adjacencyMatrix[indexOfStartPoint][indexOfEndPoint] = [distance,isWarmest,isCentral];
		this._adjacencyMatrix[indexOfEndPoint][indexOfStartPoint] = [distance,isWarmest,isCentral];
	}
}

UO_APP.prototype.getRouteFromInfo = function (bd1, bd2){
	var routingType = "";
	for (var i = 0; i < document.getElementsByName("routing").length; i++) {
		if (document.getElementsByName("routing")[i].checked) {
			routingType = document.getElementsByName("routing")[i].value;
		}
	}
	if (e("isBrooks")) {
		bd1 = this._brooksBuildingId;
	}
	if (e("fromToOption").value == "to") {
		var startBuildingId = bd2;
		var endBuildingId = bd1;
	} else {
		var startBuildingId = bd1;
		var endBuildingId = bd2;
	}
	this._map.gmap.closeInfoWindow();
	this.setDirectionSelects(startBuildingId, endBuildingId);
	this.changeRouting(null,routingType,true);
	this.getShortestRouteBetweenBuildings(startBuildingId, endBuildingId, routingType);
}

UO_APP.prototype.getShortestRouteBetweenBuildings = function (startBuildingId, endBuildingId, routingType){
	if (startBuildingId == "select") {
		alert("Please, select a starting point");
		return;
	}
	if (endBuildingId == "select") {
		alert("Please, select a destination");
		return;
	}
	if (startBuildingId == endBuildingId) {
		alert("Starting point should be different than destination");
		return;
	}
	//Test for Brooks Residence
	if (startBuildingId == "address") {
		alert("Please, select the address of the starting point building");
		return;
	}
	if (endBuildingId == "address") {
		alert("Please, select the address of the destination building");
		return;
	}
	if(startBuildingId == "60" && routingType == "warmest") {
		alert("For warmest route, use the Shuttle Service");
		if(this._shortestPoly != null){
			this._map.gmap.removeOverlay(this._shortestPoly);
			for (var i = 0; i < this._directionsMarkers.length; i++) {
				this._directionsMarkers[i].hide();
			}
			this._directionsMarkers = new Array();
		}
		for (var i = 0; i < this._insidePolylines.length; i++) {
			this._map.gmap.removeOverlay(this._insidePolylines[i]);
		}
		this._insidePolylines = new Array();
		this._map.shortestPolyArray = new Array();
		this._map.insidePolyArray = new Array();
		e("uo_path_distance").innerHTML = "";
		this._map.showBuildingMarkers(e("radioValue").value);
		this.showShuttleLees("shuttleBus","from");
		return;
	}
	if(endBuildingId == "60" && routingType == "warmest") {
		alert("For warmest route, use the Shuttle Service");
		if(this._shortestPoly != null){
			this._map.gmap.removeOverlay(this._shortestPoly);
			for (var i = 0; i < this._directionsMarkers.length; i++) {
				this._directionsMarkers[i].hide();
			}
			this._directionsMarkers = new Array();
		}
		for (var i = 0; i < this._insidePolylines.length; i++) {
			this._map.gmap.removeOverlay(this._insidePolylines[i]);
		}
		this._insidePolylines = new Array();
		this._map.shortestPolyArray = new Array();
		this._map.insidePolyArray = new Array();
		e("uo_path_distance").innerHTML = "";
		this._map.showBuildingMarkers(e("radioValue").value);
		this.showShuttleLees("shuttleBus","to");
		return;
	}
	if (this._firstTime) {
		this._routingAlgorithm = new RoutingAlgorithm();
		//initialize the shortest path components
		this.buildAdjacencyMatrix();
		this._routingAlgorithm.init(this._adjacencyMatrix, this._graphNodes);
		this._firstTime = false;
	}
	//get the doors for both buildings
	var startDoorsArr = BUILDINGS2DOORS[startBuildingId.toString()];
	var endDoorsArr = BUILDINGS2DOORS[endBuildingId.toString()];

	var addDistance = 0;
	var shortestPath = null;
	var insidePathArr = new Array();
	
	var isWarmest = routingType == "warmest";
	
	for(startDoor in startDoorsArr){
		for(endDoor in endDoorsArr){
			//get indices of both node
			s = startDoorsArr[startDoor];
			
			end = endDoorsArr[endDoor];
			startIndex = this._graphNodes.indexOf(s);
			endIndex = this._graphNodes.indexOf(end);
			
			var thisRoute = this.calculateShortestPath(startIndex, endIndex, isWarmest);
			if(thisRoute.addDistance != null && thisRoute.path != null){
				//if(weightedDistance == null || thisRoute.distance < weightedDistance){
				addDistance = thisRoute.addDistance;
				shortestPath = thisRoute.path;
				insidePathArr = thisRoute.insidePath;
				//lightedPathArr = thisRoute.lightedPath;
				//}
			}
		}
	}
	if(shortestPath == null){
		alert("No path was found between these buildings");
		return;
	}
	
		//draw the path
		var pathArr = shortestPath.split(",");
		var startCoord = null;
		var endCoord = null;
		var shortestPoly = new Array();
		//draw lighted path
//		for(var ixp = 0; ixp < lightedPathArr.length; ixp++){
//			var lightedPoly = new Array();
//			//is it a door node?
//			var isDoor = false;
//			var isPoint = false;
//			isDoor = lightedPathArr[ixp][0].indexOf("d")!=-1;
//			isPoint = lightedPathArr[ixp][0].indexOf("p")!=-1;
//			if(isDoor && !isPoint){
//				lightedPoly.push(new GLatLng(ENTRANCES[lightedPathArr[ixp][0]].lat, ENTRANCES[lightedPathArr[ixp][0]].lng));
//			}else{
//				lightedPoly.push(new GLatLng(POINTS[lightedPathArr[ixp][0]].lat, POINTS[lightedPathArr[ixp][0]].lng));
//			}
//			var isDoor = false;
//			var isPoint = false;
//			var thisPoint = null;
//			isDoor = lightedPathArr[ixp][1].indexOf("d")!=-1;
//			isPoint = lightedPathArr[ixp][1].indexOf("p")!=-1;
//			if(isDoor && !isPoint){
//				lightedPoly.push(new GLatLng(ENTRANCES[lightedPathArr[ixp][1]].lat, ENTRANCES[lightedPathArr[ixp][1]].lng));
//			}else{
//				lightedPoly.push(new GLatLng(POINTS[lightedPathArr[ixp][1]].lat, POINTS[lightedPathArr[ixp][1]].lng));
//			}
//			var lightedPolyline = new GPolyline(lightedPoly, this._lightedPathColor, this._lightedPathThickness, 0.5, null);
//			this._lightedPolylines.push(lightedPolyline);
//			this._map.gmap.addOverlay(lightedPolyline);
//			if (e("lightedPathCheck").src.indexOf("unchecked") != -1) {
//				lightedPolyline.hide();
//			}
//		}
		
		if (pathArr[0].indexOf("p")!=-1) {
			pathArr.splice(0,1);
		}
		if (pathArr[pathArr.length-1].indexOf("p")!=-1) {
			pathArr.splice(pathArr.length-1,1);
		}
		for(var ixp = 0; ixp < pathArr.length; ixp++){
			//is it a door node?
			var isDoor = false;
			var isPoint = false;
			var thisPoint = null;
			//isDoor = pathArr[ixp][0] == "d";
			//isPoint = pathArr[ixp][0] == "p";
			isDoor = pathArr[ixp].indexOf("d")!=-1;
			isPoint = pathArr[ixp].indexOf("p")!=-1;
				
			if(isDoor && !isPoint){
				//it is a door
				thisPoint = new GLatLng(ENTRANCES[pathArr[ixp]].lat, ENTRANCES[pathArr[ixp]].lng);
				shortestPoly.push(thisPoint);
			}else{
				//it is a point
				thisPoint = new GLatLng(POINTS[pathArr[ixp]].lat, POINTS[pathArr[ixp]].lng);
				shortestPoly.push(thisPoint);
			}

			if(ixp == 0){//starting door
				startCoord = thisPoint;
				this.plotDirectionMarker(thisPoint, true, "Starting Point");
			}else if(ixp == pathArr.length - 1){//ending door
				endCoord = thisPoint;
				this.plotDirectionMarker(thisPoint, false, "Destination");
			}
		}
		
		this._map.shortestPolyArray=shortestPoly;

		this._shortestPoly= new GPolyline(shortestPoly, this._shortestPathColor, this._shortestPathThickness, 1, null);
		this._map.gmap.addOverlay(this._shortestPoly);
		
		//draw inside path
		for(var ixp = 0; ixp < insidePathArr.length; ixp++){
			var insidePoly = new Array();
			//is it a door node?
			var isDoor = false;
			var isPoint = false;
			isDoor = insidePathArr[ixp][0].indexOf("d")!=-1;
			isPoint = insidePathArr[ixp][0].indexOf("p")!=-1;
			if(isDoor && !isPoint){
				insidePoly.push(new GLatLng(ENTRANCES[insidePathArr[ixp][0]].lat, ENTRANCES[insidePathArr[ixp][0]].lng));
			}else{
				insidePoly.push(new GLatLng(POINTS[insidePathArr[ixp][0]].lat, POINTS[insidePathArr[ixp][0]].lng));
			}
			var isDoor = false;
			var isPoint = false;
			var thisPoint = null;
			isDoor = insidePathArr[ixp][1].indexOf("d")!=-1;
			isPoint = insidePathArr[ixp][1].indexOf("p")!=-1;
			if(isDoor && !isPoint){
				insidePoly.push(new GLatLng(ENTRANCES[insidePathArr[ixp][1]].lat, ENTRANCES[insidePathArr[ixp][1]].lng));
			}else{
				insidePoly.push(new GLatLng(POINTS[insidePathArr[ixp][1]].lat, POINTS[insidePathArr[ixp][1]].lng));
			}
			this._map.insidePolyArray.push(insidePoly);
			var insidePolyline = new GPolyline(insidePoly, this._insidePathColor, this._shortestPathThickness, 1, null);
			//warningPolyline.warning = insidePathArr[ixp][2];
			this._insidePolylines.push(insidePolyline);
//			GEvent.addListener(warningPolyline, "click", function(latlng){
//				var html = "<b>Warning</b><br><br>"+this.warning;
//				UOM._map.gmap.openInfoWindowHtml(latlng, html);
//			});
			this._map.gmap.addOverlay(insidePolyline);
		}
	
		var shortestDistance = this._shortestPoly.getLength();
		//var shortestTime = shortestDistance / this._walkingSpeed;
		//Need to consider distance walked inside buildings
//		shortestTime = (shortestDistance + addDistance) / this._walkingSpeed;
		
		shortestDistance = shortestDistance.toFixed(0);
//		shortestTime = shortestTime.toFixed(0);
//		if (shortestTime == 0) {
//			var timeText = "less than 1 minute";
//		} else {
//			var timeText = "about "+shortestTime+" minutes";
//		}
//		e("uo_path_distance").innerHTML = "It will take you "+timeText+" walking to get there ("+shortestDistance+"m)";
		
		e("uo_path_distance").innerHTML = "You are about "+shortestDistance+"m from your destination";
		/*var distanceHTML = "<table border='0' cellpadding='1' cellspacing='1'><tr><td width='100%' nowrap>&nbsp;<a href='javascript:UOM._directionsWindow.hide()'>" +
						   "<img width='12' height='12' title='Close' src='images/close.gif' border='0' style='position:absolute;right:4px;top:4px'>" +
						   "</a></td></tr><tr><td nowrap><h4>It will take you about <span class='uo_filterName'> " + Math.round(shortestTime) + " minutes </span> to get there ("+shortestDistance+"m)</h4></td></tr></table>";*/
//		var distanceHTML = "<table cellpadding='1' cellspacing='1'><tr><td width='100%' nowrap>&nbsp;<a href='javascript:UOM._directionsWindow.hide()'>" +
//		   				   "<img width='12' height='12' title='Close' src='images/eclose.gif' border='0' style='position:absolute;right:4px;top:4px'></a></td></tr>" +
//		   				   "<tr><td nowrap><b>Distance to destination: "+shortestDistance+"m</b></td></tr>" +
//		   				   "<tr><td nowrap><b>Approximate walking time: "+Math.round(shortestTime)+" minutes</b></td></tr></table>";
		//var distanceHTML = "<h3>It will take you around <span class='uo_filterName'> " + shortestTime + " minutes </span> to get there ("+shortestDistance+"m)</h3>";
		//create a boundary box using the start and end points
		var pathBoundingBox = new GLatLngBounds();
		pathBoundingBox.extend(startCoord);
		pathBoundingBox.extend(endCoord);
		var boundingBoxCenter = pathBoundingBox.getCenter();
		var boundingBoxZoom = this._map.gmap.getBoundsZoomLevel(pathBoundingBox);
		
		//set the map to this new center/zoom levels
		this._map.gmap.setCenter(boundingBoxCenter, boundingBoxZoom);
		
		this._map.hideBuildingMarkers(startBuildingId,endBuildingId);
		
//		if (this._directionsWindow != null) {
//			this._directionsWindow.hide();
//		}
//		this._map.gmap.closeInfoWindow();
//	    
//	    this._directionsWindow = new EWindow(this._map.gmap, new EStyle("", new GSize(24,24), "uo_direction_form", new GPoint(0,0)));      
//	    this._map.gmap.addOverlay(this._directionsWindow);
//	    this._directionsWindow.openOnMap(boundingBoxCenter,distanceHTML,new GPoint(140,110));
		//this._map.gmap.openInfoWindowHtml(boundingBoxCenter, distanceHTML);
}

UO_APP.prototype.calculateShortestPath = function(from, to, isWarmest){
		if(this._shortestPoly != null){
			this._map.gmap.removeOverlay(this._shortestPoly);
			for (var i = 0; i < this._directionsMarkers.length; i++) {
				this._directionsMarkers[i].hide();
			}
			this._directionsMarkers = new Array();
		}
		for (var i = 0; i < this._insidePolylines.length; i++) {
			this._map.gmap.removeOverlay(this._insidePolylines[i]);
		}
		this._insidePolylines = new Array();
		this._map.shortestPolyArray = new Array();
		this._map.insidePolyArray = new Array();
//		for (var i = 0; i < this._lightedPolylines.length; i++) {
//			this._map.gmap.removeOverlay(this._lightedPolylines[i]);
//		}
//		this._lightedPolylines = new Array();
		var r = this._routingAlgorithm.shortestPath(this._adjacencyMatrix.length,from,to,isWarmest);
		
		return r;
}

UO_APP.prototype.plotDirectionMarker = function(point, starting, title){
	var icon = new GIcon(G_DEFAULT_ICON, starting?"images/icons/icon_starting.png":"images/icons/icon_destination.png");
	var marker = new GMarker(point, {icon:icon});
	this._directionsMarkers.push(marker);
	this._map.gmap.addOverlay(marker);
}

UO_APP.prototype.populateStartingPointDropdown = function(value) {
	if (!startingPointDropdown) {		
		var select = e("uo_start_location");
		select.length = 0;
		var option = document.createElement("option");
		option.value = "select";
		var text = document.createTextNode("Select Starting Point");
		option.appendChild(text);
		select.appendChild(option);
		for (var i = 0; i < BUILDINGS.length; i++) {
			if (BUILDINGS[i].campus == value) {
				if (BUILDINGS[i].isHeader) {
					option = document.createElement("option");
					//Test for Brooks Residence
					if (BUILDINGS[i].ident) {
						option.value = "address";
					} else {
						option.value = BUILDINGS[i].id;
					}
					text = document.createTextNode(BUILDINGS[i].name);
					option.appendChild(text);
					select.appendChild(option);
				} 
				if (BUILDINGS[i].ident) {
					option = document.createElement("option");
					option.value = BUILDINGS[i].id;
					text = document.createTextNode("\xa0\xa0\xa0\xa0\xa0-\xa0");
					option.appendChild(text);
					text = document.createTextNode(BUILDINGS[i].address);
					option.appendChild(text);
					select.appendChild(option);
				}
			}
	    }
		startingPointDropdown = true;
	}
}

UO_APP.prototype.populateDestinationDropdown = function(value) {
	if (!destinationDropdown) {
		select = e("uo_end_location");
		select.length = 0;
		option = document.createElement("option");
		option.value = "select";
		text = document.createTextNode("Select Destination");
		option.appendChild(text);
		select.appendChild(option);
		for (var i = 0; i < BUILDINGS.length; i++) {
			if (BUILDINGS[i].campus == value) {
				if (BUILDINGS[i].isHeader) {
					option = document.createElement("option");
					//Test for Brooks Residence
					if (BUILDINGS[i].ident) {
						option.value = "address";
					} else {
						option.value = BUILDINGS[i].id;
					}
					text = document.createTextNode(BUILDINGS[i].name);
					option.appendChild(text);
					select.appendChild(option);
				} 
				if (BUILDINGS[i].ident) {
					option = document.createElement("option");
					option.value = BUILDINGS[i].id;
					text = document.createTextNode("\xa0\xa0\xa0\xa0\xa0-\xa0");
					option.appendChild(text);
					text = document.createTextNode(BUILDINGS[i].address);
					option.appendChild(text);
					select.appendChild(option);
				}
			}
	    }
		destinationDropdown = true;
	}
}

UO_APP.prototype.isIE = function (){
	if (navigator.userAgent.indexOf("MSIE") > 0 ) {
		return true;
	} else {
		return false;
	}
}

UO_APP.prototype.isIE6 = function (){
	// Internet Explorer 6
	var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	//exactly Internet Explorer 7
	//var IE7 = false /*@cc_on || @_jscript_version == 5.7 @*/;
	// at least Internet Explorer 7
	//var gteIE7 = false /*@cc_on || @_jscript_version >= 5.7 @*/;
	// any Internet Explorer (thanks to Dean)
	//var isMSIE = /*@cc_on!@*/false;
	return IE6;
}

UO_APP.prototype.initAjaxAutocompleter = function () {
	new Ajax.Autocompleter("autoCompleteTextField", "autoCompleteMenu", "response.html", {afterUpdateElement: UOM.getSelectionId});
}

UO_APP.prototype.initAutocompleter = function () {
	new Autocompleter.Local(
        'autoCompleteTextField',
        'autoCompleteMenu',
        this._map.buildings.buildingNamesArray(),
        {fullSearch:true,afterUpdateElement:UOM.getSelectionId,choices:4});
}

UO_APP.prototype.initBrooksAutocompleter = function () {
	new Autocompleter.Local(
        'brooksTextField',
        'brooksAutoComplete',
        this._map.buildings.brooksAddressesArray(),
        {fullSearch:true,afterUpdateElement:UOM.getBrooksSelectionId,choices:4});
}

UO_APP.prototype.getSelectionId = function (text, li) {
	UOM._selBuildingId = li.id;
}

UO_APP.prototype.getBrooksSelectionId = function (text, li) {
	UOM._brooksBuildingId = li.id;
}

UO_APP.prototype.setDirectionSelects = function (startingPointId,destinationId) {
	UOM.populateStartingPointDropdown("main");
	UOM.populateDestinationDropdown("main");
	for(i = 0; i < e('uo_end_location').options.length; i++) {
    	if(e('uo_end_location').options[i].value == destinationId) {		
    		e('uo_end_location').selectedIndex = i;
    	}
    }
	for(i = 0; i < e('uo_start_location').options.length; i++) {
    	if(e('uo_start_location').options[i].value == startingPointId) {		
    		e('uo_start_location').selectedIndex = i;
    	}
    }
}
