/**** <Variables> ****/


var map, icons, gmarkers, markers;
var lightwindowiframeopen = false;
var staticMapsAccordion = null;

var lang = 'fr';

function ts() {
    var x = new Date();
    return x.valueOf();
}

// Base Icon/Marker for Google Maps
icons = [];
gmarkers = [];
icons.red = new GIcon();
icons.red.image = "/images/maps/mapIconAddress.png"; 
icons.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 
icons.red.iconSize = new GSize(16,26); 
icons.red.shadowSize = new GSize(28,26); 
icons.red.iconAnchor = new GPoint(6, 20); 
icons.red.infoWindowAnchor = new GPoint(5, 1); 
icons.red.imageMap = [4,0,0,4,0,7,3,11,4,19,7,19,8,11,11,7,11,4,7,0];
// End of Base Icon/Marker for Google Maps
/**** </Variables> ****/

/**** <Google Maps Code> ****/
var map;
var options = {};
var centerLatitude = 45.42327;
var centerLongitude = -75.69545;
var startZoom = 15;
if(Prototype.Browser.IE) {startZoom = 16;}
geocoder = new GClientGeocoder();
var implication = 0;

//default states
var currentShown = '';
var TWChecked = false;
var TWShown = [];
var BSChecked = true;
var BSShown = [];
var VXChecked = false;
var VXShown = [];
var PRChecked = false;
var PRShown = [];
var timeoutStop = 0;
var timeoutVendor = 0;
var markers = null;

function TWMarkers() {
	markers = TWShown;
	map.clearOverlays();
	for (var i = 0; i < TWShown.length; i++) {
		var lng = TWShown[i].getAttribute("lng");
		var lat = TWShown[i].getAttribute("lat");
		var id = TWShown[i].getAttribute("id");
		var station_id = TWShown[i].getAttribute("station_id");
		var name = TWShown[i].getAttribute("name");
		if(lng && lat) {
			var latlng = new GLatLng(parseFloat(lat),parseFloat(lng));
			var html = '<div class="googleBubble">';
			marker = null;
			marker = createTWMarker(latlng, html, "tw", id, station_id, name);
			map.addOverlay(marker);
		}
	}
	currentShown = 'stations';
	updateMessage();
	if ($('mapsq').value!=''){
		showAddress($('mapsq').value,0);
	}
}

function retrieveTWStops(getvars) {
	if(currentShown!='stations') {
		map.clearOverlays();
		if(implication<21) {
			map.setCenter(new GLatLng(centerLatitude, centerLongitude), 10);
		}
		if(TWShown.length==0) {
			var request = GXmlHttp.create();
			request.open('GET', '/google/retrieve_markers' + getvars, true);
			request.onreadystatechange = function() {
				if (request.readyState == 4) {			
					var xmlDoc = request.responseXML;
					if(xmlDoc.documentElement == undefined){
						markers = TWShown = xmlDoc.getElementsByTagName("marker");
					} else {
						markers = TWShown = xmlDoc.documentElement.getElementsByTagName("marker");
					}
					TWMarkers();
				}
			};
			request.send(null);
		} else {
			TWMarkers();
		}
	} else {
		updateMessage();
	}
}

function retrieveStops() {
	var bounds = map.getBounds();
	var southWest = bounds.getSouthWest();
	var northEast = bounds.getNorthEast();
	var zoom =  map.getZoom();
	var getVars = '?zoom=' + zoom + '&ne=' + northEast.toUrlValue() + '&sw=' + southWest.toUrlValue();
	var request = GXmlHttp.create();
	request.open('GET', '/google/retrieve_stops'  + getVars, true);
	request.onreadystatechange = function() {

		if (request.readyState == 4) {	
			var xmlDoc = request.responseXML;
			if(xmlDoc.documentElement == undefined){
				markers = xmlDoc.getElementsByTagName("marker");
			} else {
				markers = xmlDoc.documentElement.getElementsByTagName("marker");
			}

			map.clearOverlays();
			if(markers) {
				for (var i = 0; i < markers.length; i++) {
					var lng = markers[i].getAttribute("lng");
					var lat = markers[i].getAttribute("lat");
					var id = markers[i].getAttribute("id");
					var stopid = markers[i].getAttribute("stopid");
					if(lng && lat) {
						var html = "";
						var latlng = new GLatLng(parseFloat(lat),parseFloat(lng));
						marker = null;
						marker = createMarker(latlng, html, "bs", id, stopid);
						map.addOverlay(marker);
					}
				}
			}
			currentShown = 'stops';
			updateMessage();
			if ($('mapsq').value!=''){
				showAddress($('mapsq').value,0);
			}
		}
	};
	request.send(null);
}

