jQuery(document).ready( function() {

    if (jQuery('div.link_metromap').length) {
        jQuery('#metromap_container').hide();
    }

    jQuery('div.link_metromap a').click( function() {
        jQuery(this).hide();
        jQuery('#metromap_container').slideDown();
        return false;
    });
    
    jQuery('#btn_metro_station_select').click(function() {
    	jQuery('#list_undeground_stations option:selected').appendTo('#list_undeground_stations_selected');
    	updateMetromapStations();
    });
    
    jQuery('#btn_metro_station_unselect').click(function() {
    	jQuery('#list_undeground_stations_selected option:selected').appendTo('#list_undeground_stations');
    	updateMetromapStations();
    });
    
    jQuery('#btn_metro_station_clear').click(function() {
    	jQuery('#list_undeground_stations_selected option').appendTo('#list_undeground_stations');
    	updateMetromapStations();
    });

});

function updateMetromapStations()
{
	jQuery('#metromap a.metro_station').removeClass('active');
    jQuery('#list_undeground_stations_selected option').each(function() {
		jQuery('#metromap a.metro_station[rel='+jQuery(this).val()+']').addClass('active');
    });
}


