//Product: InputMask
//Company: Data Research Group
//Website: http://www.assistedsolutions.com/components/InputMask
//Release: 3.5.1
//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 DRG_InputMask_LastObj;var DRG_InputMask_PerformingEvent=false;window.DRG_InputMask_LoadMethods=DRG_InputMask_LoadMethods;DRG_InputMask_AddHandler(window,"load","DRG_InputMask_LoadMethods");function DRG_InputMask_LoadMethods(){for(var $a=0;$a<DRG_InputMask_Objects.length;$a++){var im=document.getElementById(DRG_InputMask_Objects[$a]);im.GetText=function(){return DRG_InputMask_FuncGetText(this);};im.GetTextUnMasked=function(){return DRG_InputMask_FuncGetTextUnMasked(this);};im.SetText=function($b){DRG_InputMask_FuncSetText(this,$b);};}};function DRG_InputMask_AddHandler($c,$d,$e,$f){var $g=function(e){$c[$e](e,$f);};if($c.addEventListener){$c.addEventListener($d,$g,false);}else if($c.attachEvent){$c.attachEvent("on"+$d,$g);}else{var $h=$c["on"+$d];if($h){$g=function(e){$h(e);$c[$e](e,$f);};};$c["on"+$d]=$g;}};function DRG_InputMask_OnInput(event,obj){DRG_InputMask_ValidateContent(obj);DRG_InputMask_PutCaretPos(obj,DRG_InputMask_GetSelectionStart(obj));};function DRG_InputMask_ValidateContent(obj){var $i="";var NewValue=obj.value;var $j=obj.getAttribute("mask");var $k=obj.getAttribute("maskAlpha");var $l=obj.getAttribute("maskNumeric");var $m=obj.getAttribute("maskAlphaNumeric");var $n=obj.getAttribute("maskDisplay");for(var i=0;i<$j.length;i++){if($j.substring(i,(i+1))==$k){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){$i+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{$i+=$n;}}else if($j.substring(i,(i+1))==$l){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){$i+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{$i+=$n;}}else if($j.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.substring(0,1).charCodeAt(0)>=48&&NewValue.substring(0,1).charCodeAt(0)<=57)))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$i+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{$i+=$n;}}else{$i+=$j.substring(i,(i+1));}};obj.value=$i;};function DRG_InputMask_ValidatePos(pos,obj){if(obj==null){obj=DRG_InputMask_LastObj;};DRG_InputMask_PutCaretPos(obj,pos);};function DRG_InputMask_OnPaste(obj){var NewValue=window.clipboardData.getData("Text");var pos=DRG_InputMask_PlaceInMask(obj,NewValue);DRG_InputMask_LastObj=obj;window.setTimeout("DRG_InputMask_ValidatePos("+pos+")",10);DRG_InputMask_StopEvent(event);};function DRG_InputMask_OnCut(obj){var $o=DRG_InputMask_GetSelectionStart(obj);var $p=DRG_InputMask_GetSelectionEnd(obj);if($o+$p==obj.value.length){window.clipboardData.setData("Text",obj.value);obj.value="";DRG_InputMask_GotFocus(obj);}else{var $n=obj.getAttribute("maskDisplay");window.clipboardData.setData("Text",obj.value.substring($o,($o+1)));DRG_InputMask_UpdateChar(obj,$o,$n);DRG_InputMask_PutCaretPos(obj,$o);};DRG_InputMask_StopEvent(event);};function DRG_InputMask_MakeProperCase(obj,$b){if(obj.getAttribute("ForceCase")!=null){if(obj.getAttribute("ForceCase").toLowerCase()=="upper"){return $b.toUpperCase();}else{return $b.toLowerCase();}}else{return $b;}};function DRG_InputMask_PlaceInMask(obj,NewValue){var $i="";var OriginalNewValue=NewValue;NewValue=DRG_InputMask_MakeProperCase(obj,NewValue);if(NewValue.length>0){var $j=obj.getAttribute("mask");var $k=obj.getAttribute("maskAlpha");var $l=obj.getAttribute("maskNumeric");var $m=obj.getAttribute("maskAlphaNumeric");var $n=obj.getAttribute("maskDisplay");var CurrentPos=DRG_InputMask_GetSelectionStart(obj);var $q=true;obj.setAttribute("inEvent",true);if(obj.getAttribute("ClientSideOnBeforeInsert")!=null&&obj.getAttribute("ClientSideOnBeforeInsert").length>0){DRG_InputMask_PerformingEvent=true;$q=eval(obj.getAttribute("ClientSideOnBeforeInsert")+"(obj, NewValue, CurrentPos)");DRG_InputMask_PerformingEvent=false;};if($q){$i+=obj.value.substring(0,CurrentPos);for(var i=CurrentPos;i<$j.length;i++){if($j.substring(i,(i+1))==$k){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){$i+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{break;}}else if($j.substring(i,(i+1))==$l){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){$i+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{break;}}else if($j.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.substring(0,1).charCodeAt(0)>=48&&NewValue.substring(0,1).charCodeAt(0)<=57)))){NewValue=NewValue.substring(1);};if(NewValue.length>0){$i+=NewValue.substring(0,1);NewValue=NewValue.substring(1);}else{break;}}else{$i+=$j.substring(i,(i+1));}};$i+=obj.value.substring(i,$j.length);if(obj.getAttribute("ClientSideOnAfterInsert")!=null){DRG_InputMask_PerformingEvent=true;eval(obj.getAttribute("ClientSideOnAfterInsert")+"(obj, OriginalNewValue, CurrentPos)");DRG_InputMask_PerformingEvent=false;};obj.value=$i;return i;}else{return CurrentPos;}}else{return DRG_InputMask_GetSelectionStart(obj);;}};function DRG_InputMask_LostFocus(obj){if(!DRG_InputMask_PerformingEvent){var $j=obj.getAttribute("mask");if($j!=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 $j=obj.getAttribute("mask");if($j!=null&&$j.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 $j=obj.getAttribute("mask");if($j!=null&&$j.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){DRG_InputMask_PerformingEvent=false;obj.removeAttribute("inEvent");};function DRG_InputMask_GotFocus(obj){if(!DRG_InputMask_PerformingEvent&&obj.getAttribute("inEvent")==null){var $j=obj.getAttribute("mask");if($j!=null&&$j.length>0){var $r=DRG_InputMask_GetSelectionStart(obj);var pos=DRG_InputMask_GetValidPos(obj,$r);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 $j=obj.getAttribute("mask");if($j!=null&&$j.length>0){var $s=DRG_InputMask_GetSelectionStart(obj);DRG_InputMask_PutCaretPos(obj,$s);};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 $o=DRG_InputMask_GetSelectionStart(obj);var $p=DRG_InputMask_GetSelectionEnd(obj);if($o==0&&$p==obj.value.length){obj.value=DRG_InputMask_GetDisplayMask(obj,true);DRG_InputMask_PushPosBegin(obj);}else{var $n=obj.getAttribute("maskDisplay");DRG_InputMask_UpdateChar(obj,$o,$n);DRG_InputMask_PutCaretPos(obj,$o+1);}};function DRG_InputMask_KeyBackspace(obj){var $o=DRG_InputMask_GetSelectionStart(obj);var $p=DRG_InputMask_GetSelectionEnd(obj);if($o==0&&$p==obj.value.length){obj.value=DRG_InputMask_GetDisplayMask(obj,true);DRG_InputMask_PushPosBegin(obj);}else{var $n=obj.getAttribute("maskDisplay");DRG_InputMask_UpdateChar(obj,$o,$n);pos=DRG_InputMask_GetValidPos(obj,$o-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 $t=obj.getAttribute("maskDisplay");if(obj.value.length>0){for(var sp=0;sp<obj.value.length;sp++){if(DRG_InputMask_PosIsValid(obj,sp)&&obj.value.substring(sp,(sp+1))==$t){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 $t=obj.getAttribute("maskDisplay");if(obj.value.length>0){for(var sp=(obj.value.length-1);sp>=0;sp--){if(DRG_InputMask_PosIsValid(obj,sp)&&obj.value.substring(sp,(sp+1))==$t){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 $q=true;obj.setAttribute("inEvent",true);if(obj.getAttribute("ClientSideOnBeforeInsert")!=null){DRG_InputMask_PerformingEvent=true;$q=eval(obj.getAttribute("ClientSideOnBeforeInsert")+"(obj, ks, pos)");DRG_InputMask_PerformingEvent=false;};if($q){DRG_InputMask_UpdateChar(obj,pos,ks);if(obj.getAttribute("ClientSideOnAfterInsert")!=null){DRG_InputMask_PerformingEvent=true;eval(obj.getAttribute("ClientSideOnAfterInsert")+"(obj, ks, pos)");DRG_InputMask_PerformingEvent=false;}};return $q;};function DRG_InputMask_UpdateChar(obj,pos,ks){ks=DRG_InputMask_MakeProperCase(obj,ks);var x=obj.value;var $u=x.substring(0,pos);var $v=x.substring(pos+1,x.length);obj.value=$u+ks+$v;};function DRG_InputMask_PutCaretPos(obj,pos,$w){DRG_InputMask_PerformingEvent=true;if(pos<=0){pos=0;};if(pos>=obj.value.length-1){pos=obj.value.length-1;};pos=DRG_InputMask_GetValidPos(obj,pos,$w);if(pos!=-1){if(obj.createTextRange){var $x=obj.createTextRange();$x.moveStart("character",pos);$x.moveEnd('character',pos+1-obj.value.length);$x.select();}else if(obj.setSelectionRange){obj.focus();obj.setSelectionRange(pos,pos+1);}}else{obj.blur();};DRG_InputMask_PerformingEvent=false;};function DRG_InputMask_SelectAll(obj){var pos=0;if(obj.createTextRange){var $x=obj.createTextRange();$x.moveStart("character",pos);$x.moveEnd('character',pos+obj.value.length);$x.select();}else if(obj.setSelectionRange){obj.focus();obj.setSelectionRange(pos,pos+obj.value.length);}};function DRG_InputMask_GetValidPos(obj,pos,$w){if($w==null){$w=false;};if(DRG_InputMask_PosIsValid(obj,pos)){return pos;}else{var $j=obj.getAttribute("mask");if($w){while(pos>=0){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos=pos-1;}while(pos<$j.length-1){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos=pos+1;}}else{while(pos<$j.length-1){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos=pos+1;}while(pos>=0){if(DRG_InputMask_PosIsValid(obj,pos)){return pos;};pos=pos-1;}};return -1;}};function DRG_InputMask_PosIsValid(obj,pos){var $j=obj.getAttribute("mask");var m=$j.split("");if(m.length>pos){if(m[pos]!=null){var $k=obj.getAttribute("maskAlpha");var $l=obj.getAttribute("maskNumeric");var $m=obj.getAttribute("maskAlphaNumeric");if(m[pos]==$k||m[pos]==$l||m[pos]==$m){return true;}else{return false;}}else{return false;}}else{return false;}};function DRG_InputMask_KeyIsValid(obj,pos,$y){var m=obj.getAttribute("mask").split("");if(m.length>pos){var $z=m[pos];var $A=obj.getAttribute("maskAlpha");var $B=obj.getAttribute("maskNumeric");var $C=obj.getAttribute("maskAlphaNumeric");if($z==$A){if(($y>=65&&$y<=90)||($y>=97&&$y<=122)){return true;}else{return false;}}else if($z==$B){if($y>=48&&$y<=57){return true;}else{return false;}}else if($z==$C){if(($y>=48&&$y<=57)||($y>=65&&$y<=90)||($y>=97&&$y<=122)){return true;}else{return false;}}else{return false;}}else{return false;}};function DRG_InputMask_GetSelectionStart(obj){if(obj.createTextRange){$D=document.selection.createRange().duplicate();$D.moveEnd("character",obj.value.length);var pos=obj.value.lastIndexOf($D.text);if($D.text==""){pos=obj.value.length;if(pos==2147483647){pos=0;}};return pos;}else{var pos=obj.selectionStart;if(pos==2147483647){pos=0;};return pos;}};function DRG_InputMask_GetSelectionEnd(obj){if(obj.createTextRange){$D=document.selection.createRange().duplicate();$D.moveStart("character",-obj.value.length);pos=$D.text.length;return pos;}else{return obj.selectionEnd;}};function DRG_InputMask_GetDisplayMask(obj,$E){var $j=obj.getAttribute("mask");if($E==true){var f="";var $k=obj.getAttribute("maskAlpha");var $l=obj.getAttribute("maskNumeric");var $m=obj.getAttribute("maskAlphaNumeric");var $n=obj.getAttribute("maskDisplay");var m=$j.split("");for(var mi=0;mi<m.length;mi++){if(m[mi]==$k||m[mi]==$l||m[mi]==$m){f+=$n;}else{f+=m[mi];}};return f;}else{return $j;}};function DRG_InputMask_FuncSetText(obj,$b){DRG_InputMask_PerformingEvent=true;obj.setAttribute("inEvent",true);var $F=DRG_InputMask_GetDisplayMask(obj,true);obj.focus();obj.value=$F;DRG_InputMask_PushPosBegin(obj);DRG_InputMask_PlaceInMask(obj,$b);if(obj.value==$F){obj.value="";};obj.blur();DRG_InputMask_ResetFlags(obj);};function DRG_InputMask_FuncGetText(obj){return obj.value;};function DRG_InputMask_FuncGetTextUnMasked(obj){var $G="";var $H=obj.getAttribute("mask");if($H!=null){var $k=obj.getAttribute("maskAlpha");var $l=obj.getAttribute("maskNumeric");var $m=obj.getAttribute("maskAlphaNumeric");var $n=obj.getAttribute("maskDisplay");for(var cp=0;cp<$H.length;cp++){if(obj.value.length>cp){var $I=$H.substring(cp,cp+1);if($I==$k||$I==$l||$I==$m){var $z=obj.value.substring(cp,cp+1);if($z!=$n){$G+=$z;}}}else{break;}}};return $G;}