function VXMarkers() {
	markers = VXShown;
	map.clearOverlays();
	for (var i = 0; i < markers.length; i++) {
		var lng = markers[i].getAttribute("lng");
		var lat = markers[i].getAttribute("lat");
		var name = markers[i].getAttribute("name");
		var tx = "Non";
		// var dp = "Non";
		var mp = "Non";
		if (markers[i].getAttribute("tx")  == "Y") { tx = 'Oui'; }
		// if (markers[i].getAttribute("dp")  == "Y") { dp = 'Oui'; }
		if (markers[i].getAttribute("mp")  == "Y") { mp = 'Oui'; }

		if(lng && lat) {
			var latlng = new GLatLng(parseFloat(lat),parseFloat(lng));
			var html = '<div class="googleBubble">';
				html+='	<h2>' + markers[i].getAttribute("name") + '<\/h2>';
				html+='	<div class="bubbleSubText">' + markers[i].getAttribute("address") + '<\/div>';
				html+='	<table style="width:195px" class="vendor">';
				html+='		<caption>Offerts à cet endroit :<\/caption>';
				html+='		<tr class="vendorRow">';
				html+='			<th>Billets<\/th>';
				// html+='			<th>Day Pass<\/th>';
				html+='			<th>Laissez-passer<\/th>';
				html+='		<\/tr>';
				html+='		<tr>';
				html+='			<td>' + tx + '<\/td>';
				// html+='			<td>' + dp + '<\/td>';
				html+='			<td>' + mp + '<\/td>';
				html+='		<\/tr>';
				html+='	<\/table><br /><br /><br />';
				html+='<\/div>';
			marker = null;
			marker = createVendorMarker(latlng, html, "vx");
			map.addOverlay(marker);
		}
	} //for
	currentShown = 'vendors';
	updateMessage();
	if ($('mapsq').value!=''){
		showAddress($('mapsq').value,0);
	}
}

function retrieveVendors(getVars){
	if(currentShown!='vendors') {
		map.clearOverlays();
		if(VXShown.length==0) {
			var request = GXmlHttp.create();
			var newZoom = map.getZoom(); 
			var bounds = map.getBounds();
			var southWest = bounds.getSouthWest();
			var northEast = bounds.getNorthEast();
			//var getVars = '?zoom=' + newZoom + '&ne=' + northEast.toUrlValue() + '&sw=' + southWest.toUrlValue();
		
			//tell the request where to retrieve data from.
			request.open('GET', '/google/retrieve_vendors' + getVars, true);
		
			//tell the request what to do when the state changes.
			request.onreadystatechange = function() {
				if (request.readyState == 4) {
					var xmlDoc = request.responseXML;
					if(xmlDoc.documentElement == undefined){
						markers = VXShown = xmlDoc.getElementsByTagName("marker");
					} else {
						markers = VXShown = xmlDoc.documentElement.getElementsByTagName("marker");
					}
					VXMarkers();
				} //if
			}; //function
			request.send(null);
		} else {
			VXMarkers();
		}
	} else {
		updateMessage();
	}
}

function PRMarkers() {
	markers = PRShown;
	map.clearOverlays();
	for (var i = 0; i < PRShown.length; i++) {
		var lng = PRShown[i].getAttribute("lng");
		var lat = PRShown[i].getAttribute("lat");
		var name = PRShown[i].getAttribute("name");
		var info_phone = PRShown[i].getAttribute("info_phone");
		var station_id = PRShown[i].getAttribute("station_id");
		if(lng && lat) {
			var latlng = new GLatLng(parseFloat(lat),parseFloat(lng));
			var html = '<div class="googleBubble">';
			marker = null;
			marker = createParkMarker(latlng, html, "vx", info_phone, name, station_id);
			map.addOverlay(marker);
		}
	}
	currentShown = 'park';
	updateMessage();
	if ($('mapsq').value!=''){
		showAddress($('mapsq').value,0);
	}
}

