//////////////////////////////////////////////////////////////////////////////////////////
// Directions
function map_showdirection(id) {
  // Init Selection
  spjs_hide('maptype_list');
  spjs_show('maptype_driving_text');
  spjs_hide('maptype_driving_link');
  //spjs_hide('maptype_transit_text');
  //spjs_show('maptype_transit_link');
  spjs_hide('maptype_walking_text');
  spjs_show('maptype_walking_link');
  
  // Show Panel
  spjs_show('mapbackground_'+id);
  spjs_show('mapdirectiontitle_'+id);
  spjs_show('mapdirectionpanel_'+id);
  
  $('map_input_from').focus();
}

function map_hidedirection(id) {
  spjs_hide('mapbackground_'+id);
  spjs_hide('mapdirectiontitle_'+id);
  spjs_hide('mapdirectionpanel_'+id);
  sp_mapobj.clear_directions();
}

function map_getdirections(id) {
  map_getdirections_type(id, 'car');
}

function map_getdirections_type(id, type) {
  map_busydirections(id);
  
  var from_str = spjs_get_value('map_input_from');
  sp_mapobj.get_directions_from(from_str, {travel_mode: type});
}

function map_busydirections(id) {
  spjs_disable('mapdirectionsubmit_'+id);
  spjs_hide('mapdirections_'+id);
  spjs_show('mapdirectionbusy_'+id);
}

function map_resetdirections(id) {
  spjs_enable('mapdirectionsubmit_'+id);
  spjs_show('mapdirections_'+id);
  spjs_hide('mapdirectionbusy_'+id);
  
  spjs_show('maptype_list');
}

//////////////////////////////////////////////////////////////////////////////////////////
// Nearby
function map_shownearby(id) {
  spjs_show('mapbackground_'+id);
  spjs_show('mapnearbytitle_'+id);
  spjs_show('mapnearbypanel_'+id);
}

function map_hidenearby(id) {
  spjs_hide('mapbackground_'+id);
  spjs_hide('mapnearbytitle_'+id);
  spjs_hide('mapnearbypanel_'+id);
  
  map_clearnearby();
}

function map_clearnearby() {
  var cur_id = $('mapnearby_current').value;
  var oldgroupname = 'markergroup_'+cur_id;
  if(sp_mapobj.has_marker_group(oldgroupname)) {
    sp_mapobj.hide_marker_group(oldgroupname);
    sp_mapobj.remove_marker_group(oldgroupname);
  }
  $('mapnearby_content_'+cur_id).hide();
}
