
//Product: InputMask
//Company: Data Research Group
//Website: http://www.assistedsolutions.com/components/InputMask
//Release: 3.5
//This component has been copyrighted by Data Research Group.  It is not to be altered
//or distributed, except as part of an application.  This product requires a license for
//all usage.  Visit http://www.assistedsolutions.com/store for more information.

var $a;var $b=false;window.DRG_InputMask_LoadMethods=DRG_InputMask_LoadMethods;DRG_InputMask_AddHandler(window,"load","DRG_InputMask_LoadMethods");function DRG_InputMask_LoadMethods(){for($c=0;$c<DRG_InputMask_Objects.length;$c++){var im=document.getElementById(DRG_InputMask_Objects[$c]);im.GetText=function(){return DRG_InputMask_FuncGetText(this);};im.GetTextUnMasked=function(){return DRG_InputMask_FuncGetTextUnMasked(this);};im.SetText=function($d){DRG_InputMask_FuncSetText(this,$d);};}};function DRG_InputMask_AddHandler($e,$f,$g,$h){var $i=function(e){$e[$g](e,$h);};if($e.addEventListener){$e.addEventListener($f,$i,false);}else if($e.attachEvent){$e.attachEvent("on"+$f,$i);}else{var $j=$e["on"+$f];if($j){$i=function(e){$j(e);$e[$g](e,$h);};};$e["on"+$f]=$i;}};function DRG_InputMask_OnInput(event,obj){DRG_InputMask_ValidateContent(obj);DRG_InputMask_PutCaretPos(obj,DRG_InputMask_GetSelectionStart(obj));};function DRG_InputMask_ValidateContent(obj){var $k="";var NewValue=obj.value;var $l=obj.getAttribute("mask");var $m=obj.getAttribute("maskAlpha");var $n=obj.getAttribute("maskNumeric");var $o=obj.getAttribute("maskAlphaNumeric");var $p=obj.getAttribute("maskDisplay");for(i=0;i<$l.length;i++){if($l.substring(i,(i+1))==$m){while(NewValue.length>0&&(!((NewValue.substring(0,1).charCodeAt(0)>=65&&NewValue.substring(0,1).charCodeAt(0)<=90)||(NewValue.substring(0,1).charCodeAt(0)>=97&&NewValue.substring(0,1).charCodeAt(0)<=122)))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$k+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{$k+=$p;}}else if($l.substring(i,(i+1))==$n){while(NewValue.length>0&&(!(NewValue.substring(0,1).charCodeAt(0)>=48&&NewValue.substring(0,1).charCodeAt(0)<=57))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$k+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{$k+=$p;}}else if($l.substring(i,(i+1))==$o){while(NewValue.length>0&&(!((NewValue.substring(0,1).charCodeAt(0)>=65&&NewValue.substring(0,1).charCodeAt(0)<=90)||(NewValue.substring(0,1).charCodeAt(0)>=97&&NewValue.substring(0,1).charCodeAt(0)<=122)||(NewValue.substring(0,1).charCodeAt(0)>=48&&NewValue.substring(0,1).charCodeAt(0)<=57)))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$k+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{$k+=$p;}}else{$k+=$l.substring(i,(i+1));}};obj.value=$k;};function DRG_InputMask_ValidatePos(pos,obj){if(obj==null){obj=$a;};DRG_InputMask_PutCaretPos(obj,pos);};function DRG_InputMask_OnPaste(obj){var NewValue=window.clipboardData.getData("Text");var pos=DRG_InputMask_PlaceInMask(obj,NewValue);$a=obj;window.setTimeout("DRG_InputMask_ValidatePos("+pos+")",10);DRG_InputMask_StopEvent(event);};function DRG_InputMask_OnCut(obj){var $q=DRG_InputMask_GetSelectionStart(obj);var $r=DRG_InputMask_GetSelectionEnd(obj);if($q+$r==obj.value.length){window.clipboardData.setData("Text",obj.value);obj.value="";DRG_InputMask_GotFocus(obj);}else{var $p=obj.getAttribute("maskDisplay");window.clipboardData.setData("Text",obj.value.substring($q,($q+1)));DRG_InputMask_UpdateChar(obj,$q,$p);DRG_InputMask_PutCaretPos(obj,$q);};DRG_InputMask_StopEvent(event);};function DRG_InputMask_MakeProperCase(obj,$d){if(obj.getAttribute("ForceCase")!=null){if(obj.getAttribute("ForceCase").toLowerCase()=="upper"){return $d.toUpperCase();}else{return $d.toLowerCase();}}else{return $d;}};function DRG_InputMask_PlaceInMask(obj,NewValue){var $k="";var OriginalNewValue=NewValue;NewValue=DRG_InputMask_MakeProperCase(obj,NewValue);if(NewValue.length>0){var $l=obj.getAttribute("mask");var $m=obj.getAttribute("maskAlpha");var $n=obj.getAttribute("maskNumeric");var $o=obj.getAttribute("maskAlphaNumeric");var $p=obj.getAttribute("maskDisplay");var CurrentPos=DRG_InputMask_GetSelectionStart(obj);var $s=true;obj.setAttribute("inEvent",true);if(obj.getAttribute("ClientSideOnBeforeInsert")!=null&&obj.getAttribute("ClientSideOnBeforeInsert").length>0){$b=true;$s=eval(obj.getAttribute("ClientSideOnBeforeInsert")+"(obj, NewValue, CurrentPos)");$b=false;};if($s){$k+=obj.value.substring(0,CurrentPos);for(i=CurrentPos;i<$l.length;i++){if($l.substring(i,(i+1))==$m){while(NewValue.length>0&&(!((NewValue.substring(0,1).charCodeAt(0)>=65&&NewValue.substring(0,1).charCodeAt(0)<=90)||(NewValue.substring(0,1).charCodeAt(0)>=97&&NewValue.substring(0,1).charCodeAt(0)<=122)))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$k+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{break;}}else if($l.substring(i,(i+1))==$n){while(NewValue.length>0&&(!(NewValue.substring(0,1).charCodeAt(0)>=48&&NewValue.substring(0,1).charCodeAt(0)<=57))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$k+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{break;}}else if($l.substring(i,(i+1))==$o){while(NewValue.length>0&&(!((NewValue.substring(0,1).charCodeAt(0)>=65&&NewValue.substring(0,1).charCodeAt(0)<=90)||(NewValue.substring(0,1).charCodeAt(0)>=97&&NewValue.substring(0,1).charCodeAt(0)<=122)||(NewValue.substring(0,1).charCodeAt(0)>=48&&NewValue.substring(0,1).charCodeAt(0)<=57)))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$k+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{break;}}else{$k+=$l.substring(i,(i+1));}};$k+=obj.value.substring(i,$l.length);if(obj.getAttribute("ClientSideOnAfterInsert")!=null){$b=true;eval(obj.getAttribute("ClientSideOnAfterInsert")+"(obj, OriginalNewValue, CurrentPos)");$b=false;};obj.value=$k;return i;}else{return CurrentPos;}}else{return DRG_InputMask_GetSelectionStart(obj);;}};function DRG_InputMask_LostFocus(obj){if(!$b){var $l=obj.getAttribute("mask");if($l!=null&&obj.value==DRG_InputMask_GetDisplayMask(obj,true)){obj.value="";};if(obj.getAttribute("ClientSideOnLostFocus")!=null){eval(obj.getAttribute("ClientSideOnLostFocus")+"(obj)");};DRG_InputMask_ResetFlags(obj);}};function DRG_InputMask_KeyDown(event,obj){var $l=obj.getAttribute("mask");if($l!=null&&$l.length>0){var k=DRG_InputMask_GetKeyCode(event);if(k==8||(k>=33&&k<=40)||k==46){switch(k){case 8:DRG_InputMask_KeyBackspace(obj);break;case 33:DRG_InputMask_PushPosBegin(obj);break;case 34:DRG_InputMask_PushPosEnd(obj);break;case 35:DRG_InputMask_PushPosEnd(obj);break;case 36:DRG_InputMask_PushPosBegin(obj);break;case 37:DRG_InputMask_PushPosLeft(obj);break;case 38:DRG_InputMask_PushPosLeft(obj);break;case 39:DRG_InputMask_PushPosRight(obj);break;case 40:DRG_InputMask_PushPosRight(obj);break;case 46:DRG_InputMask_KeyDelete(obj);break;};DRG_InputMask_StopEvent(event);}}};function DRG_InputMask_KeyPress(event,obj){var $l=obj.getAttribute("mask");if($l!=null&&$l.length>0){var kc=DRG_InputMask_GetKeyCode(event);var ss=DRG_InputMask_GetSelectionStart(obj);if(kc!=9){if(DRG_InputMask_KeyIsValid(obj,ss,kc)){var ks=String.fromCharCode(kc);if(DRG_InputMask_UpdateCharWEvent(obj,ss,ks)){DRG_InputMask_PutCaretPos(obj,ss+1);}else{DRG_InputMask_PutCaretPos(obj,ss);}}else{if(ss==0&&DRG_InputMask_GetSelectionEnd(obj)==obj.value.length){DRG_InputMask_PushPosBegin(obj);var ss=DRG_InputMask_GetSelectionStart(obj);if(DRG_InputMask_KeyIsValid(obj,ss,kc)){var ks=String.fromCharCode(kc);if(DRG_InputMask_UpdateCharWEvent(obj,ss,ks)){DRG_InputMask_PutCaretPos(obj,ss+1);}else{DRG_InputMask_PutCaretPos(obj,ss);}}}};DRG_InputMask_StopEvent(event);}}};function DRG_InputMask_StopEvent(event){if(document.all){event.returnValue=false;}else if(event.preventDefault){event.preventDefault();}};function DRG_InputMask_StopEventPropagation(event){event.cancelBubble=true;if(event.stopPropagation){event.stopPropagation();}};function DRG_InputMask_ResetFlags(obj){$b=false;obj.removeAttribute("inEvent");};function DRG_InputMask_GotFocus(obj){if(!$b&&obj.getAttribute("inEvent")==null){var $l=obj.getAttribute("mask");if($l!=null&&$l.length>0){var $t=DRG_InputMask_GetSelectionStart(obj);var pos=DRG_InputMask_GetValidPos(obj,$t);if(pos!=-1){if(obj.value==null||obj.value.length==0){obj.value=DRG_InputMask_GetDisplayMask(obj,true);};if(obj.getAttribute("CursorStartLocation")!=null){if(obj.getAttribute("CursorStartLocation").toLowerCase()=="selectall"){DRG_InputMask_SelectAll(obj);}else if(obj.getAttribute("CursorStartLocation").toLowerCase()=="first"){DRG_InputMask_PushPosBegin(obj);}else if(obj.getAttribute("CursorStartLocation").toLowerCase()=="firstempty"){DRG_InputMask_PushPosFirstEmpty(obj);}else if(obj.getAttribute("CursorStartLocation").toLowerCase()=="last"){DRG_InputMask_PushPosEnd(obj);}else if(obj.getAttribute("CursorStartLocation").toLowerCase()=="lastempty"){DRG_InputMask_PushPosLastEmpty(obj);}else{DRG_InputMask_PutCaretPos(obj,pos);}}else{DRG_InputMask_PutCaretPos(obj,pos);}}else{obj.blur();}};if(obj.getAttribute("ClientSideOnGotFocus")!=null){eval(obj.getAttribute("ClientSideOnGotFocus")+"(obj)");};DRG_InputMask_StopEvent(event);}};function DRG_InputMask_OnClick(event,obj){var $l=obj.getAttribute("mask");if($l!=null&&$l.length>0){var $u=DRG_InputMask_GetSelectionStart(obj);DRG_InputMask_PutCaretPos(obj,$u);};DRG_InputMask_StopEventPropagation(event);};function DRG_InputMask_GetKeyCode(event){return(event.keyCode?event.keyCode:event.which?event.which:event.charCode);};function DRG_InputMask_KeyDelete(obj){var $q=DRG_InputMask_GetSelectionStart(obj);var $r=DRG_InputMask_GetSelectionEnd(obj);if($q==0&&$r==obj.value.length){obj.value=DRG_InputMask_GetDisplayMask(obj,true);DRG_InputMask_PushPosBegin(obj);}else{var $p=obj.getAttribute("maskDisplay");DRG_InputMask_UpdateChar(obj,$q,$p);DRG_InputMask_PutCaretPos(obj,$q+1);}};function DRG_InputMask_KeyBackspace(obj){var $q=DRG_InputMask_GetSelectionStart(obj);var $r=DRG_InputMask_GetSelectionEnd(obj);if($q==0&&$r==obj.value.length){obj.value=DRG_InputMask_GetDisplayMask(obj,true);DRG_InputMask_PushPosBegin(obj);}else{var $p=obj.getAttribute("maskDisplay");DRG_InputMask_UpdateChar(obj,$q,$p);pos=DRG_InputMask_GetValidPos(obj,$q-1,true);DRG_InputMask_PutCaretPos(obj,pos);}};function DRG_InputMask_PushPosLeft(obj){var k=DRG_InputMask_GetSelectionStart(obj);if((k-1)>=0){DRG_InputMask_PutCaretPos(obj,(k-1),true);}};function DRG_InputMask_PushPosRight(obj){var k=DRG_InputMask_GetSelectionStart(obj);if((k+1)<obj.value.length){DRG_InputMask_PutCaretPos(obj,(k+1));}};function DRG_InputMask_PushPosFirstEmpty(obj){var $v=obj.getAttribute("maskDisplay");if(obj.value.length>0){for(sp=0;sp<obj.value.length;sp++){if(DRG_InputMask_PosIsValid(obj,sp)&&obj.value.substring(sp,(sp+1))==$v){DRG_InputMask_PutCaretPos(obj,sp);break;}}}else{DRG_InputMask_PushPosBegin(obj);}};function DRG_InputMask_PushPosBegin(obj){DRG_InputMask_PutCaretPos(obj,0);};function DRG_InputMask_PushPosLastEmpty(obj){var $v=obj.getAttribute("maskDisplay");if(obj.value.length>0){for(sp=(obj.value.length-1);sp>=0;sp--){if(DRG_InputMask_PosIsValid(obj,sp)&&obj.value.substring(sp,(sp+1))==$v){DRG_InputMask_PutCaretPos(obj,sp);break;}}}else{DRG_InputMask_PushPosBegin(obj);}};function DRG_InputMask_PushPosEnd(obj){DRG_InputMask_PutCaretPos(obj,obj.getAttribute("mask").length);};function DRG_InputMask_UpdateCharWEvent(obj,pos,ks){var $s=true;obj.setAttribute("inEvent",true);if(obj.getAttribute("ClientSideOnBeforeInsert")!=null){$b=true;$s=eval(obj.getAttribute("ClientSideOnBeforeInsert")+"(obj, ks, pos)");$b=false;};if($s){DRG_InputMask_UpdateChar(obj,pos,ks);if(obj.getAttribute("ClientSideOnAfterInsert")!=null){$b=true;eval(obj.getAttribute("ClientSideOnAfterInsert")+"(obj, ks, pos)");$b=false;}};return $s;};function DRG_InputMask_UpdateChar(obj,pos,ks){ks=DRG_InputMask_MakeProperCase(obj,ks);var x=obj.value;var $w=x.substring(0,pos);var $x=x.substring(pos+1,x.length);obj.value=$w+ks+$x;};function DRG_InputMask_PutCaretPos(obj,pos,$y){$b=true;if(pos<=0){pos=0;};if(pos>=obj.value.length-1){pos=obj.value.length-1;};pos=DRG_InputMask_GetValidPos(obj,pos,$y);if(pos!=-1){if(obj.createTextRange){var $z=obj.createTextRange();$z.moveStart("character",pos);$z.moveEnd('character',pos+1-obj.value.length);$z.select();}else if(obj.setSelectionRange){obj.focus();obj.setSelectionRange(pos,pos+1);}}else{obj.blur();};$b=false;};function DRG_InputMask_SelectAll(obj){var pos=0;if(obj.createTextRange){var $z=obj.createTextRange();$z.moveStart("character",pos);$z.moveEnd('character',pos+obj.value.length);$z.select();}else if(obj.setSelectionRange){obj.focus();obj.setSelectionRange(pos,pos+obj.value.length);}};function DRG_InputMask_GetValidPos(obj,pos,$y){if($y==null){$y=false;};if(DRG_InputMask_PosIsValid(obj,pos)){return pos;}else{var $l=obj.getAttribute("mask");if($y){while(pos>=0){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos--;}while(pos<$l.length-1){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos++;}}else{while(pos<$l.length-1){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos++;}while(pos>=0){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos--;}};return -1;}};function DRG_InputMask_PosIsValid(obj,pos){var $l=obj.getAttribute("mask");var m=$l.split("");if(m.length>pos){if(m[pos]!=null){var $m=obj.getAttribute("maskAlpha");var $n=obj.getAttribute("maskNumeric");var $o=obj.getAttribute("maskAlphaNumeric");if(m[pos]==$m||m[pos]==$n||m[pos]==$o){return true;}else{return false;}}else{return false;}}else{return false;}};function DRG_InputMask_KeyIsValid(obj,pos,$A){var m=obj.getAttribute("mask").split("");if(m.length>pos){var $B=m[pos];var $C=obj.getAttribute("maskAlpha");var $D=obj.getAttribute("maskNumeric");var $E=obj.getAttribute("maskAlphaNumeric");if($B==$C){if(($A>=65&&$A<=90)||($A>=97&&$A<=122)){return true;}else{return false;}}else if($B==$D){if($A>=48&&$A<=57){return true;}else{return false;}}else if($B==$E){if(($A>=48&&$A<=57)||($A>=65&&$A<=90)||($A>=97&&$A<=122)){return true;}else{return false;}}else{return false;}}else{return false;}};function DRG_InputMask_GetSelectionStart(obj){if(obj.createTextRange){$F=document.selection.createRange().duplicate();$F.moveEnd("character",obj.value.length);pos=obj.value.lastIndexOf($F.text);if($F.text=="")pos=obj.value.length;return pos;}else{return obj.selectionStart;}};function DRG_InputMask_GetSelectionEnd(obj){if(obj.createTextRange){$F=document.selection.createRange().duplicate();$F.moveStart("character",-obj.value.length);pos=$F.text.length;return pos;}else{return obj.selectionEnd;}};function DRG_InputMask_GetDisplayMask(obj,$G){var $l=obj.getAttribute("mask");if($G==true){var f="";var $m=obj.getAttribute("maskAlpha");var $n=obj.getAttribute("maskNumeric");var $o=obj.getAttribute("maskAlphaNumeric");var $p=obj.getAttribute("maskDisplay");var m=$l.split("");for(mi=0;mi<m.length;mi++){if(m[mi]==$m||m[mi]==$n||m[mi]==$o){f+=$p;}else{f+=m[mi];}};return f;}else{return $l;}};function DRG_InputMask_FuncSetText(obj,$d){$b=true;obj.setAttribute("inEvent",true);var $H=DRG_InputMask_GetDisplayMask(obj,true);obj.focus();obj.value=$H;DRG_InputMask_PushPosBegin(obj);DRG_InputMask_PlaceInMask(obj,$d);if(obj.value==$H){obj.value="";};obj.blur();DRG_InputMask_ResetFlags(obj);};function DRG_InputMask_FuncGetText(obj){return obj.value;};function DRG_InputMask_FuncGetTextUnMasked(obj){var $I="";var $J=obj.getAttribute("mask");if($J!=null){var $m=obj.getAttribute("maskAlpha");var $n=obj.getAttribute("maskNumeric");var $o=obj.getAttribute("maskAlphaNumeric");var $p=obj.getAttribute("maskDisplay");for(cp=0;cp<$J.length;cp++){if(obj.value.length>cp){var $K=$J.substring(cp,cp+1);if($K==$m||$K==$n||$K==$o){var $B=obj.value.substring(cp,cp+1);if($B!=$p){$I+=$B;}}}else{break;}}};return $I;}