(function ($) {
   $.fn.labelOver = function (options) {

      var settings = $.extend( {}, $.fn.labelOver.settings, options )

      this.each(function () {
         var labels;
         $(this).addClass('overlabel')
         //Accept either labels themselves, or an element containing labels.
         if($(this).is('label')) {
            labels = $(this);
         } else {
            labels = $(this).find('label');
         }
         
         labels.each(function () {

            var $input = settings.inputFinder.apply(this).bind('focus', function () {
               //Hide corresponding label on focus
               labelFor = $(this).attr('id');
               $('label[for='+labelFor+']').hide();               
            }).bind('blur', function () {
               //If field is blank on blur, show label
               if($(this).val() == ""){
                  labelFor = $(this).attr('id');
                  $('label[for='+labelFor+']').show();                  
               }
            });
            //Hide the label by default for any pre-populated fields
            if ($input.val() != "") {
               $(this).hide();
            }
            //Make label look/act like input couterpart
            $(this).css('cursor', 'text').click(function () {
               $(this).hide();
               $input.focus();
            });
            
         });//end - each label
      });//end - each element
      
   }
   $.fn.labelOver.settings = {
      inputFinder: function () {
         var inputId = $(this).attr('for');
         return $('#'+inputId);
      }
   }
})(jQuery)
$(document).ready(function () {
   $('#quick-contact').labelOver();   
})
