         nodesLayer.addFeatures(features)
         map.zoomToExtent(nodesLayer.getDataExtent())
 
-  retrieveDirections = () ->
-    destination = $("#destination").val()
-    source = $("#source").val()
+  retrieveDirections = (source, destination) ->
     $.get "/directions", {
+      source
       destination
-      source
       },
       (directions) ->
         displayDirections(directions)

        addWaysToLayer(ways, waysLayer)
        map.zoomToExtent(waysLayer.getDataExtent())

  setNode = (input) ->
    id = nodesLayer.selectedFeatures.length > 0 and nodesLayer.selectedFeatures[0].attributes.node.id
    input.val(id) if id?

  setNodeAsSource = () ->
    setNode($("#source"))

  setNodeAsDestination = () ->
    setNode($("#destination"))

  toggleDisabledProperty = (elementId) ->
    if $("##{ elementId }").prop("disabled") is true

        retrieveWays()
  })
  selectFeatureControl = new OpenLayers.Control.SelectFeature([nodesLayer, waysLayer]);
  source = null

  $(() ->
    map = new OpenLayers.Map "map"
