/*!
 * jQuery overplaceholder Plugin 1.0
 *
 * http://diapeira.1gb.ru/diapeira/jquery-plugins/overplaceholder.html
 * http://plugins.jquery.com/project/overplaceholder
 *
 * Copyright (c) 2011 Amphiluke
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function(d){var g=function(i,h){var k=d("<span class='oph-wrapper'></span>");var j=h.attr("id");if(j){k.attr("id","oph-"+j)}h.wrap(k);i.insertAfter(h)},c=function(j,h){if(!h){h=d("#"+j.attr("for"))}var i=h.offset(),k=h.parent().offset();j.css({left:(i.left-k.left)+"px",top:(i.top+((h.outerHeight()-j.outerHeight())>>1)-k.top)+"px"})},a=function(h,i){if(i&&(h.val().replace(/\s/g,"")==="")){h.val("")}return h.val()},f=function(j,h,i){j.click(function(){i.onhide.call(this)});j.bind("parentformreset",function(){var k=h.get(0).defaultValue;if(!k||(i.ignoreSpaces&&(k.replace(/\s/g,"")===""))){i.onshow.call(j.get(0))}else{i.onhide.call(j.get(0))}});if(("unselectable" in j.get(0))||("expando" in document)){j.attr("unselectable","on")}},e=function(j,h,i){if(h.get(0).nodeName.toUpperCase()=="SELECT"){h.change(function(){var k=(a(h,i.ignoreSpaces))?i.onhide:i.onshow;k.call(j.get(0))})}else{h.focus(function(){if(!h.val()){i.onhide.call(j.get(0))}})}h.blur(function(){if(!a(h,i.ignoreSpaces)){i.onshow.call(j.get(0))}})},b=function(j,i){var h=d("#"+j.attr("for"));if(h.length==0){return false}j.addClass("overplaceholder");g(j,h);if(typeof i.onafterWrap=="function"){i.onafterWrap(j,h)}c(j,h);if(a(h,i.ignoreSpaces)){i.onhide.call(j.get(0))}f(j,h,i);e(j,h,i)};d.fn.overplaceholder=function(i){var h={},j={onhide:function(){d(this).hide()},onshow:function(){d(this).show()},onafterWrap:null,ignoreSpaces:false};d.extend(h,j,i);return this.each(function(){b(d(this),h)})};d(document).ready(function(){var h=(d.support.submitBubbles)?"live":"bind";d("form")[h]("reset",function(){d(".overplaceholder",this).trigger("parentformreset")})})})(jQuery);
