var ACCESS = {"octranspo": [], "overpass": [], "shuttleBus": [], "taxi": []};
ACCESS["overpass"][0]={desc: "overpassRD", lat: 45.422142, lng: -75.682282, campus: "main"};
ACCESS["overpass"][1]={desc: "overpassRD", lat: 45.421468, lng: -75.682465, campus: "main"};
ACCESS["overpass"][2]={desc: "overpassRD", lat: 45.422394, lng: -75.683377, campus: "main"};
ACCESS["overpass"][3]={desc: "overpassRD", lat: 45.422865, lng: -75.683693, campus: "main"};
ACCESS["overpass"][4]={desc: "overpassRD", lat: 45.423516, lng: -75.684342, campus: "main"};
ACCESS["overpass"][5]={desc: "overpassRU", lat: 45.423441, lng: -75.683892, campus: "main"};
ACCESS["overpass"][6]={desc: "overpassRU", lat: 45.423523, lng: -75.683602, campus: "main"};
ACCESS["overpass"][7]={desc: "overpassRU", lat: 45.423843, lng: -75.682932, campus: "main"};
ACCESS["overpass"][8]={desc: "overpassRD", lat: 45.424043, lng: -75.682728, campus: "main"};
ACCESS["overpass"][9]={desc: "overpassRD", lat: 45.423399, lng: -75.682057, campus: "main"};
ACCESS["overpass"][10]={desc: "overpassRD", lat: 45.401953, lng: -75.648782, campus: "altaVista"};
ACCESS["overpass"][11]={desc: "overpassRU", lat: 45.401746, lng: -75.650691, campus: "altaVista"};
ACCESS["overpass"][12]={desc: "overpassRD", lat: 45.423550, lng: -75.685989, campus: "main"};
ACCESS["shuttleBus"][0]={desc: "Shuttle", lat: 45.422454, lng: -75.682111, campus: "main", info: "<div style='height:120px;width:300px;'><span class='uo_bold_font'>Shuttle Bus Service</span><br><br>For shuttle timetable and additional information,<br>click the following link:<br><br><a href=\'http://www.protection.uottawa.ca/en/shuttlergn.html\' target=\'_blank\'>http://www.protection.uottawa.ca/en/shuttlergn.html</a><br><br><a href=\'http://www.protection.uottawa.ca/en/shuttlergn.html#RgCampus\' target=\'_blank\'>View route</a></div>", direction: "to"};
ACCESS["shuttleBus"][1]={desc: "Shuttle", lat: 45.415202, lng: -75.671725, campus: "main", info: "<div style='height:120px;width:300px;'><span class='uo_bold_font'>Shuttle Bus Service</span><br><br>For shuttle timetable and additional information,<br>click the following link:<br><br><a href=\'http://www.protection.uottawa.ca/en/shuttlergn.html\' target=\'_blank\'>http://www.protection.uottawa.ca/en/shuttlergn.html</a><br><br><a href=\'http://www.protection.uottawa.ca/en/shuttlergn.html#RgCampus\' target=\'_blank\'>View route</a></div>", direction: "from"};
ACCESS["shuttleBus"][2]={desc: "Shuttle", lat: 45.403045, lng: -75.650311, campus: "altaVista", info: "<div style='height:120px;width:300px;'><span class='uo_bold_font'>Shuttle Bus Service</span><br><br>For shuttle timetable and additional information,<br>click the following link:<br><br><a href=\'http://www.protection.uottawa.ca/en/shuttlergn.html\' target=\'_blank\'>http://www.protection.uottawa.ca/en/shuttlergn.html</a><br><br><a href=\'http://www.protection.uottawa.ca/en/shuttlergn.html#RgCampus\' target=\'_blank\'>View route</a></div>", zoom: true};
ACCESS["taxi"][0]={desc: "Taxi Pickup Point", lat: 45.425135, lng: -75.686424, campus: "main", info: "<div style='height:135px;width:300px;'><span class='uo_bold_font'>Taxi Pickup Point</span><br><br><b>Pickup Point #1</b><br><b>Address:</b> 135 Seraphin Marion<br><br>This point relates to Blue Line Taxi (613-746-8740) and Capital Taxi (613-741-3887)<br><br><b>When calling for service, provide the Pickup Point #</b></div>"};
ACCESS["taxi"][1]={desc: "Taxi Pickup Point", lat: 45.422680, lng: -75.684670, campus: "main", info: "<div style='height:135px;width:300px;'><span class='uo_bold_font'>Taxi Pickup Point</span><br><br><b>Pickup Point #2</b><br><b>Address:</b> 90 University Private<br><br>This point relates to Blue Line Taxi (613-746-8740) and Capital Taxi (613-741-3887)<br><br><b>When calling for service, provide the Pickup Point #</b></div>"};
ACCESS["taxi"][2]={desc: "Taxi Pickup Point", lat: 45.421170, lng: -75.680378, campus: "main", info: "<div style='height:135px;width:300px;'><span class='uo_bold_font'>Taxi Pickup Point</span><br><br><b>Pickup Point #3</b><br><b>Address:</b> 141 Louis Pasteur<br><br>This point relates to Blue Line Taxi (613-746-8740) and Capital Taxi (613-741-3887)<br><br><b>When calling for service, provide the Pickup Point #</b></div>"};
ACCESS["taxi"][3]={desc: "Taxi Pickup Point", lat: 45.419668, lng: -75.678619, campus: "main", info: "<div style='height:135px;width:300px;'><span class='uo_bold_font'>Taxi Pickup Point</span><br><br><b>Pickup Point #4</b><br><b>Address:</b> 800 King Edward Avenue<br><br>This point relates to Blue Line Taxi (613-746-8740) and Capital Taxi (613-741-3887)<br><br><b>When calling for service, provide the Pickup Point #</b></div>"};
ACCESS["taxi"][4]={desc: "Taxi Pickup Point", lat: 45.402842, lng: -75.649892, campus: "altaVista", info: "<div style='height:135px;width:300px;'><span class='uo_bold_font'>Taxi Pickup Point</span><br><br><b>Pickup Point #5</b><br><b>Address:</b> 451 Smyth Road<br><br>This point relates to Blue Line Taxi (613-746-8740) and Capital Taxi (613-741-3887)<br><br><b>When calling for service, provide the Pickup Point #</b></div>"};
ACCESS["taxi"][5]={desc: "Taxi Stand", lat: 45.423380, lng: -75.681156, campus: "main", info: "<div style='height:135px;width:300px;'><span class='uo_bold_font'>Taxi Stand</span><br><br><b>Pickup Point #6</b><br><b>Address:</b> 75 Louis Pasteur<br><br>This point relates to Blue Line Taxi (613-746-8740) and Capital Taxi (613-741-3887)<br><br><b>When calling for service, provide the Pickup Point #</b></div>"};
ACCESS["octranspo"][0]={desc: "OC Transpo", lat: 45.424111, lng: -75.686713, campus: "main", info: "<div style='height:40px;width:200px;'><b>OC Transpo - Laurier Station</b><br><br>Website: <a href=\'http://www.octranspo.com\' target=\'_blank\'>www.octranspo.com</a></div>"};
ACCESS["octranspo"][1]={desc: "OC Transpo", lat: 45.420413, lng: -75.682014, campus: "main", info: "<div style='height:40px;width:200px;'><b>OC Transpo - Campus Station</b><br><br>Website: <a href=\'http://www.octranspo.com\' target=\'_blank\'>www.octranspo.com</a></div>"};
ACCESS["octranspo"][2]={desc: "OC Transpo", lat: 45.416460, lng: -75.670556, campus: "main", info: "<div style='height:40px;width:200px;'><b>OC Transpo - Lees Station</b><br><br>Website: <a href=\'http://www.octranspo.com\' target=\'_blank\'>www.octranspo.com</a></div>"};

