/*
 * Copyright (c) 2011 Romain Ruetschi <romain.ruetschi@gmail.com>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
(function(a,b,c){function d(a){return a.placeholder===""&&a.placeholder!==c}var e={input:d(b.createElement("input")),textarea:d(b.createElement("textarea"))};a.fn.placeHoldize=function(){function c(b){var c=b.closest("form");c.submit(function(){var b=a(this);b.data("placeHoldize.submitHandlerCalled")||b.find(".placeholder-visible").val("").data("placeHoldize.submitHandlerCalled",!0)});return!0}function b(b){var c=a(this),d=this.nodeName.toLowerCase();if(!!b||!e[d]&&!!c.attr("placeholder")){var f=c.attr("placeholder");c.val().length<=0||c.val()==f?(c.val(""),c.removeAttr("placeholder").addClass("placeholder-visible"),c.val(f)):c.removeClass("placeholder-visible").addClass("placeholder-hidden"),c.addClass("placeholdized"),c.focus(function(){c.val()===f&&(c.val(""),c.removeClass("placeholder-visible").addClass("placeholder-hidden"))}),c.blur(function(){c.val()===""?(c.val(f),c.removeClass("placeholder-hidden").addClass("placeholder-visible")):c.removeClass("placeholder-visible").addClass("placeholder-hidden")})}}return function(a){this.each(function(){b.call(this,a)}),c(this);return this}}()})(jQuery,document);
