(function($){
$.fn.overlabel = function() {
    this.each(function(index) {
      
      var label = $(this);
      var name = this.htmlFor || label.attr('for');
      var label_content = label.text();
      var control = label.siblings("input[@name="+ name +"]:first");

      var password_input = "<input type='text' value='"+ label_content +"' name='"+ control.attr("name") +"' class='"+ control.attr("class") +" blur password' onfocus='$(this).prev().show().focus().end().hide();' />";
      label.hide();
      
      var activateOverlabel = 1;
      if(control.val()=="" && activateOverlabel == 1){
        if(control.attr("type") == "password") control.after(password_input).hide();
        control.attr("value", label_content).toggleClass("blur").focus(function(){
          if(control.val() == label_content) control.attr("value", "").toggleClass("blur");
          if(control.attr("type") == "password" && control.next().is(".password")) control.next().remove();
        }).blur(function(){
          if(control.val() === ""){
            control.attr("value", label_content).toggleClass("blur");
            if(control.attr("type") == "password") control.after(password_input).hide();
          }
        }).parent("form").submit(function(){
          if(control.val() == label_content) control.attr("value", "").toggleClass("blur");
          if(control.attr("type") == "password" && control.next().is(".password")) control.show().next().remove();
        });
      }
      
    });
}
})(jQuery);