/*
 *
 * Fancy Input plugin v1.0
 *
 * © 2008 Copyright, all right reserved, Tom Flídr, Czech (tomflidr@gmail.com)
 * This SOFTWARE is under the MIT (http://en.wikipedia.org/wiki/MIT_License)
 * jQuery 1.2.6+
 *
 */

$.fn.fancyInput=function(g){var h={inputs:'.fancy-input',labels:'.fancy-label',radius:4,glow:1};g=$.extend(h,g);var j='<div></div>';var k='*:nth-child(';var l=')';var m=k+1+l+','+k+2+l;var n='';var o=' ';var p='input';var q='label';var r='focused';var s='px';var t='-';var u='';var v=0+s;var w='position';var x='relative';var y='absolute';var z='float';var A='z-index';var B='display';var C='block';var D='table';var E='none';var F='auto';var G='visibility';var H='visible';var I='hidden';var J='width';var K='height';var L='top';var M='right';var N='bottom';var O='left';var P='margin';var Q=P+t+L;var R=P+t+M;var S=P+t+N;var T=P+t+O;var U='padding';var V=U+t+L;var W=U+t+M;var X=U+t+N;var Y=U+t+O;var Z='background';var ba=Z+t+'image';var bb=Z+t+'repeat';var bc=Z+t+w;var bd=Z+t+'color';var be='transparent';var bf='border-width';var bg=$.browser.msie&&parseInt($.browser.version)<8;var bh=$.browser.msie&&parseInt($.browser.version)==6;var bi=function(a,b){return $(a).css(b)};var bj=function(a,b,c){$(a).css(b,c)};var bk=function(a,b,c){for(var i=0;i<b.length;i++){bj(a,b[i],c[i])}};var bl=function(c){var d=Array(bi(c,B),bi(c,ba),bi(c,bb));var e=Array(w,z,L,M,N,O,Q,R,S,T,B,K,J);var f=Array(bi(c,w),bi(c,z),(bi(c,L)==F)?-g.glow:parseInt(bi(c,L).replace(s,u))-g.glow,bi(c,M),bi(c,N),(bi(c,O)==F)?-g.glow:parseInt(bi(c,O).replace(s,u))-g.glow,bi(c,Q),(bi(c,R)==F)?g.glow:parseInt(bi(c,R).replace(s,u))+g.glow,(bi(c,S)==F)?g.glow:parseInt(bi(c,S).replace(s,u))+g.glow,bi(c,T),d[0],$(c).outerHeight()+2*g.glow,$(c).outerWidth()+2*g.glow);bj(c,B,E);$(c).wrap(j);bk($(c).parent(),e,f);e=Array(w,z,L,M,N,O,K,J,P,B,bf,Z,bd,V,W,X,Y);f=Array(x,E,(bg)?-1+s:v,F,F,v,(bh)?($(c).outerHeight()+(g.glow*2)-2)+s:$(c).height()+s,(bh)?($(c).outerWidth()+(g.glow*2))+s:$(c).width()+s,v,C,v,E,be,parseInt(bi(c,V).replace(s,u))+$(c).outerHeight()-$(c).innerHeight(),parseInt(bi(c,W).replace(s,u))+$(c).outerWidth()-$(c).innerWidth(),parseInt(bi(c,X).replace(s,u))+$(c).outerHeight()-$(c).innerHeight(),parseInt(bi(c,Y).replace(s,u))+$(c).outerWidth()-$(c).innerWidth());$(c).parent().parent().children(g.labels+"[for='"+$(c).attr('id')+"']").each(function(){$(this).clone().insertBefore($(c));$(this).remove();if($(c).val()!=u){$(c).parent().children(g.labels).each(function(){bj(this,G,I)})};$(c).parent().children(g.labels).each(function(){bk(this,e,f);bj(this,w,y)})});bk(c,e,f);$(c).parent().prepend(j+j);$(c).parent().children(m).each(function(i){var a=$(this).parent().width()-g.radius;if(i==0){var b=Array(a,O+o+L,0)}else{var b=Array(g.radius,M+o+L,a)};bk(this,Array(w,K,J,ba,bb,bc,T),Array(y,$(this).parent().height(),b[0],d[1],d[2],b[1],b[2]))})};var bm=function(a,b){$(a).children(m).each(function(i){$(this).css(bc,(i==0)?O+o+b:M+o+b)})};var bn=function(a){var b=a.length;for(var i=0;i<b;i++){a=a.replace(o,u)};return(a==u)?true:false};$(g.inputs).each(function(){bl(this);$(this).focus(function(){$(this).parent().addClass(r);$(this).parent().each(function(){bm(this,N)});if($(this).parent().children(k+3+l).is(q)){$(this).parent().children(q).css(G,I)}});$(this).blur(function(){$(this).parent().removeClass(r);$(this).parent().each(function(){bm(this,L)});if(bn($(this).val())&&$(this).parent().children(k+3+l).is(q)){$(this).val(u);$(this).parent().children(q).css(G,H)}});$(this).parent().hover(function(){bm(this,N)},function(){if(!$(this).hasClass(r)){$(this).removeClass(r);bm(this,L)}})})};

