(function(e){"use strict";function o(t){var n=t.selector;t.each(function(){var t="fancyInput",n=e('
');if(this.tagName=="TEXTAREA")t+=" textarea";e(this.parentNode).append(n).addClass(t);if(this.value)r.fillText(this.value,this)});e(document).on("input.fi",n,r.input).on("keypress.fi",n,r.keypress).on("keyup.fi select.fi mouseup.fi cut.fi paste.fi blur.fi",n,r.allEvents).on("mousedown.fi mouseup.fi keydown.fi",n,i.set).on("keydown.fi",n,r.keydown)}var t=!!window.ActiveXObject,n;e.fn.fancyInput=function(){if(!t||"ontouchstart"in document.documentElement)o(this);return this};var r={classToggler:"state1",keypress:function(e){var t=String.fromCharCode(e.charCode),n=this.nextElementSibling,i=this.selectionEnd,o=this.tagName=="TEXTAREA"&&e.keyCode==13;if(this.selectionEnd-this.selectionStart>0&&e.charCode&&!(e.metaKey||e.ctrlKey)){var u=[this.selectionStart,this.selectionEnd];i=this.selectionStart;if(s.lastDir=="rtl"){u=[this.value.length-this.selectionEnd,this.value.length-this.selectionStart+1]}r.removeChars(n,u)}if(e.charCode&&!(e.metaKey||e.ctrlKey)||o){var a=s.check(t);if(a=="rtl"||a==""&&s.lastDir=="rtl")i=this.value.length-this.selectionStart;if(o)t="";r.maskPassword(this);r.writer(t,this,i)}},input:function(){r.textLength=this.value.length;r.inputResize(this)},maskPassword:function(t){if(t.type=="password")e(t.nextElementSibling).find("span").each(function(){this.innerHTML=""})},setCaretHeight:function(t){var r=e(t.nextElementSibling);if(!r.find("span").length)return false;n=r.find("span")[0].clientHeight;r.find("b").height(n)},writer:function(t,n,r){var i=e(n.nextElementSibling).children().not("b"),s=document.createElement("span");if(t==" ")t=" ";if(t){s.innerHTML=t;this.classToggler=this.classToggler=="state2"?"state1":"state2";s.className=this.classToggler}else s=document.createElement("br");if(i.length){if(r==0)e(n.nextElementSibling).prepend(s);else{var o=i.eq(--r);o.after(s)}}else n.nextElementSibling.appendChild(s);if(t)setTimeout(function(){s.removeAttribute("class")},20);return this},clear:function(t){var n=e(t.parentNode).find(".caret");e(t).html(n)},fillText:function(e,t){var n=t.nextElementSibling,i,s=document.createDocumentFragment();r.clear(t.nextElementSibling);setTimeout(function(){var t=e.length;for(var r=0;rt.parentNode.clientWidth)n+=20;t.style.width=n+"px"}},keydown:function(e){var t=String.fromCharCode(e.charCode),n=this.nextElementSibling,i=this.selectionEnd,o=(e.metaKey||e.ctrlKey)&&e.keyCode==90||e.altKey&&e.keyCode==8,u=(e.metaKey||e.ctrlKey)&&e.keyCode==89,a=(e.metaKey||e.ctrlKey)&&e.keyCode==65;r.setCaret(this);if(a)return true;if(o||u){setTimeout(function(){r.fillText(e.target.value,e.target)},50);return true}if(e.keyCode==8||e.keyCode==46&&this.selectionEnd>this.selectionStart){var f=[this.selectionStart,this.selectionEnd];if(s.lastDir=="rtl")f=[this.value.length-this.selectionEnd,this.value.length-this.selectionStart+1];setTimeout(function(){if(e.metaKey||e.ctrlKey)f=[e.target.selectionStart,f[0]];r.removeChars(n,f)},0)}if(this.selectionStart==0)this.parentNode.scrollLeft=0;return true},allEvents:function(e){r.setCaret(this);if(e.type=="paste"){setTimeout(function(){r.fillText(e.target.value,e.target);r.inputResize(e.target)},20)}if(e.type=="cut"){r.removeChars(this.nextElementSibling,[this.selectionStart,this.selectionEnd])}if(!e.keyCode||e.keyCode<50)r.maskPassword(this);if(!n){setTimeout(function(){r.setCaretHeight(e.target)},150)}if(this.selectionStart==this.value.length)this.parentNode.scrollLeft=999999},setCaret:function(t){var n=e(t.parentNode).find(".caret"),i=e(t.nextElementSibling).children().not("b"),o=i.not(".deleted"),u=r.getCaretPosition(t);if(s.lastDir=="rtl")u=t.value.length-u;var a=o.eq(u);if(u==t.value.length){n.appendTo(t.nextElementSibling)}else n.insertBefore(a)},getCaretPosition:function(e){var t,n=i.direction||"right";if(e.selectionStart||e.selectionStart=="0")t=n=="left"?e.selectionStart:e.selectionEnd;return t||0}},i={direction:null,lastOffset:null,set:function(e){var t;if(e.shiftKey&&e.keyCode==37)t="left";else if(e.shiftKey&&e.keyCode==39)t="right";if(e.type=="mousedown")i.lastOffset=e.clientX;else if(e.type=="mouseup")t=e.clientX');if(this.tagName=="TEXTAREA")t+=" textarea";e(this.parentNode).append(n).addClass(t);if(this.value)r.fillText(this.value,this)});e(document).on("input.fi",n,r.input).on("keypress.fi",n,r.keypress).on("keyup.fi select.fi mouseup.fi cut.fi paste.fi blur.fi",n,r.allEvents).on("mousedown.fi mouseup.fi keydown.fi",n,i.set).on("keydown.fi",n,r.keydown)}var t=!!window.ActiveXObject,n;e.fn.fancyInput=function(){if(!t||"ontouchstart"in document.documentElement)o(this);return this};var r={classToggler:"state1",keypress:function(e){var t=String.fromCharCode(e.charCode),n=this.nextElementSibling,i=this.selectionEnd,o=this.tagName=="TEXTAREA"&&e.keyCode==13;if(this.selectionEnd-this.selectionStart>0&&e.charCode&&!(e.metaKey||e.ctrlKey)){var u=[this.selectionStart,this.selectionEnd];i=this.selectionStart;if(s.lastDir=="rtl"){u=[this.value.length-this.selectionEnd,this.value.length-this.selectionStart+1]}r.removeChars(n,u)}if(e.charCode&&!(e.metaKey||e.ctrlKey)||o){var a=s.check(t);if(a=="rtl"||a==""&&s.lastDir=="rtl")i=this.value.length-this.selectionStart;if(o)t="";r.maskPassword(this);r.writer(t,this,i)}},input:function(){r.textLength=this.value.length;r.inputResize(this)},maskPassword:function(t){if(t.type=="password")e(t.nextElementSibling).find("span").each(function(){this.innerHTML=""})},setCaretHeight:function(t){var r=e(t.nextElementSibling);if(!r.find("span").length)return false;n=r.find("span")[0].clientHeight;r.find("b").height(n)},writer:function(t,n,r){var i=e(n.nextElementSibling).children().not("b"),s=document.createElement("span");if(t==" ")t=" ";if(t){s.innerHTML=t;this.classToggler=this.classToggler=="state2"?"state1":"state2";s.className=this.classToggler}else s=document.createElement("br");if(i.length){if(r==0)e(n.nextElementSibling).prepend(s);else{var o=i.eq(--r);o.after(s)}}else n.nextElementSibling.appendChild(s);if(t)setTimeout(function(){s.removeAttribute("class")},20);return this},clear:function(t){var n=e(t.parentNode).find(".caret");e(t).html(n)},fillText:function(e,t){var n=t.nextElementSibling,i,s=document.createDocumentFragment();r.clear(t.nextElementSibling);setTimeout(function(){var t=e.length;for(var r=0;rt.parentNode.clientWidth)n+=20;t.style.width=n+"px"}},keydown:function(e){var t=String.fromCharCode(e.charCode),n=this.nextElementSibling,i=this.selectionEnd,o=(e.metaKey||e.ctrlKey)&&e.keyCode==90||e.altKey&&e.keyCode==8,u=(e.metaKey||e.ctrlKey)&&e.keyCode==89,a=(e.metaKey||e.ctrlKey)&&e.keyCode==65;r.setCaret(this);if(a)return true;if(o||u){setTimeout(function(){r.fillText(e.target.value,e.target)},50);return true}if(e.keyCode==8||e.keyCode==46&&this.selectionEnd>this.selectionStart){var f=[this.selectionStart,this.selectionEnd];if(s.lastDir=="rtl")f=[this.value.length-this.selectionEnd,this.value.length-this.selectionStart+1];setTimeout(function(){if(e.metaKey||e.ctrlKey)f=[e.target.selectionStart,f[0]];r.removeChars(n,f)},0)}if(this.selectionStart==0)this.parentNode.scrollLeft=0;return true},allEvents:function(e){r.setCaret(this);if(e.type=="paste"){setTimeout(function(){r.fillText(e.target.value,e.target);r.inputResize(e.target)},20)}if(e.type=="cut"){r.removeChars(this.nextElementSibling,[this.selectionStart,this.selectionEnd])}if(!e.keyCode||e.keyCode<50)r.maskPassword(this);if(!n){setTimeout(function(){r.setCaretHeight(e.target)},150)}if(this.selectionStart==this.value.length)this.parentNode.scrollLeft=999999},setCaret:function(t){var n=e(t.parentNode).find(".caret"),i=e(t.nextElementSibling).children().not("b"),o=i.not(".deleted"),u=r.getCaretPosition(t);if(s.lastDir=="rtl")u=t.value.length-u;var a=o.eq(u);if(u==t.value.length){n.appendTo(t.nextElementSibling)}else n.insertBefore(a)},getCaretPosition:function(e){var t,n=i.direction||"right";if(e.selectionStart||e.selectionStart=="0")t=n=="left"?e.selectionStart:e.selectionEnd;return t||0}},i={direction:null,lastOffset:null,set:function(e){var t;if(e.shiftKey&&e.keyCode==37)t="left";else if(e.shiftKey&&e.keyCode==39)t="right";if(e.type=="mousedown")i.lastOffset=e.clientX;else if(e.type=="mouseup")t=e.clientX