var LIBRARIES = [];
LIBRARIES[0]={id: "archives", name: "Archives & Special Collections", lat: 45.423260, lng: -75.684106, icon: "images/icons/icon_library.png", campus: "main", location: "MRT (Level 0 - Room 039)", address: "65 University Private", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=archives&c=home", isLibrary: true};
LIBRARIES[1]={id: "law", name: "Brian Dickson Law Library", lat: 45.423975, lng: -75.682465, icon: "images/icons/shadow_Law_library_32.png", campus: "main", location: "FTX (4th Floor)", address: "57 Louis Pasteur", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=ftx&c=home", isLibrary: true};
LIBRARIES[2]={id: "gsg", name: "GSG - Geographic, Statistical and Government Information", abbreviation: "GSG - Geographic, Statistical and Government...",lat: 45.423087, lng: -75.684267, icon: "images/icons/icon_library.png", campus: "main", location: "MRT (3rd Floor)", address: "65 University Private", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=gsg&c=home", isLibrary: true};
LIBRARIES[3]={id: "sciences", name: "Health Science Library", lat: 45.402654, lng: -75.650589, icon: "images/icons/shadow_Health_library_32.png", campus: "altaVista", location: "RGN (Room 1020)", address: "451 Smyth Road", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=rgn&c=home", isLibrary: true};
LIBRARIES[4]={id: "annex", name: "Library Annex", lat: 45.423196, lng: -75.683892, icon: "images/icons/icon_library.png", campus: "main", location: "Off-Site Storage Facility", address: "65 University Private", link: "http://www.biblio.uottawa.ca/content-page.php?g=en&s=biblio&c=faq-annex", isLibrary: true};
LIBRARIES[5]={id: "management", name: "Management Library", lat: 45.423832, lng: -75.687218, icon: "images/icons/icon_library.png", campus: "main", location: "DMS (Room 2141)", address: "55 Laurier Avenue East", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=dms&c=home", isLibrary: true};
LIBRARIES[6]={id: "mediaResources", name: "Media Resources", lat: 45.422913, lng: -75.683967, icon: "images/icons/icon_library.png", campus: "main", location: "MRT (1st Floor)", address: "65 University Private", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=media&c=home", isLibrary: true};
LIBRARIES[7]={id: "morisset", name: "Morisset Library - Arts & Science", lat: 45.423267, lng: -75.684332, icon: "images/icons/icon_Moriset_library_32.png", campus: "main", location: "MRT", address: "65 University Private", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=mrt&c=home", isLibrary: true};
LIBRARIES[8]={id: "music", name: "Music Library", lat: 45.423840, lng: -75.684589, icon: "images/icons/icon_Music_library_32.png", campus: "main", location: "PRZ (3rd Floor)", address: "50 University Private", link: "http://www.biblio.uottawa.ca/section-home.php?g=en&s=prz&c=home", isLibrary: true, isLastLibrary: true};
LIBRARIES[9]={id: "ccsComputerLab", name: "CCS Computer Lab", lat: 45.422386, lng: -75.683076, icon: "images/icons/icon_computer_lab.png", campus: "main", location: "MNT (Main level - Room 140)", address: "125 University Private", link: "http://www.ccs.uottawa.ca/students/labs/#mnt", isComputerLab: true};
LIBRARIES[10]={id: "mrtComputerLabF", name: "Morisset Library - First Floor", lat: 45.423057, lng: -75.684117, icon: "images/icons/icon_computer_lab.png", campus: "main", location: "Morisset Library (First Floor)", address: "65 University Private", link: "http://www.ccs.uottawa.ca/students/labs/#mrst", isComputerLab: true};
LIBRARIES[11]={id: "mrtComputerLabT", name: "Morisset Library - Third Floor", lat: 45.423094, lng: -75.683935, icon: "images/icons/icon_computer_lab.png", campus: "main", location: "Morisset Library (Third Floor)", address: "65 University Private", link: "http://www.ccs.uottawa.ca/students/labs/#mrst", isComputerLab: true};
LIBRARIES[12]={id: "thnComputerLab", name: "Thompson Training Center", lat: 45.423749, lng: -75.683087, icon: "images/icons/icon_computer_lab.png", campus: "main", location: "Thompson (Room 054)", address: "35 University Private", link: "http://web9.uottawa.ca/services/sic-ccs/formation-training/Training/static/tr-centre.asp", isComputerLab: true, isLastComputerLab: true};

UOLIBRARIES = function (){
}

UOLIBRARIES.prototype.plotLibrary = function(map,i,index,forTool){
	var icon = new GIcon();
	icon.iconSize = new GSize(20,20);
	icon.iconAnchor = new GPoint(20,20);
	icon.infoWindowAnchor = new GPoint(20,20);
	icon.image = LIBRARIES[i].icon;
	var point = new GLatLng(LIBRARIES[i].lat, LIBRARIES[i].lng);
	var markerOpts = {icon: icon, clickable: forTool?false:true, hide: index==i?false:true, draggable: forTool?true:false};
	var marker = new GMarker(point, markerOpts);
	if (!forTool) {
		GEvent.addListener(marker, "click", function() {
			var html = "<div style='height:80px;'><b>"+LIBRARIES[i].name+"</b><br><br>";
			if (LIBRARIES[i].location != "") {
				html = html + "<b>Location:</b> "+LIBRARIES[i].location;
			}
			if (LIBRARIES[i].address != "") {
				html = html + "<br><b>Address:</b> "+LIBRARIES[i].address;
			}
			if (LIBRARIES[i].link != "") {
				html = html + "<br><a href=\'"+LIBRARIES[i].link+"\' target=\'_blank\'>More Information</a>";
			}
			html = html + "<br><br><br></div>";
			marker.openInfoWindow(html);
		});
	} else {
		GEvent.addListener(marker, "dragend", function(latlng) {
			for (var j = 0; j < libraryMarkers.length; j++) {
				if (i == libraryMarkers[j][0]) {
					libraryMarkers.splice(j,1);
				}
			}
			libraryMarkers.push([i, latlng.lat().toFixed(6), latlng.lng().toFixed(6)]);
	    });
	}
	return marker;
}

UOLIBRARIES.prototype.plotLibraryTool = function(map,i,index){
	var icon = new GIcon();
	icon.iconSize = new GSize(20,20);
	icon.iconAnchor = new GPoint(20,20);
	icon.infoWindowAnchor = new GPoint(20,20);
	icon.image = LIBRARIES[i].icon;
	var point = new GLatLng(LIBRARIES[i].lat, LIBRARIES[i].lng);
	var markerOpts = {icon: icon, hide: i==index?false:true};
	var marker = new GMarker(point, markerOpts);
	marker.index = i;
	GEvent.addListener(marker, "click", function() {
		var bounds = new GLatLngBounds();
		var lat = marker.getLatLng().lat() + 0.001;
		var lng = marker.getLatLng().lng();
		var point = new GLatLng(lat, lng);
		bounds.extend(point);
		marker.checked = "";
		if (UOM._poiCategory == "library" && UOM._poiId == i) {
			marker.checked = "checked";
		}
		marker.openInfoWindowHtml("<input type='checkbox' value='"+this.index+"' "+this.checked+" onclick='UOM._map.selectPoi(this);' />Select Point of Interest");
		map.setCenter(bounds.getCenter());
	});
	return marker;
}
