// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

  $(document).ready(function(){
    $(".tabs > ul").tabs();
    $("input#event_venue_name").autocomplete("auto_complete_for_venue_name",
                                  { formatItem:formatVenue,
                                    onItemSelect: onVenueSelect});
    $(".loginField").focus(function () {
             $(this).val("");
    });
    $(".date-select").datepicker({
        numberOfMonths: 2,
        speed: "",
        dateFormat: "dd-M-yy",
        showOn: "both",
        buttonImage: "/images/calendar.gif",
        buttonImageOnly: true
    });
    $('a.title').cluetip({activation: 'click', splitTitle: '|', sticky: true, closePosition: 'title'});
    $(".job_category").autocomplete("auto_complete_for_job_category");
  });
  function formatVenue(row) {
    var ven = ""
    var cit = ""
    if(row[0] != null){ ven = row[0];}
    if(row[5] != null){ cit = row[5];}
    return ven + "<br><i>" + cit + "</i>";
  }
  function onVenueSelect(row) {
      $("input#event_venue_id").val(row[1]);
      $("input#event_address").val(row[2]);
      $("input#event_nearest_station").val(row[3]);
  }
  function focusPoint(id){
      if (currentFocus) {
        Element.removeClassName("sidebar-item-"+currentFocus,"current");
      }
      Element.addClassName("sidebar-item-"+id,"current");
      markerHash[id].marker.openInfoWindowHtml(markerHash[id].loc_name);
      currentFocus=id;
  }
  function filterResults(resultID, className){
    var elements = document.getElementsByClassName(className);
    for(i=0;i<elements.length;i++) {
          Element.hide(elements[i])
    }
    Element.show("result-" + resultID)
    Element.show("description-" + resultID)
  }