function retrievePark(getVars){
	if(currentShown!='park') {
		map.clearOverlays();
		if(implication<21) {
			map.setCenter(new GLatLng(centerLatitude, centerLongitude), 10);
		}
		if(PRShown.length==0) {
			var request = GXmlHttp.create();
			request.open('GET', '/google/retrieve_park' + getVars, true);
			request.onreadystatechange = function() {
				if (request.readyState == 4) {
					var xmlDoc = request.responseXML;
					if(xmlDoc.documentElement == undefined){
						markers = PRShown = xmlDoc.getElementsByTagName("marker");
					} else{
						markers = PRShown = xmlDoc.documentElement.getElementsByTagName("marker");
					}
					PRMarkers();
				}
			};
			request.send(null);
		} else {
			PRMarkers();
		}
	} else {
		updateMessage();
	}
}

function showAddress(address, newsearch) {
	var laddress = address + ", Ottawa, Ontario";
	if (geocoder) {
		geocoder.getLatLng(
			laddress,
			function(point) {
				if (!point) {
					if (newsearch){
						showMapsMessage('Address not found');
						//alert(laddress + " not found");
					}
				} else {
					if($('mapsMessage').down(0).text=='Address not found') {
						hideMapsMessage();
					}
					if (newsearch){
						map.setCenter(point, 16);
						var marker = new GMarker(point, get_icon("address"));
						map.addOverlay(marker);
						updateMap();
					} else {
						var marker = new GMarker(point, get_icon("address"));
						map.addOverlay(marker);
					}
					
				}
			}
		);
	}
}

function retrieveMapMarkers(zoom){
	gmarkers.length=0;
	var bounds = map.getBounds();
	var southWest = bounds.getSouthWest();
	var northEast = bounds.getNorthEast();
	var zoom =  map.getZoom();

	var getVars = '?zoom=' + zoom + '&ne=' + northEast.toUrlValue() + '&sw=' + southWest.toUrlValue();

	//display Trasnsitway Station Markers
	if (TWChecked){
		// Wide area is selected to retrieve all the stations to be cached by javascript on client side
		getVars='?zoom=0&ne=46.195042,-74.295044&sw=44.789633,-76.854858';
		retrieveTWStops(getVars);
	}

	//display Bus Stop Markers	
	if(BSChecked){
		map.clearOverlays();
		var self = this;
		if(timeoutStop==null) {
			clearTimeout(timeoutStop);
			timeoutStop = setTimeout(function() {retrieveStops(self.getVars);}, 10);
		} else {
			clearTimeout(timeoutStop);
			timeoutStop = setTimeout(function() {retrieveStops(self.getVars);}, 900);
		}
	}

	//display Vendors	
	if (VXChecked){
		// Wide area is selected to retrieve all the stations to be cached by javascript on client side
		getVars='?zoom=0&ne=46.195042,-74.295044&sw=44.789633,-76.854858';
		retrieveVendors(getVars);
	}

	//display Park & Ride	
	if (PRChecked){
		// Wide area is selected to retrieve all the stations to be cached by javascript on client side
		getVars='?zoom=0&ne=46.195042,-74.295044&sw=44.789633,-76.854858';
		retrievePark(getVars);
	}
}

function retrieveRoutesNumbers(getvars) {
	var request = GXmlHttp.create();
	var text = "";
	
	//tell the request where to retrieve data from.
	request.open('GET', 'retrieve_routenumbers' + getvars, true);
	
	//tell the request what to do when the state changes.
	request.onreadystatechange = function() {
  
		if (request.readyState == 4) {
 			var xmlDoc = request.responseXML;
    			if(xmlDoc.documentElement == undefined){
				stops = xmlDoc.getElementsByTagName("stop");
			} else {
				stops = xmlDoc.documentElement.getElementsByTagName("stop");
			}
			map.clearOverlays();
			for (var i = 0; i < stops.length; i++) {
				text = stops[i].getAttribute("number");
			}
 		} //if
	}; //function
	request.send(null);
	return text;
}

function updateMap(){
	retrieveMapMarkers();
}
/**** </Google Maps Code> ****/

