/**
 * Copyright (C) 2009 Jonathan Azoff <jon@azoffdesign.com>
 *
 * This script is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 */
(function($){var text,color="#AAA";$.fn.watermark=function(optionalText){text=optionalText;return this.each(applyWatermarkHandlers);}
function applyWatermarkHandlers(){var $this=$(this);var currentText=text||$this.attr("title");var currentForm=$this.closest("form");if(!currentText||currentText.length==0)
throw"jQuery.watermark() Error: Watermarked elements must at least have a title attribute if no watermarked text is provided to the method.";if(!$this.is("textarea, [type=text], [type=password]"))
throw"jQuery.watermark() Error: Watermarked elements must be a form field that accepts text input.";if(!currentForm.data("inputs"))
currentForm.data("inputs",[$this]);else
currentForm.data("inputs").push($this)
if(!currentForm.data("submit")){currentForm.submit(function(){currentForm.data("inputs").each(function(){if(this.data("w"))
this.val("");});return true;}).data("submit",true);}
$this.attr("title","").data("text",currentText).data("w",true).blur(watermarkOn).focus(watermarkOff).bind("drop",watermarkOff).css("color",color).val(currentText);}
function watermarkOn(){var $this=$(this);if($this.val().length==0&&!$this.data("w")){$this.data("w",true).css("color",color).val($this.data("text"));}}
function watermarkOff(event){var $this=$(this);var val=(event.originalEvent&&event.originalEvent.dataTransfer)?event.originalEvent.dataTransfer.getData("Text"):"";if($this.data("w")){$this.data("w",false).css("color","").val(val);}}})(jQuery);

