/*
 * jQuery Input Hint Overlay plugin v1.1.5, 2010-03-25
 * Only tested with jQuery 1.4.1 (early versions - YMMV)
 * 
 *   http://jdeerhake.com/inputHintOverlay.php
 *   http://plugins.jquery.com/project/inputHintOverlay
 *
 *
 * Copyright (c) 2010 John Deerhake
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

jQuery.fn.inputHintOverlay=function(topNudge,leftNudge,tag,hintTag){topNudge=typeof(topNudge)!='undefined'?topNudge:0;leftNudge=typeof(leftNudge)!='undefined'?leftNudge:0;tag=typeof(tag)!='undefined'?tag:'label';hintTag=typeof(hintTag)!='undefined'?hintTag:'title';var suffix='jqiho';return this.each(function(){var curParent=$(this);var textAreas=$(this).find("textarea");$(this).find("input[type=text]").add(textAreas).each(function(){var relHint=$(this).attr(hintTag);var curValue=$(this).attr('value');var safeHint;if(relHint){safeHint=(relHint+$(this).attr('name')+$(this).closest('form').attr('id')).replace(/[^a-zA-Z0-9]/g,'');$(this).wrap("<div style='position:relative' id='wrap"+safeHint+suffix+"' />");var newPos=$(this).position();newZ=$(this).css('z-index');if(newZ=="auto")newZ="2000";else newZ=newZ+20;var newCSS={'position':'absolute','z-index':newZ,'left':newPos['left']+leftNudge,'top':newPos['top']+topNudge};newDiv=$(document.createElement(tag)).appendTo($("div#wrap"+safeHint+suffix)).attr('for',$(this).attr('id')).attr('id',safeHint+suffix).addClass('inputHintOverlay').html(relHint).css(newCSS);}
if(curValue){$('#'+safeHint+suffix).toggle(false);}
$(this).focus(function(){$('#'+safeHint+suffix).toggle(false);});$(this).blur(function(){if($(this).attr('value')==""){$('#'+safeHint+suffix).toggle(true);}});$(this).addClass(safeHint+suffix);$('#'+safeHint+suffix).click(function(e)
{$("div#wrap"+safeHint+suffix+" input").trigger('focus');});});});}