/**** <Accordion V2> ****/
var accordionMaps = Class.create();
accordionMaps.prototype = {

	//
	//  Setup the Variables
	//
	showAccordionMaps : null,
	currentAccordionMaps : null,
	duration : null,
	effects : [],
	animating : false,
	
	//  
	//  Initialize the accordionMapss
	//
	initialize: function (container, options) {
		
		this.options = Object.extend({
			resizeSpeed : 8,
			classNames : {
				toggle : 'moreInfo',
				summary : 'summary',
				summaryHidden : 'summaryHidden',
				description : 'description',
				descriptionHidden : 'descriptionHidden'
			},
			onEvent : 'click'
		}, options || {});
		
		this.duration = ((11 - this.options.resizeSpeed) * 0.15);

		var accordionMapsLinks = $$('#' + container + ' .' + this.options.classNames.toggle + ', #' + container + ' .mapsInfoImg');
		accordionMapsLinks.each(function (accordionMapsLink) {
		if ($(accordionMapsLink.previous(0)) === undefined) {
			// On Click Activate
			Event.observe(accordionMapsLink, this.options.onEvent, this.activate.bind(this, accordionMapsLink.next(0).down(0).next(2)), false);
		} else {
			// Reset Styles
			$(accordionMapsLink.previous(0)).hide();
			$(accordionMapsLink).setStyle({visibility: 'visible'});
			
			// On Click Activate
			Event.observe(accordionMapsLink, this.options.onEvent, this.activate.bind(this, accordionMapsLink), false);
			if (this.options.onEvent == 'click'){
				accordionMapsLink.onclick = function () {return false;};
			}
		}

		}.bind(this));
	},
	
	//
	//  Activate an accordionMaps
	//
	activate : function (accordionMapsLink) {
		if (this.animating) {
			return false;
		}
		
		this.showAccordionMaps = $(accordionMapsLink.up(1));
		
		if (this.currentAccordionMaps == this.showAccordionMaps) {
			
			this.deactivate();
			
		} else {
		
			this.deactivate();

			this.currentAccordionMaps = $(accordionMapsLink.up(1));
			
			var effect2 = new Effect.Parallel([
			Effect.Fade(this.currentAccordionMaps.down(0).next(0).down(0).next(2), {sync: true}),
			Effect.BlindUp(this.currentAccordionMaps.down(0).next(0).down(0).next(2), {sync: true}),
			Effect.SlideDown(this.currentAccordionMaps.down(0).next(0).down(0).next(1), {sync: true})
			], {duration: this.duration});
			
		}
	},
	
	// 
	// Deactivate an active accordion
	//
	deactivate : function () {
		if (this.currentAccordionMaps !== null) {
		
			var effect1 = new Effect.Parallel([
			Effect.Appear(this.currentAccordionMaps.down(0).next(0).down(0).next(2), {sync: true}),
			Effect.BlindDown(this.currentAccordionMaps.down(0).next(0).down(0).next(2), {sync: true}),
			Effect.BlindUp(this.currentAccordionMaps.down(0).next(0).down(0).next(1), {sync: true})
			], {duration: this.duration});
  
			this.currentAccordionMaps = null;
		}
	}
};
/**** </Accordion V2> ****/

function showMapsMessage(message) {
	if($('mapsMessage').getStyle('display')=='none') {
		$('mapsMessage').setOpacity(0).setStyle({display: 'block'});
	}
	$('mapsMessage').down(0).update(message);
	Effect.Appear('mapsMessage', { to: 0.8, duration: 0.5 });
}

function hideMapsMessage() {
	Effect.Fade('mapsMessage', { duration: 0.5 });
}

function mapIsEmpty() {
	var isEmptyBool = true;
	var bounds = map.getBounds();
	for (var i = 0; i < markers.length; i++) {
		var lat = parseFloat(markers[i].getAttribute("lat"));
		var lng = parseFloat(markers[i].getAttribute("lng"));
		var point = new GLatLng(lat,lng);
		if (bounds.contains(point) == true) {
			isEmptyBool = false;
		}
	}
	return isEmptyBool;
}

function updateMessage() {
	if(mapIsEmpty()) {
		var message = 'Zoom in and pan to view bus stops';
		switch(currentShown) {
			case 'stations':
			case 'vendors': message = 'Zoom out or pan to view ' + currentShown + '.'; break;
			case 'park': message = 'Zoom out or pan to view park and ride.';
		}
		showMapsMessage(message);
	} else {
		hideMapsMessage();
	}
}

function mapLocation(location) {
	switch(location) {
		case 'busStops': BSChecked = true; TWChecked = VXChecked = PRChecked = false; updateMap(); break;
		case 'stations': TWChecked = true; BSChecked = VXChecked = PRChecked = false; updateMap(); break;
		case 'vendors': VXChecked = true; BSChecked = TWChecked = PRChecked = false; updateMap(); break;
		case 'parkRide': PRChecked = true; TWChecked = BSChecked = VXChecked = false; updateMap(); break;
	}
	return false;
}

