$(function(){
  // add labels to all input fields, title attribute is the label
 $(".label").labelify({labelledClass: 'label'});

 // trigger submit when user clicks the search button in the field
  $(".click").click(function(){
    $(this).parent("form").submit();  
  });

  // the back button for advertiser pages
  $(".back").click(function(event){
    history.back();
    event.preventDefault();
  });

  // hide ugly 'request big' button on advertiser page
  $("img[src='common_files/images/request_bid_bt.jpg']").hide();


  $("ul.pages li:not(.current) a").hover(function(){
    // full url
    original = $(this).children("img").attr("src");
    
    // filename
    hover = original.split("/");
    original_file = hover[hover.length - 1];

    // split the file by . so we can put "on" in the middle
    split = original_file.split('.');
     
    // assume that there is a file with "on" for the hover
    on_file = split[0] + "-on." + split[1];
    // swap the old file with the new hover file
    hover_file = original.replace(original_file, on_file);

    $(this).children("img").attr("src", hover_file);
  },
  function(){
    src = $(this).children("img").attr("src");
    off_src = src.replace("-on", "");
    $(this).children("img").attr("src", off_src);
  }
  );
})

