// JavaScript Document
var locationHref = location.href;
locationHref = locationHref.replace(/http:\/\/insitu.lab20.net\//, '');


//------------------------------------------------interaction map
//----------------------------------------------INCLUDE BEN
if (locationHref.test("transport")) {
	if (locationHref.test("acceder")){
		var map_filters = new Array('T-map-filter-a');
		}
	else if (locationHref.test("stationner")){
		var map_filters = new Array('T-map-filter-c');
		}
	else if (locationHref.test("deplacer")){
		var map_filters = new Array('T-map-filter-b-1', 'T-map-filter-b-2', 'T-map-filter-b-3');
		}
	else if (locationHref=="transport/" || locationHref=="transport" || locationHref=="transport/#") {
		//pas de filte en page dacceuil mais on init le tableau pour tej l'erreur js
		var map_filters = new Array();
		}
	else {alert("erreur d'adressage");}
	} 
else {
	var map_filters = new Array('map-filter-1', 'map-filter-2', 'map-filter-3');
}
var map_filters_transitions = new Array();

window.addEvent('domready', function() {

	if ( document.getElementById('map-filters')!= null){
		/* initialisation des map Filters */

		for(i = 0; i < map_filters.length; i++) {	
			initMapFilter(map_filters[i]);	
		}
		
		$('map-canvas').addEvent('click', function() {
			closeMapTogglers();
		});
		
		$('sign-toggler').addEvent('click', function() {
			signOpen = switchSignToggler(signOpen);
		});

		/* transparences */
		if ( document.getElementById('map-filters')!= null){
			/*$$('#map-filters .content').setOpacity('0.6');*/
			
		}
	}
});


function initMapFilter(toggler_id) {
	map_filters_transitions[toggler_id] = new Fx.Style(toggler_id+'-content', 'height', {
		wait: false,
		duration: 600,
		transition: Fx.Transitions.Quint.easeOut
	});
	
	if($(toggler_id)){
	$(toggler_id).addEvent('click', function() {
		
		closeMapTogglers(toggler_id);
		
		
		
		if($(toggler_id+'-content').getStyle('height') == '0px') {
			map_filters_transitions[toggler_id].start(300);
		} else {
			map_filters_transitions[toggler_id].start(0);
		}

	});
  }	
}

function closeMapTogglers(toggler_id) {

		var toggler_id = (toggler_id == null) ? false : toggler_id;
			for(i = 0; i < map_filters.length; i++) {
				if($(map_filters[i]+'-content').getStyle('height') != '0px' && (map_filters[i] != toggler_id || toggler_id == false)) {
					map_filters_transitions[map_filters[i]].start(0);
				};
			}
}