/*
 * This file contains both original and merged/adapted code.
 * Except where indicated, all code is
 * Copyright (c) 2006-2010 vAuto, Inc., and its Affiliates.
 * All Rights Reserved.
 * Not to be reused without permission
 */
var NS="realdeal";if(typeof (window[NS]==="undefined")){window[NS]={}}NS=window[NS];NS.apply=function(C,D,B){if(B){NS.apply(C,B)}if(C&&D&&typeof D=="object"){for(var A in D){C[A]=D[A]}}return C};NS.apply(NS,{namespace:function(){var B=arguments,G=null,E,C,F,A;var D=[];for(E=0;E<B.length;++E){F=B[E].split(".");A=F[0];if(typeof (window[A])==="undefined"){window[A]=[]}G=window[A];for(C=1;C<F.length;++C){G[F[C]]=G[F[C]]||{};G=G[F[C]]}D.push(G)}return(B.length===1)?D[0]:D}});NS.apply(Function.prototype,{createDelegate:function(C,B,A){var D=this;return function(){var F=B||arguments;if(A===true){F=Array.prototype.slice.call(arguments,0);F=F.concat(B)}else{if(typeof A=="number"){F=Array.prototype.slice.call(arguments,0);var E=[A,0].concat(B);Array.prototype.splice.apply(F,E)}}return D.apply(C||window,F)}}});(function(A){A.fn.mask=function(C){this.unmask();if(this.css("position")=="static"){this.addClass("masked-relative")}this.addClass("masked");var D=A('<div class="loadmask"></div>');if(navigator.userAgent.toLowerCase().indexOf("msie")>-1){D.height(this.height()+parseInt(this.css("padding-top"))+parseInt(this.css("padding-bottom")));D.width(this.width()+parseInt(this.css("padding-left"))+parseInt(this.css("padding-right")))}if(navigator.userAgent.toLowerCase().indexOf("msie 6")>-1){this.find("select").addClass("masked-hidden")}this.append(D);if(typeof C=="string"){var B=A('<div class="loadmask-msg" style="display:none;"></div>');B.append("<div>"+C+"</div>");this.append(B);B.css("top",Math.round(this.height()/2-(B.height()-parseInt(B.css("padding-top"))-parseInt(B.css("padding-bottom")))/2)+"px");B.css("left",Math.round(this.width()/2-(B.width()-parseInt(B.css("padding-left"))-parseInt(B.css("padding-right")))/2)+"px");B.show()}};A.fn.unmask=function(B){this.find(".loadmask-msg,.loadmask").remove();this.removeClass("masked");this.removeClass("masked-relative");this.find("select").removeClass("masked-hidden")}})(jQuery);(function(C){var A=(C.browser.msie?"paste":"input")+".mask";var B=(window.orientation!=undefined);C.mask={definitions:{"9":"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"}};C.fn.extend({caret:function(F,D){if(this.length==0){return }if(typeof F=="number"){D=(typeof D=="number")?D:F;return this.each(function(){if(this.setSelectionRange){this.focus();this.setSelectionRange(F,D)}else{if(this.createTextRange){var G=this.createTextRange();G.collapse(true);G.moveEnd("character",D);G.moveStart("character",F);G.select()}}})}else{if(this[0].setSelectionRange){F=this[0].selectionStart;D=this[0].selectionEnd}else{if(document.selection&&document.selection.createRange){var E=document.selection.createRange();F=0-E.duplicate().moveStart("character",-100000);D=F+E.text.length}}return{begin:F,end:D}}},unmask:function(){return this.trigger("unmask")},mask:function(F,J){if(!F&&this.length>0){var G=C(this[0]);var I=G.data("tests");return C.map(G.data("buffer"),function(M,L){return I[L]?M:null}).join("")}J=C.extend({placeholder:"_",completed:null},J);var E=C.mask.definitions;var I=[];var K=F.length;var H=null;var D=F.length;C.each(F.split(""),function(L,M){if(M=="?"){D--;K=L}else{if(E[M]){I.push(new RegExp(E[M]));if(H==null){H=I.length-1}}else{I.push(null)}}});return this.each(function(){var U=C(this);var P=C.map(F.split(""),function(Y,X){if(Y!="?"){return E[Y]?J.placeholder:Y}});var S=false;var W=U.val();U.data("buffer",P).data("tests",I);function T(X){while(++X<=D&&!I[X]){}return X}function O(Z){while(!I[Z]&&--Z>=0){}for(var Y=Z;Y<D;Y++){if(I[Y]){P[Y]=J.placeholder;var X=T(Y);if(X<D&&I[Y].test(P[X])){P[Y]=P[X]}else{break}}}R();U.caret(Math.max(H,Z))}function L(b){for(var Z=b,a=J.placeholder;Z<D;Z++){if(I[Z]){var X=T(Z);var Y=P[Z];P[Z]=a;if(X<D&&I[X].test(Y)){a=Y}else{break}}}}function Q(Y){var Z=C(this).caret();var X=Y.keyCode;S=(X<16||(X>16&&X<32)||(X>32&&X<41));if((Z.begin-Z.end)!=0&&(!S||X==8||X==46)){M(Z.begin,Z.end)}if(X==8||X==46||(B&&X==127)){O(Z.begin+(X==46?0:-1));return false}else{if(X==27){U.val(W);U.caret(0,N());return false}}}function V(a){if(S){S=false;return(a.keyCode==8)?false:null}a=a||window.event;var X=a.charCode||a.keyCode||a.which;var d=C(this).caret();if(a.ctrlKey||a.altKey||a.metaKey){return true}else{if((X>=32&&X<=125)||X>186){var Z=T(d.begin-1);if(Z<D){var b=String.fromCharCode(X);if(I[Z].test(b)){L(Z);P[Z]=b;R();var Y=T(Z);C(this).caret(Y);if(J.completed&&Y==D){J.completed.call(U)}}}}}return false}function M(Z,X){for(var Y=Z;Y<X&&Y<D;Y++){if(I[Y]){P[Y]=J.placeholder}}}function R(){return U.val(P.join("")).val()}function N(Y){var d=U.val();var b=-1;for(var X=0,a=0;X<D;X++){if(I[X]){P[X]=J.placeholder;while(a++<d.length){var Z=d.charAt(a-1);if(I[X].test(Z)){P[X]=Z;b=X;break}}if(a>d.length){break}}else{if(P[X]==d[a]&&X!=K){a++;b=X}}}if(!Y&&b+1<K){U.val("");M(0,D)}else{if(Y||b+1>=K){R();if(!Y){U.val(U.val().substring(0,b+1))}}}return(K?X:H)}if(!U.attr("readonly")){U.one("unmask",function(){U.unbind(".mask").removeData("buffer").removeData("tests")}).bind("focus.mask",function(){W=U.val();var X=N();R();setTimeout(function(){if(X==F.length){U.caret(0,X)}else{U.caret(X)}},0)}).bind("blur.mask",function(){N();if(U.val()!=W){U.change()}}).bind("keydown.mask",Q).bind("keypress.mask",V).bind(A,function(){setTimeout(function(){U.caret(N(true))},0)})}N()})}})})(jQuery);