/*	TypeWatch 2.0 - Original by Denny Ferrassoli / Refactored by Charles Christolini
 *	Examples/Docs: www.dennydotnet.com
 *  Copyright(c) 2007 Denny Ferrassoli - DennyDotNet.com
 *  Coprright(c) 2008 Charles Christolini - BinaryPie.com
 *  Dual licensed under the MIT and GPL licenses:
 *  http://www.opensource.org/licenses/mit-license.php
 *  http://www.gnu.org/licenses/gpl.html
*/
(function(i){i.fn.typeWatch=function(o){var h=i.extend({wait:750,callback:function(){},highlight:true,captureLength:2},o);function checkElement(a,b){var c=i(a.el).val();if((c.length>h.captureLength&&c.toUpperCase()!=a.text)||(b&&c.length>h.captureLength)){a.text=c.toUpperCase();a.cb(c)}};function watchElement(e){if(e.type.toUpperCase()=="TEXT"||e.nodeName.toUpperCase()=="TEXTAREA"){var f={timer:null,text:i(e).val().toUpperCase(),cb:h.callback,el:e,wait:h.wait};if(h.highlight){i(e).focus(function(){this.select()})}var g=function(a){var b=f.wait;var c=false;if(a.keyCode==13&&this.type.toUpperCase()=="TEXT"){b=1;c=true}var d=function(){checkElement(f,c)};clearTimeout(f.timer);f.timer=setTimeout(d,b)};i(e).keydown(g)}};return this.each(function(a){watchElement(this)})}})(jQuery);