function changeTab(tabObj, location) {
	var tabs = $$('#mapsTabs li');
	tabs.each(function(tab) {
		tab.removeClassName('selected');
	}.bind(this));
	tabObj.up(0).addClassName('selected');
	return mapLocation(location);
}

function get_icon(iconName) {
	if (!icons[iconName]) {
		if (iconName == "tw_icon"){
			icons[iconName] = new GIcon(icons.red);
			icons[iconName].image = "/images/maps/mapIconStation.png";
			icons[iconName].iconAnchor = new GPoint(7, 26);
		}
		if (iconName == "flag"){
			icons[iconName] = new GIcon(icons.red);
			icons[iconName].image = "/images/maps/mapIconBusStop.png";
			icons[iconName].shadow = "/images/maps/mapIconBusStopShadow.png";
			icons[iconName].iconSize = new GSize(10,11);
			icons[iconName].shadowSize = new GSize(14, 14);
			icons[iconName].iconAnchor = new GPoint(4, 11);
		}
		if (iconName == "vendor"){
			icons[iconName] = new GIcon(icons.red);
			icons[iconName].image = "/images/maps/mapIconVendor.png";
			icons[iconName].iconAnchor = new GPoint(7, 26);
		}
		if (iconName == "park"){
			icons[iconName] = new GIcon(icons.red);
			icons[iconName].image = "/images/maps/mapIconParkRide.png";
			icons[iconName].iconAnchor = new GPoint(7, 26); 
		}
		if (iconName == "address"){
			icons[iconName] = new GIcon(icons.red);
			icons[iconName].image = "/images/maps/mapIconAddress.png";
			icons[iconName].iconAnchor = new GPoint(7, 26);
			}
		}
	return icons[iconName];
}


function createMarkerFunc(type, latlng, html, category, id, stopid, name, phone) {
	var iconType = 'flag', src = '/google/retrieve_routenumbers/'+stopid+'/'+id + '?lang=' + lang + '&amp;' + ts();
	switch(type) {
		case 'station': 
			iconType = 'tw_icon'; break;
		case 'vendor': case 'park': 
			iconType = type;
	}

	switch(type) {
		case 'station': 
			src = '/google/retrieve_routenumbers_by_tw_station-new/'+id+'/'+stopid+'/'+name + '?lang=' + lang + '&amp;' + ts(); break;
		case 'park': 
			src = '/google/retrieve_routenumbers_by_park_and_ride-new/'+phone+'/'+name+'/'+stopid + '?lang=' + lang + '&amp;' + ts();
	}

	var marker = new GMarker(latlng, get_icon(iconType)), markerHTML, maxContentDiv;

	marker.category=category;
	GEvent.addListener(marker, 'click', function() {
		maxContentDiv = document.createElement('div');
		maxContentDiv.innerHTML = 'Loading...';
		if(type=='vendor') {
			markerHTML = html;
		} else {
			markerHTML = '<iframe src="'+src+'" width="280" height="195" frameborder="0">iframe required</iframe>';
		}
		marker.openInfoWindowHtml(markerHTML);
	});
	gmarkers.push(marker);
	return marker;	
}

function createMarker(latlng, html, category, id, stopid) {
	return createMarkerFunc('bus', latlng, html, category, id, stopid);
}

function createTWMarker(latlng, html, category, id, station_id, name) {
	return createMarkerFunc('station', latlng, html, category, id, station_id, name);
}

function createVendorMarker(latlng, html, category) {
	return createMarkerFunc('vendor', latlng, html, category);
}

function createParkMarker(latlng, html, category, info_phone, name, station_id) {
	return createMarkerFunc('park', latlng, html, category, null, station_id, name, info_phone);
}

// Resize Lightwindow
function resizeLightWindowAfterOpen(delay) {
}
function resizeLightWindowTime(width, height) {

	myLightWindow._browserDimensions();
	myLightWindow._getScroll();

	if(height>myLightWindow.dimensions.viewport.height-60) { height = myLightWindow.dimensions.viewport.height-60; }

	if(Prototype.Browser.IE6) {
		$('lightwindow').morph('top: '+myLightWindow.pagePosition.y+'px; height: '+(height+60)+'px', {duration: 0.3});
		$('lightwindow_container').morph('top: 0px; height: '+(height+60)+'px', {duration: 0.3});
		$('lightwindow_contents').morph('height: '+height+'px', {duration: 0.3});
	} else {
		$('lightwindow').morph('top: 100px; height: '+height+'px', {duration: 0.4});
		$('lightwindow_container').morph('top: -100px; height: '+height+'px', {duration: 0.4});
		$('lightwindow_contents').morph('height: '+height+'px', {duration: 0.4});
	}
}

