/*
 * In-Field Label jQuery Plugin
 * http://fuelyourcoding.com/scripts/infield.html
 *
 * Copyright (c) 2009 Doug Neiner
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://docs.jquery.com/License
 *
 * @version 0.1
 */
(function(a){a.InFieldLabels=function(c,e,b){var d=this;d.$label=a(c);d.label=c;d.$field=a(e);d.field=e;d.$label.data("InFieldLabels",d);d.showing=true;d.init=function(){d.options=a.extend({},a.InFieldLabels.defaultOptions,b);if(d.$field.val()!=""){d.$label.hide();d.showing=false}d.$field.focus(function(){d.fadeOnFocus()}).blur(function(){d.checkForEmpty(true)}).bind("keydown.infieldlabel",function(f){d.hideOnChange(f)}).change(function(f){d.checkForEmpty()}).bind("onPropertyChange",function(){d.checkForEmpty()})};d.fadeOnFocus=function(){if(d.showing){d.setOpacity(d.options.fadeOpacity)}};d.setOpacity=function(f){d.$label.stop().animate({opacity:f},d.options.fadeDuration);d.showing=(f>0)};d.checkForEmpty=function(f){if(d.$field.val()==""){d.prepForShow();d.setOpacity(f?1:d.options.fadeOpacity)}else{d.setOpacity(0)}};d.prepForShow=function(f){if(!d.showing){d.$label.css({opacity:0}).show();d.$field.bind("keydown.infieldlabel",function(g){d.hideOnChange(g)})}};d.hideOnChange=function(f){if((f.keyCode==16)||(f.keyCode==9)){return}if(d.showing){d.$label.hide();d.showing=false}d.$field.unbind("keydown.infieldlabel")};d.init()};a.InFieldLabels.defaultOptions={fadeOpacity:0.5,fadeDuration:300};a.fn.inFieldLabels=function(b){return this.each(function(){var d=a(this).attr("for");if(!d){return}var c=a("input#"+d+"[type='text'],input#"+d+"[type='search'],input#"+d+"[type='tel'],input#"+d+"[type='url'],input#"+d+"[type='email'],input#"+d+"[type='password'],textarea#"+d);if(c.length==0){return}(new a.InFieldLabels(this,c[0],b))})}})(jQuery);