var ACCESS_ICON_MAP = {"shuttleBus":"images/icons/icon_Shuttle.png",
		   			   "overpassRU":"images/icons/icon_overpass_ru.png",
		   			   "overpass":"images/icons/icon_overpass.png",
		   			   "overpassRD":"images/icons/icon_overpass_rd.png",
		   			   "taxi":"images/icons/icon_taxi_32.png",
		   			   "octranspo":"images/icons/icon_octranspo.png"
};

var ACCESS_DESC_MAP = {"overpass":"Overpass",
					   "shuttleBus":"Shuttle Bus",
					   "taxi":"Taxi",
					   "octranspo":"OC Transpo"
};

UOACCESS = function (){
}

UOACCESS.prototype.plotAccess = function(map,i,type,allMarkers,forTool){
	var icon = new GIcon();
	icon.iconSize = new GSize(20,20);
	icon.iconAnchor = new GPoint(20,20);
	icon.infoWindowAnchor = new GPoint(20,20);
	if ((ACCESS[type][i].desc).indexOf("overpass")!=-1) {
		icon.image = ACCESS_ICON_MAP[ACCESS[type][i].desc];
	} else {
		icon.image = ACCESS_ICON_MAP[type];
	}
	var point = new GLatLng(ACCESS[type][i].lat, ACCESS[type][i].lng);
	var markerOpts = {icon: icon, clickable: forTool?false:true, hide: getCampus()==ACCESS[type][i].campus?false:true, draggable: forTool?true:false};
	var marker = new GMarker(point, markerOpts);
	if (ACCESS[type][i].info && !forTool) {
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(ACCESS[type][i].info);
			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);
			map.setCenter(bounds.getCenter());
		});
	}
	if (forTool) {
		GEvent.addListener(marker, "dragend", function(latlng) {
			for (var j = 0; j < accessMarkers.length; j++) {
				if ((type == accessMarkers[j][1]) && (i == accessMarkers[j][0])) {
					accessMarkers.splice(j,1);
				}
			}
			accessMarkers.push([i, type, latlng.lat().toFixed(6), latlng.lng().toFixed(6)]);
	    });
	}
	allMarkers[type].push([i,marker]);
	return marker;
}

UOACCESS.prototype.plotAccessTool = function(map,i,type,allMarkers){
	var icon = new GIcon();
	icon.iconSize = new GSize(20,20);
	icon.iconAnchor = new GPoint(20,20);
	icon.infoWindowAnchor = new GPoint(20,20);
	if ((ACCESS[type][i].desc).indexOf("overpass")!=-1) {
		icon.image = ACCESS_ICON_MAP[ACCESS[type][i].desc];
	} else {
		icon.image = ACCESS_ICON_MAP[type];
	}
	var point = new GLatLng(ACCESS[type][i].lat, ACCESS[type][i].lng);
	var markerOpts = {icon: icon, hide: getCampus()==ACCESS[type][i].campus?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._poiType == type) && (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());
	});
	allMarkers[type].push([i,marker]);
	return marker;
}

