(function(d){d.fn.priceFormat=function(a){a=d.extend({prefix:"US$ ",suffix:"",centsSeparator:".",thousandsSeparator:",",limit:!1,centsLimit:2,clearPrefix:!1,clearSufix:!1,allowNegative:!1},a);return this.each(function(){function g(k){for(var b="",a=0;a<k.length;a++)char_=k.charAt(a),0==b.length&&0==char_&&(char_=!1),char_&&char_.match(t)&&(m?b.length<m&&(b+=char_):b+=char_);for(var c;b.length<j+1;)b="0"+b;c=b;var b="",a=0,d=c.substr(c.length-j,j),e=c.substr(0,c.length-j);c=e+n+d;if(l){for(c=e.length;0<
c;c--)char_=e.substr(c-1,1),a++,0==a%3&&(char_=l+char_),b=char_+b;b.substr(0,1)==l&&(b=b.substring(1,b.length));c=b+n+d}if(o&&-1!=k.indexOf("-")&&(0!=e||0!=d))c="-"+c;h&&(c=h+c);i&&(c+=i);return c}function f(){var a=e.val(),b=g(a);a!=b&&e.val(b)}function p(){if(""!=d.trim(h)&&q){var a=e.val().split(h);e.val(a[1])}}function r(){if(""!=d.trim(i)&&s){var a=e.val().split(i);e.val(a[0])}}var e=d(this),t=/[0-9]/,h=a.prefix,i=a.suffix,n=a.centsSeparator,l=a.thousandsSeparator,m=a.limit,j=a.centsLimit,q=
a.clearPrefix,s=a.clearSuffix,o=a.allowNegative;d(this).bind("keydown",function(a){var b=a.keyCode?a.keyCode:a.which,d=String.fromCharCode(b),c=!1,f=e.val(),d=g(f+d);if(48<=b&&57>=b||96<=b&&105>=b)c=!0;8==b&&(c=!0);9==b&&(c=!0);13==b&&(c=!0);46==b&&(c=!0);37==b&&(c=!0);39==b&&(c=!0);if(o&&(189==b||109==b))c=!0;c||(a.preventDefault(),a.stopPropagation(),f!=d&&e.val(d))});d(this).bind("keyup",f);q&&(d(this).bind("focusout",function(){p()}),d(this).bind("focusin",function(){var a=e.val();e.val(h+a)}));
s&&(d(this).bind("focusout",function(){r()}),d(this).bind("focusin",function(){var a=e.val();e.val(a+i)}));0<d(this).val().length&&(f(),p(),r())})};jQuery.fn.unmask=function(){var a=d(this).val(),g="",f;for(f in a)if(!isNaN(a[f])||"-"==a[f])g+=a[f];return g}})(jQuery);