function resizeLightWindow(width,height) {
	if(lightwindowiframeopen==false) {
		setTimeout("resizeLightWindowTime("+width+", "+height+")", 1000);
		lightwindowiframeopen = true;
	} else {
		resizeLightWindowTime(width, height);
	}
}

function getHash() {
	var hash = window.location.hash;
	return hash.substring(1);
}

function loadMapsModule() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("mapsHolder"));
		map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
		map.setUIToDefault();
		map.removeMapType(G_SATELLITE_MAP);
		map.disableScrollWheelZoom();

		G_PHYSICAL_MAP.getMinimumResolution = function () { return 7 };
                G_NORMAL_MAP.getMinimumResolution = function () { return 7 };
                G_HYBRID_MAP.getMinimumResolution = function () { return 7 };

                G_PHYSICAL_MAP.getMaximumResolution = function () { return 15 };
                G_NORMAL_MAP.getMaximumResolution = function () { return 16 };
                G_HYBRID_MAP.getMaximumResolution = function () { return 16 }; 


		var mapIconAddress = new GIcon(G_DEFAULT_ICON);
		mapIconAddress.image = "/images/maps/mapIconAddress.png";
		mapIconAddress.iconSize = new GSize(16, 26);
		mapIconAddress.shadowSize = new GSize(28, 26);

		// If they're a # in the URL check if it refers to a google maps tab
		switch(getHash()) {
			case 'system-map': changeTab($('mapBusStops'), 'busStops'); break;
			case 'transitway': changeTab($('mapStations'), 'stations'); break;
			case 'vendors': changeTab($('mapVendors'), 'vendors'); break;
			case 'park-and-ride': changeTab($('mapParkRide'), 'parkRide'); break;
			default: changeTab($('mapBusStops'), 'busStops');
		}

		GEvent.addListener(map, "zoomend", function(oldzoom,zoom) {updateMap(); implication++; }); 
		GEvent.addListener(map, "dragend", function(oldzoom,zoom) {updateMap(); implication++; });

	} // End of GBrowserIsCompatible

	// Activate tabs
	$('mapBusStops').onclick = function(){return changeTab(this, 'busStops');};
	$('mapStations').onclick = function(){return changeTab(this, 'stations');};
	$('mapVendors').onclick = function(){return changeTab(this, 'vendors');};
	$('mapParkRide').onclick = function(){return changeTab(this, 'parkRide');};

	// Init Static Maps Accordion
	staticMapsAccordion = new accordionMaps('mapsInfo');
	
	// Start Events for Static Maps Lightwindows
	$$('.lightwindowiframe').each(function(link) {
		Event.observe(link, 'click', function() {
			lightwindowiframeopen = false;
			myLightWindow.activateWindow({finalAnimationHandler: 'resizeLightWindowAfterOpen',title: '', href: link.readAttribute('href'), iframeEmbed: true, width: 710, height: 300}); 
		});
		link.onclick = function() {return false;};
	});

	// If they're a # in the URL check if it refers to a static map
	getHashVal = getHash();
	switch(getHashVal) {
		case 'mapTransitway':
		case 'mapSalesCentres': 
		case 'systemMap':
		case 'routesMaps':
		case 'parkAndRideMap':
		case 'ruralParkAndRideMap':
		case 'scotiabankRoutes': staticMapsAccordion.activate($(getHashVal).down(2).next(2)); $(getHashVal).scrollTo(); break;
	}
	
	// Routes Accodion :: When selecting route in form popup a map
	$('routesMapsSelect').onsubmit = function () {
		if($('selectRouteForMap').value>=400 && $('selectRouteForMap').value<450) {
			if(lang=="fr") {
				window.location = '/decouvrir-ottawa/place_banque_scotia';
			} else {
				window.location = '/discover-ottawa/scotiabank_place';
			}
		} else {
			myLightWindow.activateWindow({title: $('selectRouteForMap').value+' Route Map', href: mapsImages[$('selectRouteForMap').value]});
		}
		return false;
	};
}

Event.observe(window, 'load', loadMapsModule, false);