$(function() {
  //use each rather than implicit loop to capture state for each field
  $('.apply_placeholder').each(function() {
    var $this = $(this);
    //console.log($this);
    var label = $('label[for=' + $this.attr('name') + ']').remove().text();
    $this.val(label).addClass('placeholder');
    
    $this.focus(function() {
      if ($this.val() == label) {
        $this.removeClass('placeholder').val('');
      }
    }).blur(function() {
      if ($this.val() == '') {
       $this.addClass('placeholder').val(label);
      }
    });
    
    //store in pseudo label for reference from other scripts
    $this.attr('prompt', label);
    
    $this.parents('form').eq(0).submit(function() {
      if ($this.val() == label) {
        $this.val('');
      }
    });
  });
  
});