/*----------------------------------------------------------------------------\
|                         Intekron JXP Common Controls                        |
|-----------------------------------------------------------------------------|
|                       (mailto:support@intekron.com)                         |
|                  For Intekron (http://www.intekron.com/)                    |
|-----------------------------------------------------------------------------|
|                   Copyright (c) 2003-2007 Intekron Ltd.                     |
|-----------------------------------------------------------------------------|
| This software is provided "as is", without warranty of any kind, express or |
| implied, including  but not limited  to the warranties of  merchantability, |
| fitness for a particular purpose and noninfringement. In no event shall the |
| authors or  copyright  holders be  liable for any claim,  damages or  other |
| liability, whether  in an  action of  contract, tort  or otherwise, arising |
| from,  out of  or in  connection with  the software or  the  use  or  other |
| dealings in the software.                                                   |
\----------------------------------------------------------------------------*/

//********************************************************************************
// CONTROL: ctlCommon - ABTSRACT BASE CLASS
//********************************************************************************
function ctlCommon(sID, bRequired, bReadonly, bVisible) {
	this.sID		= sID;
	this.bRequired	= bRequired;
	this.bReadonly	= bReadonly;
	this.bVisible	= bVisible;
	this.bDirty		= false;
}
ctlCommon.prototype.toString = function () { return ""; }
ctlCommon.prototype.focus = function () { OnFocus(this.getID()); }
ctlCommon.prototype.blur = function () { OnBlur(this.getID()); }
ctlCommon.prototype.click = function () { OnClick(this.getID()); }
ctlCommon.prototype.change = function () { this.bDirty = true;OnChange(this.getID()); }
ctlCommon.prototype.isVisible = function () { return this.bVisible; }
ctlCommon.prototype.isRequired = function () { return this.bRequired; }
ctlCommon.prototype.isReadonly = function () { return this.bReadonly; }
ctlCommon.prototype.isValid = function () { return true; }
ctlCommon.prototype.isDirty = function () { return this.bDirty; }
ctlCommon.prototype.clear = function () { this.bDirty = false; }
ctlCommon.prototype.show = function (bVal) { this.bVisible = bVal; }
ctlCommon.prototype.readonly = function (bVal) { this.bReadonly = bVal; }
ctlCommon.prototype.required = function (bVal) { this.bRequired = bVal; }
ctlCommon.prototype.getID = function () { return this.sID; }

//********************************************************************************
// CONTROL: ctlText
//********************************************************************************
function ctlText(sID, sInitValue, iLength, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.sValue 	= sInitValue;
	this.iLength	= iLength;
	zControls[zControls.length] = this;
}
ctlText.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return (oTXT ? oTXT.value : this.sValue);
}
ctlText.prototype.setValue = function (sNewValue) {
	this.sValue = sNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = this.sValue;
	this.change();
	oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlText.prototype.getLength = function () {
	return this.iLength;
}
ctlText.prototype.setLength = function (iNewLength) {
	this.iLength = iNewLength;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.maxLength = this.iLength;
}
// Inherited...
ctlText.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + this.sValue + "\" "
			+ (!this.isReadonly() ? "" : " tabindex=\"-1\" ")
			+ "maxlength=\"" + this.getLength() + "\" "
			+ "style=\"width:" + min(this.getLength() * 20, 325) + "px;display:" + (this.isVisible() ? "block": "none") + "\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	return str;
}
ctlText.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.focus();
		return this.base.focus();
	}
}
ctlText.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return this.base.blur();
	}
}
ctlText.prototype.click = function () { return this.base.click(); }
ctlText.prototype.change = function () { return this.base.change(); }
ctlText.prototype.isVisible = function () { return this.base.isVisible(); }
ctlText.prototype.isRequired = function () { return this.base.isRequired(); }
ctlText.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlText.prototype.isDirty = function () { return this.base.isDirty(); }
ctlText.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		if (oTXT.value.length == 0 && this.isRequired()) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else {
			oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
			return true;
		}
	}
	else {
		return true;
	}
}
ctlText.prototype.clear = function () { return this.base.clear(); }
ctlText.prototype.show = function (bVal) { document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlText.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlText.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlText.prototype.getToken = function () { return this.base.getToken(); }
ctlText.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlPassword
//********************************************************************************
function ctlPassword(sID, sInitValue, iLength, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.sValue 	= sInitValue;
	this.iLength	= iLength;
	zControls[zControls.length] = this;
}
ctlPassword.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return (oTXT ? oTXT.value : this.sValue);
}
ctlPassword.prototype.setValue = function (sNewValue) {
	this.sValue = sNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = this.sValue;
	this.change();
	oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlPassword.prototype.getLength = function () {
	return this.iLength;
}
ctlPassword.prototype.setLength = function (iNewLength) {
	this.iLength = iNewLength;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.maxLength = this.iLength;
}
// Inherited...
ctlPassword.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"password\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + this.sValue + "\" "
			+ (!this.isReadonly() ? "" : " tabindex=\"-1\" ")
			+ "maxlength=\"" + this.getLength() + "\" "
			+ "style=\"width:" + min(this.getLength() * 20, 325) + "px;\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	return str;
}
ctlPassword.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.focus();
		return this.base.focus();
	}
}
ctlPassword.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return this.base.blur();
	}
}
ctlPassword.prototype.click = function () { return this.base.click(); }
ctlPassword.prototype.change = function () { return this.base.change(); }
ctlPassword.prototype.isVisible = function () { return this.base.isVisible(); }
ctlPassword.prototype.isRequired = function () { return this.base.isRequired(); }
ctlPassword.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlPassword.prototype.isDirty = function () { return this.base.isDirty(); }
ctlPassword.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		if (oTXT.value.length == 0 && this.isRequired()) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else {
			oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
			return true;
		}
	}
	else {
		return true;
	}
}
ctlPassword.prototype.clear = function () { return this.base.clear(); }
ctlPassword.prototype.show = function (bVal) { document.getElementById('tr' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlPassword.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlPassword.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlPassword.prototype.getToken = function () { return this.base.getToken(); }
ctlPassword.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlTextArea
//********************************************************************************
function ctlTextArea(sID, sInitValue, iLength, iRows, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.sValue		= sInitValue.replace(/&#0A;/g,"\n").replace(/&#0D;/g,"\r");
	this.iLength	= iLength;
	this.iRows		= iRows;
	zControls[zControls.length] = this;
}
ctlTextArea.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? oTXT.value : this.sValue;
}
ctlTextArea.prototype.setValue = function (sNewValue) {
	this.sValue = sNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = this.sValue;
	this.change();
	oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlTextArea.prototype.getLength = function () {
	return this.iLength;
}
ctlTextArea.prototype.setLength = function (iNewLength) {
	this.iLength = iNewLength;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.maxLength = this.iLength;
}
ctlTextArea.prototype.getRows = function () {
	return this.iRows;
}
ctlTextArea.prototype.setRows = function (iNewRows) {
	this.iRows = iNewRows;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.rows = this.iRows;
}
// Inherited...
ctlTextArea.prototype.toString = function () {
	var str = this.base.toString();
	str += "<TEXTAREA "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "maxlength=\"" + this.getLength() + "\" "
			+ (!this.isReadonly() == false ? "" : " tabindex=\"-1\" ")
			+ "wrap=\"SOFT\" "
			+ "style=\"width:90%;\" "
			+ "cols=50 "
			+ "rows=" + this.getRows() + " "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += this.getValue();
	str += "</TEXTAREA>";
	return str;
}
ctlTextArea.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.focus();
		return this.base.focus();
	}
}
ctlTextArea.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return this.base.blur();
	}
}
ctlTextArea.prototype.click = function () { return this.base.click(); }
ctlTextArea.prototype.change = function () { return this.base.change(); }
ctlTextArea.prototype.isVisible = function () { return this.base.isVisible(); }
ctlTextArea.prototype.isRequired = function () { return this.base.isRequired(); }
ctlTextArea.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlTextArea.prototype.isDirty = function () { return this.base.isDirty(); }
ctlTextArea.prototype.isValid = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	if (oTXT.value.length == 0 && this.isRequired()) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else {
		oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return true;
	}
}
ctlTextArea.prototype.clear = function () { return this.base.clear(); }
ctlTextArea.prototype.show = function (bVal) { document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlTextArea.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlTextArea.prototype.required = function (bVal) {
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
	return this.base.required(bVal);
}
ctlTextArea.prototype.getToken = function () { return this.base.getToken(); }
ctlTextArea.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlDate
//********************************************************************************
function ctlDate(sID, sInitValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.sValue 	= sInitValue;		// YYYY-MM-DD
	zControls[zControls.length] = this;
}
ctlDate.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? oTXT.value.length > 0 ? DateToYYYYMMDD(oTXT.value) : "" : this.sValue;
}
ctlDate.prototype.setValue = function (sNewValue) {
	this.sValue = sNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = this.sValue.length > 0 ? YYYYMMDDToDate(this.sValue) : "";
	this.change();
	oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlDate.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ (!this.isReadonly() ? "" : "tabindex=\"-1\" ")
			+ "value=\"" + (this.getValue().length > 0 ? YYYYMMDDToDate(this.getValue()) : "") + "\" "
			+ "style=\"" + (this.base.isVisible() ? "" : "display:none;") + "width:90px;text-align:center;\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += "<BUTTON id=\"btn" + this.getID() + "\" class=\"ImageButton\" tabindex=\"-1\" onclick=\"" + this.getID() + ".click();return false;\" style=\"" + (this.base.isVisible() ? "" : "display:none;") + "visibility:" + (!this.isReadonly()?"visible":"hidden") + "\">";
	str += "<IMG align=\"middle\" style=\"cursor:pointer;\" SRC=\"../images/icons/date.png\"/>";
	str += "</BUTTON>";

	return str;
}
ctlDate.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.focus();
	}
	return this.base.focus();
}
ctlDate.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
	}
	return this.base.blur();
}
ctlDate.prototype.click = function () {
	ShowPopUp('../COMMON/calendarpopup.jsp;jsessionid=' + sSessionID + '?FORDATE=' + this.getValue(), 200, 235, 'parent.ctlDate_clickback("' + this.getID() + '")');
}
function ctlDate_clickback(sID) {
	var sChoice = popupReturnValue;
	if (sChoice != '') {
		var oCtl = eval(sID);
		oCtl.setValue(sChoice);
	}
}
ctlDate.prototype.change = function () { return this.base.change(); }
ctlDate.prototype.isVisible = function () { return this.base.isVisible(); }
ctlDate.prototype.isRequired = function () { return this.base.isRequired(); }
ctlDate.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlDate.prototype.isDirty = function () { return this.base.isDirty(); }
ctlDate.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		if (oTXT.value.length == 0 && this.isRequired()) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else if (oTXT.value.length > 0 && !isValidDate(oTXT.value)) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else {
			oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
			return true;
		}
	}
	else {
		return true;
	}
}
ctlDate.prototype.clear = function () { return this.base.clear(); }
ctlDate.prototype.show = function (bVal) { document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlDate.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var oBTN = document.getElementById('btn' + this.getID());
	oBTN.style.visibility = (!bVal?"visible":"hidden");
	return this.base.readonly(bVal);
}
ctlDate.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlDate.prototype.getToken = function () { return this.base.getToken(); }
ctlDate.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlDuration
//********************************************************************************
function ctlDuration(sID, fInitValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.fValue 	= fInitValue;
	zControls[zControls.length] = this;
}
ctlDuration.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? DurationToJSFloat(oTXT.value) : this.fValue;
}
ctlDuration.prototype.setValue = function (fNewValue) {
	this.fValue = fNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = formatDuration(this.fValue);
	this.change();
	oTXT.className = (!this.isReadonly() ? this.isValid() ? this.isRequired() ? 'INPUTREQUIRED' : '' : 'INPUTERROR' : 'INPUTREADONLY');
}
// Inherited...
ctlDuration.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ (!this.isReadonly() ? "" : "tabindex=\"-1\" ")
			+ "value=\"" + formatDuration(this.getValue()) + "\" "
			+ "style=\"width:80px;text-align:center;display:" + (this.isVisible() ? "block" : "none") + ";\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	return str;
}
ctlDuration.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
	}
	return this.base.focus();
}
ctlDuration.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		if (!this.isValid()) {
			oTXT.className = 'INPUTERROR';
		}
		else {
			if (this.isRequired()) {
				oTXT.className = 'INPUTREQUIRED';
			}
			else {
				oTXT.className = '';
			}
			this.setValue(this.getValue());
		}
	}
	return this.base.blur();
}
ctlDuration.prototype.change = function () { return this.base.change(); }
ctlDuration.prototype.isVisible = function () { return this.base.isVisible(); }
ctlDuration.prototype.isRequired = function () { return this.base.isRequired(); }
ctlDuration.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlDuration.prototype.isDirty = function () { return this.base.isDirty(); }
ctlDuration.prototype.isValid = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	if (oTXT.value.length == 0 && this.isRequired()) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else if (!isValidDuration(oTXT.value)) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else {
		oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return true;
	}
}
ctlDuration.prototype.clear = function () { return this.base.clear(); }
ctlDuration.prototype.show = function (bVal) { document.getElementById('tr' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlDuration.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlDuration.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlDuration.prototype.getToken = function () { return this.base.getToken(); }
ctlDuration.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlTime
//********************************************************************************
function ctlTime(sID, sInitValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.sValue 	= sInitValue;		// HH:MM:SS
	this.oMask		= new ctlTimeMask('txt' + this.getID());
	zControls[zControls.length] = this;
}
ctlTime.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? TimeToHHMMSS(oTXT.value) : this.sValue;
}
ctlTime.prototype.setValue = function (sNewValue) {
	this.sValue = sNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = HHMMSSToTime(this.sValue);
	this.change();
	oTXT.className = (!this.isReadonly() ? this.isValid() ? '' : 'INPUTERROR' : 'INPUTREADONLY');
}
// Inherited...
ctlTime.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + HHMMSSToTime(this.getValue()) + "\" "
			+ "style=\"position:relative;width:65px;text-align:center;\" "
			+ "onkeydown=\"" + this.getID() + ".keypressdown(" + (moz?"event":"") + ");\" "
			+ "onkeypress=\"" + this.getID() + ".keypress(" + (moz?"event":"") + ");\" "
			+ "onfocus=\"" + this.getID() + ".focus(" + (moz?"event":"") + ");\" "
			+ "onblur=\"" + this.getID() + ".blur(" + (moz?"event":"") + ");\" "
			+ "onchange=\"" + this.getID() + ".change();this.value=formatTime(this.value);\" />";
	return str;
}
ctlTime.prototype.keypressdown = function (event) {
	this.oMask._onKeyPressdown(event);
}
ctlTime.prototype.keypress = function (event) {
	this.oMask._onKeyPress(event);
}
ctlTime.prototype.focus = function (event) {
	if (!this.isReadonly()) {
		this.oMask._onFocus(event);
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.focus();
	}
	return this.base.focus();
}
ctlTime.prototype.blur = function (event) {
	if (!this.isReadonly()) {
		this.oMask._onBlur();
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
	}
	return this.base.blur();
}
ctlTime.prototype.change = function () { return this.base.change(); }
ctlTime.prototype.isVisible = function () { return this.base.isVisible(); }
ctlTime.prototype.isRequired = function () { return this.base.isRequired(); }
ctlTime.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlTime.prototype.isDirty = function () { return this.base.isDirty(); }
ctlTime.prototype.setInvalid = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.className = 'INPUTERROR';
}
ctlTime.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		if (oTXT.value.length == 0 && this.isRequired()) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else if (!isValidTime(oTXT.value)) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else {
			oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
			return true;
		}
	}
	else {
		return true;
	}
}
ctlTime.prototype.clear = function () { return this.base.clear(); }
ctlTime.prototype.show = function (bVal) { document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlTime.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlTime.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlTime.prototype.getToken = function () { return this.base.getToken(); }
ctlTime.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlFloat
//********************************************************************************
function ctlFloat(sID, fValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.fValue 	= Number(fValue);
	zControls[zControls.length] = this;
}
ctlFloat.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? StringToJSFloat(oTXT.value) : this.fValue;
}
ctlFloat.prototype.setValue = function (fNewValue) {
	this.fValue = fNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = formatFloat(JSFloatToString(this.fValue));
	this.change();
	if (!this.isReadonly()) oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
// Inherited...
ctlFloat.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + formatFloat(JSFloatToString(this.getValue())) + "\" "
			+ "style=\"width:100px;text-align:right;\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	return str;
}
ctlFloat.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.style.textAlign = 'left';
		return this.base.focus();
	}
}
ctlFloat.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oTXT.value = formatFloat(oTXT.value);
		oTXT.style.textAlign = 'right';
		return this.base.blur();
	}
}
ctlFloat.prototype.click = function () { return this.base.click(); }
ctlFloat.prototype.change = function () { return this.base.change(); }
ctlFloat.prototype.isVisible = function () { return this.base.isVisible(); }
ctlFloat.prototype.isRequired = function () { return this.base.isRequired(); }
ctlFloat.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlFloat.prototype.isDirty = function () { return this.base.isDirty(); }
ctlFloat.prototype.isValid = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	if (oTXT.value.length == 0 && this.isRequired()) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else if (!isValidCurrency(oTXT.value)) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else {
		oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return true;
	}
}
ctlFloat.prototype.clear = function () { return this.base.clear(); }
ctlFloat.prototype.show = function (bVal) { document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlFloat.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlFloat.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlFloat.prototype.getToken = function () { return this.base.getToken(); }
ctlFloat.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlInteger
//********************************************************************************
function ctlInteger(sID, iValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.iValue		= iValue;		// Integer value.
	zControls[zControls.length] = this;
}
ctlInteger.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? StringToJSInteger(oTXT.value) : this.iValue;
}
ctlInteger.prototype.setValue = function (iNewValue) {
	this.iValue = iNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = formatInteger(JSIntegerToString(this.iValue));
	this.change();
	oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlInteger.prototype.toString = function () {
	var str = this.base.toString();
	str += "<TABLE cellpadding=0 cellspacing=0><TR>"
	str += "<TD rowspan=2><INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + formatInteger(JSIntegerToString(this.getValue())) + "\" "
			+ "style=\"width:80px;text-align:right;display:" + (this.isVisible() ? "block" : "none") + ";\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" /></TD>";
	str += "<TD><BUTTON id=\"btninc" + this.getID() + "\" onclick=\"" + this.getID() + ".increment();\" tabindex=-1 style=\"width:20px;height:10px;border:0px;border-bottom:1px solid threedsahdow;border-right:1px solid threedsahdow;\" " + (this.isReadonly() ? "disabled" : "") + "><IMG src=\"../images/up.gif\"></BUTTON></TD></TR>";
	str += "<TR><TD><BUTTON id=\"btndec" + this.getID() + "\" onclick=\"" + this.getID() + ".decrement();\" tabindex=-1 style=\"width:20px;height:10px;border:0px;border-bottom:1px solid threedsahdow;border-right:1px solid threedsahdow;\" " + (this.isReadonly() ? "disabled" : "") + "><IMG src=\"../images/down.gif\"></BUTTON></TD>";
	str += "</TR></TABLE>";
	return str;
}
ctlInteger.prototype.increment = function () {
	if (!this.isReadonly()) {
		var iNewValue = this.getValue();
		this.setValue(iNewValue+1);
	}
}
ctlInteger.prototype.decrement = function () {
	if (!this.isReadonly()) {
		var iNewValue = this.getValue();
		this.setValue(iNewValue-1);
	}
}
ctlInteger.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.style.textAlign = 'left';
		return this.base.focus();
	}
}
ctlInteger.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oTXT.value = formatInteger(oTXT.value);
		oTXT.style.textAlign = 'right';
		return this.base.blur();
	}
}
ctlInteger.prototype.click = function () { return this.base.click(); }
ctlInteger.prototype.change = function () { return this.base.change(); }
ctlInteger.prototype.isVisible = function () { return this.base.isVisible(); }
ctlInteger.prototype.isRequired = function () { return this.base.isRequired(); }
ctlInteger.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlInteger.prototype.isDirty = function () { return this.base.isDirty(); }
ctlInteger.prototype.isValid = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	if (oTXT.value.length == 0 && this.isRequired()) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else if (!isValidInteger(oTXT.value)) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else {
		oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return true;
	}
}
ctlInteger.prototype.clear = function () { return this.base.clear(); }
ctlInteger.prototype.show = function (bVal) { 
	document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');
	document.getElementById('btninc' + this.getID()).style.display=(bVal?'block':'none');
	document.getElementById('btndec' + this.getID()).style.display=(bVal?'block':'none');
	return this.base.show(bVal); 
}
ctlInteger.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var oBTN1 = document.getElementById('btninc' + this.getID());
	oBTN1.disabled = (bVal ? 1 : 0);
	var oBTN2 = document.getElementById('btndec' + this.getID());
	oBTN2.disabled = (bVal ? 1 : 0);
	return this.base.readonly(bVal);
}
ctlInteger.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlInteger.prototype.getToken = function () { return this.base.getToken(); }
ctlInteger.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlLong
//********************************************************************************
function ctlLong(sID, sLabel, lValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, sLabel, bRequired, bReadonly, bVisible);
	this.lValue		= lValue;		// Long value.
	zControls[zControls.length] = this;
}
ctlLong.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? StringToJSInteger(oTXT.value) : this.lValue;
}
ctlLong.prototype.setValue = function (lNewValue) {
	this.lValue = lNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = formatInteger(JSIntegerToString(this.lValue));
	this.change();
	oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
// Inherited...
ctlLong.prototype.toString = function () {
	var str = this.base.toString();
	str += "<TR id=\"tr" + this.getID() + "\" style=\"display:" + (this.isVisible() ? "block;" : "none;") + "\">";
	str += "<TD class=\"NSLabelBlock\" nowrap>" + (this.getLabel() == "" ? " " : this.getLabel() + ":") + "</TD>";
	str += "<TD class=\"NSInputBlock\">";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + formatInteger(JSIntegerToString(this.getValue())) + "\" "
			+ "style=\"width:100px;text-align:right;\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += "</TD>";
	str += "</TR>";
	return str;
}
ctlLong.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.style.textAlign = 'left';
		return this.base.focus();
	}
}
ctlLong.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oTXT.value = formatInteger(oTXT.value);
		oTXT.style.textAlign = 'right';
		return this.base.blur();
	}
}
ctlLong.prototype.click = function () { return this.base.click(); }
ctlLong.prototype.change = function () { return this.base.change(); }
ctlLong.prototype.isVisible = function () { return this.base.isVisible(); }
ctlLong.prototype.isRequired = function () { return this.base.isRequired(); }
ctlLong.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlLong.prototype.isDirty = function () { return this.base.isDirty(); }
ctlLong.prototype.isValid = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	if (oTXT.value.length == 0 && this.isRequired()) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else if (!isValidInteger(oTXT.value)) {
		oTXT.className = 'INPUTERROR';
		return false;
	}
	else {
		oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return true;
	}
}
ctlLong.prototype.clear = function () { return this.base.clear(); }
ctlLong.prototype.show = function (bVal) { document.getElementById('tr' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlLong.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlLong.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlLong.prototype.getToken = function () { return this.base.getToken(); }
ctlLong.prototype.getID = function () { return this.base.getID(); }
ctlLong.prototype.getLabel = function () { return this.base.getLabel(); }
ctlLong.prototype.setLabel = function (sNewLabel) { return this.base.setLabel(sNewLabel); }

//********************************************************************************
// CONTROL: ctlCurrency
//********************************************************************************
function ctlCurrency(sID, fValue, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.fValue 	= Number(fValue);
	zControls[zControls.length] = this;
}
ctlCurrency.prototype.getValue = function () {
	var oTXT = document.getElementById('txt' + this.getID());
	return oTXT ? StringToJSFloat(oTXT.value) : this.fValue;
}
ctlCurrency.prototype.setValue = function (fNewValue) {
	this.fValue = fNewValue;
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.value = formatCurrency(JSFloatToString(this.fValue));
	this.change();
	if (!this.isReadonly()) oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlCurrency.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"text\" "
			+ (!this.isReadonly() == false ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"txt" + this.getID() + "\" " 
			+ "value=\"" + formatCurrency(JSFloatToString(this.getValue())) + "\" "
			+ "style=\"width:100px;text-align:right;display:" + (this.isVisible()?"block":"none") + "\" "
			+ (!this.isReadonly() ? "" : "tabindex=\"-1\" ")
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	return str;
}
ctlCurrency.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.style.textAlign = 'left';
		return this.base.focus();
	}
}
ctlCurrency.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oTXT.value = formatCurrency(oTXT.value);
		oTXT.style.textAlign = 'right';
		return this.base.blur();
	}
}
ctlCurrency.prototype.click = function () { return this.base.click(); }
ctlCurrency.prototype.change = function () { return this.base.change(); }
ctlCurrency.prototype.isVisible = function () { return this.base.isVisible(); }
ctlCurrency.prototype.isRequired = function () { return this.base.isRequired(); }
ctlCurrency.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlCurrency.prototype.isDirty = function () { return this.base.isDirty(); }
ctlCurrency.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('txt' + this.getID());
		if (oTXT.value.length == 0 && this.isRequired()) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else if (!isValidCurrency(oTXT.value)) {
			oTXT.className = 'INPUTERROR';
			return false;
		}
		else {
			oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
			return true;
		}
	}
	return true;
}
ctlCurrency.prototype.clear = function () { return this.base.clear(); }
ctlCurrency.prototype.show = function (bVal) { document.getElementById('txt' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlCurrency.prototype.readonly = function (bVal) {
	var oTXT = document.getElementById('txt' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlCurrency.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var oTXT = document.getElementById('txt' + this.getID());
		oTXT.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlCurrency.prototype.getToken = function () { return this.base.getToken(); }
ctlCurrency.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// CONTROL: ctlCheckbox
//********************************************************************************
function ctlCheckbox(sID, sText, bInitValue, bReadonly, bVisible) {
	this.base	= new ctlCommon(sID, true, bReadonly, bVisible);
	this.bValue = bInitValue;
	this.sText	= sText;
	zControls[zControls.length] = this;
}
ctlCheckbox.prototype.getValue = function () {
	var oCHK = document.getElementById('chk' + this.getID());
	return oCHK ? oCHK.checked : this.bValue;
}
ctlCheckbox.prototype.setValue = function (bNewValue) {
	this.bValue = bNewValue;
	var oCHK = document.getElementById('chk' + this.getID());
	oCHK.checked = this.bValue;
	this.change();
	oCHK.className = (this.isValid() ? '' : 'INPUTERROR');
}
// Inherited...
ctlCheckbox.prototype.toString = function () {
	var str = this.base.toString();
	str += "<INPUT type=\"checkbox\" style=\"background:transparent;width:20px;border:0px;\" "
			+ (!this.isReadonly() == false ? "disabled=true class=\"INPUTREADONLY\"" : "") + " "
			+ "id=\"chk" + this.getID() + "\" " 
			+ (this.getValue() ? "checked " : "")
			+ "onclick=\"" + this.getID() + ".change();\" "
			+ "onfocus=\"" + this.getID() + ".focus();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += this.sText.length > 0 ? "&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style=\"font-style:italic;\">" + this.sText + "</SPAN>" : "";
	return str;
}
ctlCheckbox.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oCHK = document.getElementById('chk' + this.getID());
		oCHK.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oCHK.focus();
		return this.base.focus();
	}
}
ctlCheckbox.prototype.blur = function () {
	if (!this.isReadonly()) {
		var oCHK = document.getElementById('chk' + this.getID());
		oCHK.className = (!this.isValid() ? 'INPUTERROR' : '');
		return this.base.blur();
	}
}
ctlCheckbox.prototype.click = function () { return this.base.click(); }
ctlCheckbox.prototype.change = function () { return this.base.change(); }
ctlCheckbox.prototype.isVisible = function () { return this.base.isVisible(); }
ctlCheckbox.prototype.isRequired = function () { return this.base.isRequired(); }
ctlCheckbox.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlCheckbox.prototype.isDirty = function () { return this.base.isDirty(); }
ctlCheckbox.prototype.isValid = function () {
	var oCHK = document.getElementById('chk' + this.getID());
	oCHK.className = (this.isReadonly() ? 'INPUTREADONLY' : '');
	return true;
}
ctlCheckbox.prototype.clear = function () { return this.base.clear(); }
ctlCheckbox.prototype.show = function (bVal) { document.getElementById('chk' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlCheckbox.prototype.readonly = function (bVal) {
	var oCHK = document.getElementById('chk' + this.getID());
	oCHK.disabled = bVal;
	oCHK.className = (bVal ? 'INPUTREADONLY' : '');
	return this.base.readonly(bVal);
}
ctlCheckbox.prototype.required = function (bVal) { return this.base.required(bVal); }
ctlCheckbox.prototype.getToken = function () { return this.base.getToken(); }
ctlCheckbox.prototype.getID = function () { return this.base.getID(); }
ctlCheckbox.prototype.getLabel = function () { return this.base.getLabel(); }
ctlCheckbox.prototype.setLabel = function (sNewLabel) { return this.base.setLabel(sNewLabel); }

//********************************************************************************
// CONTROL: ctlTimeSlot
//********************************************************************************
function ctlTimeSlot(sID, dtDate, dtEndDate, tmStart, tmStop, bRequired, bReadonly, bVisible, bHideEndDate, bHideStopTime) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.dtDate			= dtDate;		// Value of the date control YYYY-MM-DD.
	this.dtEndDate		= dtEndDate;	// Value of the end date control YYYY-MM-DD.
	this.tmStart		= tmStart;		// Value of the start control hh:mm:ss.
	this.tmStop			= tmStop;		// Value of the stop control hh:mm:ss.
	this.fHours			= 0;			// Duration stored as a float.
	this.bHideEndDate	= bHideEndDate;	// Hide the end date control.
	this.bHideStopTime	= bHideStopTime;// Hode the stop time control.
	this.calcDuration();
	this.oMask1			= new ctlTimeMask('tm1' + this.getID());
	this.oMask2			= new ctlTimeMask('tm2' + this.getID());
	zControls[zControls.length] = this;
}
ctlTimeSlot.prototype.getDate = function () {
	var octlDate = document.getElementById('dat' + this.getID());
	return (octlDate ? DateToYYYYMMDD(octlDate.value) : this.dtDate);
}
ctlTimeSlot.prototype.setDate = function (sYYYYMMDD) {
	this.dtDate = sYYYYMMDD;
	var octlDate = document.getElementById('dat' + this.getID());
	if (octlDate) octlDate.value = YYYYMMDDToDate(this.dtDate);
	this.calcDuration();
	this.change();
	octlDate.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlTimeSlot.prototype.getEndDate = function () {
	var octlDate = document.getElementById('datEnd' + this.getID());
	return (octlDate ? DateToYYYYMMDD(octlDate.value) : this.dtEndDate);
}
ctlTimeSlot.prototype.setEndDate = function (sYYYYMMDD) {
	this.dtEndDate = sYYYYMMDD;
	var octlDate = document.getElementById('datEnd' + this.getID());
	if (octlDate) octlDate.value = YYYYMMDDToDate(this.dtEndDate);
	this.calcDuration();
	this.change();
	octlDate.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlTimeSlot.prototype.getStart = function () {
	var octlStart = document.getElementById('tm1' + this.getID());
	return (octlStart ? TimeToHHMMSS(octlStart.value) : this.tmStart);
}
ctlTimeSlot.prototype.setStart = function (sHHMMSS) {
	this.tmStart = sHHMMSS;
	var octlStart = document.getElementById('tm1' + this.getID());
	if (octlStart) octlStart.value = HHMMSSToTime(sHHMMSS);
	this.calcDuration();
	this.change();
	octlStart.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlTimeSlot.prototype.getStop = function () {
	var octlStop = document.getElementById('tm2' + this.getID());
	return (octlStop ? TimeToHHMMSS(octlStop.value) : this.tmStop);
}
ctlTimeSlot.prototype.setStop = function (sHHMMSS) {
	this.tmStop = sHHMMSS;
	var octlStop = document.getElementById('tm2' + this.getID());
	if (octlStop) octlStop.value = HHMMSSToTime(sHHMMSS);
	this.calcDuration();
	this.change();
	octlStop.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlTimeSlot.prototype.getDuration = function () {
	var octlDuration = document.getElementById('dur' + this.getID());
	return (octlDuration ? DurationToJSFloat(octlDuration.value) : this.fHours);
}
ctlTimeSlot.prototype.setDuration = function (fDuration) {
	this.fHours = fDuration;
	var octlDuration = document.getElementById('dur' + this.getID());
	if (octlDuration) octlDuration.value = formatDuration(fDuration);
	this.calcEndTime();
	this.change();
	octlDuration.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlTimeSlot.prototype.toString = function () {
	var str = this.base.toString();
	str += "<TABLE id=\"tbl" + this.getID() + "\" cellspacing=\"0\" cellpadding=\"0\" style=\"color:black;\">";
	str += "<TR>";
	str += "<TD nowrap>";
	str += "<DIV id=\"inp" + this.getID() + "\" class=\"divDateInput\">";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"dat" + this.getID() + "\" " 
			+ "value=\"" + YYYYMMDDToDate(this.getDate()) + "\" "
			+ "style=\"width:90px;text-align:center;\" "
			+ "onfocus=\"" + this.getID() + ".focus1();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();" + this.getID() + ".calcDuration();\" />";
	str += "<BUTTON id=\"btn" + this.getID() + "\" class=\"ImageButton\" tabindex=\"-1\" onclick=\"" + this.getID() + ".click();return false;\" style=\"visibility:" + (!this.isReadonly()?"visible":"hidden") + "\">";
	str += "<IMG align=\"middle\" style=\"cursor:pointer;\" SRC=\"../images/icons/date.png\"/>";
	str += "</BUTTON>";
	str += "</DIV>";
	str += "<DIV id=\"inpEnd" + this.getID() + "\" class=\"divDateInput\" " + (this.bHideEndDate ? "style=\"display:none;\"" : "") + ">";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"datEnd" + this.getID() + "\" " 
			+ "value=\"" + YYYYMMDDToDate(this.getEndDate()) + "\" "
			+ "style=\"width:90px;text-align:center;\" "
			+ "onfocus=\"" + this.getID() + ".focus1();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();" + this.getID() + ".calcDuration();\" />";
	str += "<BUTTON id=\"btnEnd" + this.getID() + "\" class=\"ImageButton\" tabindex=\"-1\" onclick=\"" + this.getID() + ".clickEnd();return false;\" style=\"visibility:" + (!this.isReadonly()?"visible":"hidden") + "\">";
	str += "<IMG align=\"middle\" style=\"cursor:pointer;\" SRC=\"../images/icons/date.png\"/>";
	str += "</BUTTON>";
	str += "</DIV>";
	str += "</TD>";
	str += "<TD nowrap align=\"right\">";
	str += "&nbsp;&nbsp;" + sStartLabel + ":&nbsp;";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"tm1" + this.getID() + "\" " 
			+ "value=\"" + HHMMSSToTime(this.getStart()) + "\" "
			+ "style=\"width:65px;text-align:center;\" "
			+ "onkeydown=\"" + this.getID() + ".keypressdown1(" + (moz?"event":"") + ");\" "
			+ "onkeypress=\"" + this.getID() + ".keypress1(" + (moz?"event":"") + ");\" "
			+ "onfocus=\"" + this.getID() + ".focusMask1(" + (moz?"event":"") + ");\" "
			+ "onblur=\"" + this.getID() + ".blurMask1(" + (moz?"event":"") + ");\" "
			+ "onchange=\"" + this.getID() + ".change();this.value=formatTime(this.value);" + this.getID() + ".calcDuration();\" />";
	str += (!this.bHideEndDate ? "<BR>&nbsp;&nbsp;" + sStopLabel + ":&nbsp;" : "");
	str += "<INPUT type=\"text\"  " + (this.bHideEndDate ? "style=\"display:none;\"" : "") + " "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"tm2" + this.getID() + "\" " 
			+ "value=\"" + HHMMSSToTime(this.getStop()) + "\" "
			+ "style=\"width:65px;text-align:center;\" "
			+ "onkeydown=\"" + this.getID() + ".keypressdown2(" + (moz?"event":"") + ");\" "
			+ "onkeypress=\"" + this.getID() + ".keypress2(" + (moz?"event":"") + ");\" "
			+ "onfocus=\"" + this.getID() + ".focusMask2(" + (moz?"event":"") + ");\" "
			+ "onblur=\"" + this.getID() + ".blurMask2(" + (moz?"event":"") + ");\" "
			+ "onchange=\"" + this.getID() + ".change();this.value=formatTime(this.value);" + this.getID() + ".calcDuration();\" />";
	str += "</TD>";
	str += "<TD nowrap>";
	str += "&nbsp;&nbsp;" + sHoursLabel + ":&nbsp;";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"dur" + this.getID() + "\" " 
			+ "value=\"" + formatDuration(this.fHours) + "\" "
			+ "style=\"width:60px;text-align:right;\" "
			+ "onfocus=\"" + this.getID() + ".focus1();\" "
			+ "onblur=\"" + this.getID() + ".calcEndTime();" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();" + this.getID() + ".calcEndTime();\" />";
	str += "</TD>";
	str += "</TR>";
	str += "</TABLE>";
	return str;
}
ctlTimeSlot.prototype.keypressdown1 = function (event) {
	this.oMask1._onKeyPressdown(event);
}
ctlTimeSlot.prototype.keypress1 = function (event) {
	this.oMask1._onKeyPress(event);
}
ctlTimeSlot.prototype.keypressdown2 = function (event) {
	this.oMask2._onKeyPressdown(event);
}
ctlTimeSlot.prototype.keypress2 = function (event) {
	this.oMask2._onKeyPress(event);
}
ctlTimeSlot.prototype.focus = function () {
	if (!this.isReadonly()) {
		var octlDate = document.getElementById('dat' + this.getID());
		var octlEndDate = document.getElementById('datEnd' + this.getID());
		var octlStart = document.getElementById('tm1' + this.getID());
		var octlStop = document.getElementById('tm2' + this.getID());
		var octlDuration = document.getElementById('dur' + this.getID());
		octlDate.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlEndDate.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlStart.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlStop.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlDuration.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlDate.focus();
		return this.base.focus();
	}
}
ctlTimeSlot.prototype.focusMask1 = function (event) {
	if (!this.isReadonly()) {
		this.oMask1._onFocus(event);
		this.focus1();
	}
}
ctlTimeSlot.prototype.focusMask2 = function (event) {
	if (!this.isReadonly()) {
		this.oMask2._onFocus(event);
		this.focus1();
	}
}
ctlTimeSlot.prototype.blurMask1 = function (event) {
	if (!this.isReadonly()) {
		this.oMask1._onBlur(event);
		this.blur();
	}
}
ctlTimeSlot.prototype.blurMask2 = function (event) {
	if (!this.isReadonly()) {
		this.oMask2._onBlur(event);
		this.blur();
	}
}
ctlTimeSlot.prototype.focus1 = function () {
	if (!this.isReadonly()) {
		var octlDate = document.getElementById('dat' + this.getID());
		var octlEndDate = document.getElementById('datEnd' + this.getID());
		var octlStart = document.getElementById('tm1' + this.getID());
		var octlStop = document.getElementById('tm2' + this.getID());
		var octlDuration = document.getElementById('dur' + this.getID());
		octlDate.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlEndDate.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlStart.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlStop.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlDuration.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		return this.base.focus();
	}
}
ctlTimeSlot.prototype.blur = function () {
	if (!this.isReadonly()) {
		var octlDate = document.getElementById('dat' + this.getID());
		var octlEndDate = document.getElementById('datEnd' + this.getID());
		var octlStart = document.getElementById('tm1' + this.getID());
		var octlStop = document.getElementById('tm2' + this.getID());
		var octlDuration = document.getElementById('dur' + this.getID());
		var bValid = this.isValid();
		if (bValid) this.calcDuration();
		octlDate.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		octlEndDate.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		octlStart.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		octlStop.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		octlDuration.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return this.base.blur();
	}
}
ctlTimeSlot.prototype.click = function () {
	ShowPopUp('../COMMON/calendarpopup.jsp;jsessionid=' + sSessionID + '?FORDATE=' + this.getDate(), 200, 235, 'parent.ctlTimeSlot_clickback("' + this.getID() + '")')
}
function ctlTimeSlot_clickback(sID) {
	var sChoice = popupReturnValue;
	if (sChoice != '') {
		var oCtl = eval(sID);
		oCtl.setDate(sChoice);
	}
}
ctlTimeSlot.prototype.clickEnd = function () {
	ShowPopUp('../COMMON/calendarpopup.jsp;jsessionid=' + sSessionID + '?FORDATE=' + this.getEndDate(), 200, 235, 'parent.ctlTimeSlot_clickbackEnd("' + this.getID() + '")')
}
function ctlTimeSlot_clickbackEnd(sID) {
	var sChoice = popupReturnValue;
	if (sChoice != '') {
		var oCtl = eval(sID);
		oCtl.setEndDate(sChoice);
	}
}
ctlTimeSlot.prototype.change = function () {
	var sDate = this.getDate();
	var sEndDate = this.getEndDate();
	if (sEndDate < sDate) {
		this.setEndDate(sDate);
	}
	return this.base.change();
}
ctlTimeSlot.prototype.isVisible = function () { return this.base.isVisible(); }
ctlTimeSlot.prototype.isRequired = function () { return this.base.isRequired(); }
ctlTimeSlot.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlTimeSlot.prototype.isDirty = function () { return this.base.isDirty(); }
ctlTimeSlot.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var octlDate = document.getElementById('dat' + this.getID());
		if (octlDate.value.length == 0 && this.isRequired()) {
			octlDate.className = 'INPUTERROR'; return false;
		}
		else if (!isValidDate(octlDate.value)) {
			octlDate.className = 'INPUTERROR'; return false;
		}
		else {
			octlDate.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
		var octlEndDate = document.getElementById('datEnd' + this.getID());
		if (octlEndDate.value.length == 0 && this.isRequired()) {
			octlEndDate.className = 'INPUTERROR'; return false;
		}
		else if (!isValidDate(octlEndDate.value)) {
			octlEndDate.className = 'INPUTERROR'; return false;
		}
		else {
			octlEndDate.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
		if (this.getEndDate() < this.getDate()) {
			octlDate.className = 'INPUTERROR';
			octlEndDate.className = 'INPUTERROR';
			return false;
		}
		var octlStart = document.getElementById('tm1' + this.getID());
		if (octlStart.value.length == 0 && this.isRequired()) {
			octlStart.className = 'INPUTERROR'; return false;
		}
		else if (!isValidTime(octlStart.value)) {
			octlStart.className = 'INPUTERROR'; return false;
		}
		else {
			octlStart.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
		var octlStop = document.getElementById('tm2' + this.getID());
		if (octlStop.value.length == 0 && this.isRequired()) {
			octlStop.className = 'INPUTERROR'; return false;
		}
		else if (!isValidTime(octlStop.value)) {
			octlStop.className = 'INPUTERROR'; return false;
		}
		else {
			octlStop.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
		var octlDuration = document.getElementById('dur' + this.getID());
		if (octlDuration.value.length == 0 && this.isRequired()) {
			octlDuration.className = 'INPUTERROR'; return false;
		}
		else if (!isValidDuration(octlDuration.value)) {
			octlDuration.className = 'INPUTERROR'; return false;
		}
		else if (DurationToJSFloat(octlDuration.value) < 0) {
			octlDuration.className = 'INPUTERROR'; return false;
		}
		else {
			octlDuration.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
	}
	return true;
}
ctlTimeSlot.prototype.clear = function () { return this.base.clear(); }
ctlTimeSlot.prototype.show = function (bVal) { document.getElementById('tbl' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlTimeSlot.prototype.readonly = function (bVal) {
	var octlDate = document.getElementById('dat' + this.getID());
	octlDate.readOnly = bVal;
	octlDate.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var octlEndDate = document.getElementById('datEnd' + this.getID());
	octlEndDate.readOnly = bVal;
	octlEndDate.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var octlStart = document.getElementById('tm1' + this.getID());
	octlStart.readOnly = bVal;
	octlStart.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var octlStop = document.getElementById('tm2' + this.getID());
	octlStop.readOnly = bVal;
	octlStop.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var octlDuration = document.getElementById('dur' + this.getID());
	octlDuration.readOnly = bVal;
	octlDuration.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	document.getElementById('btn' + this.getID()).style.visibility = bVal ? 'hidden' : 'visible';
	document.getElementById('btnEnd' + this.getID()).style.visibility = bVal ? 'hidden' : 'visible';
	return this.base.readonly(bVal);
}
ctlTimeSlot.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var octlDate = document.getElementById('dat' + this.getID());
		octlDate.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlEndDate = document.getElementById('datEnd' + this.getID());
		octlEndDate.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlStart = document.getElementById('tm1' + this.getID());
		octlStart.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlStop = document.getElementById('tm2' + this.getID());
		octlStop.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlDuration = document.getElementById('dur' + this.getID());
		octlDuration.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlTimeSlot.prototype.getToken = function () { return this.base.getToken(); }
ctlTimeSlot.prototype.getID = function () { return this.base.getID(); }
ctlTimeSlot.prototype.calcEndTime = function () {
	var tmStartTime	= TimeToJSTime(HHMMSSToTime(this.getStart()));
	var dtStartDate	= DateToJSDate(YYYYMMDDToDate(this.getDate()));
	var tmStopTime	= new Date();
	var iMillis		= this.getDuration() * 60 * 60 * 1000;
	tmStopTime.setTime(tmStartTime.getTime() + iMillis);
	var octlStop	= document.getElementById('tm2' + this.getID());
	octlStop.value	= JSTimeToTime(tmStopTime);
	this.tmStop		= TimeToHHMMSS(octlStop.value);
	var octlEndDate	= document.getElementById('datEnd' + this.getID());
	var dtStopDate = new Date();
	dtStopDate.setFullYear(dtStartDate.getFullYear());
	dtStopDate.setMonth(dtStartDate.getMonth());
	dtStopDate.setDate(dtStartDate.getDate());
	dtStopDate.setHours(tmStartTime.getHours());
	dtStopDate.setMinutes(tmStartTime.getMinutes());
	dtStopDate.setSeconds(0);
	dtStopDate.setTime(dtStopDate.getTime() + iMillis);
	octlEndDate.value	= JSDateToDate(dtStopDate);
	this.dtEndDate	= DateToYYYYMMDD(octlEndDate.value);
}
ctlTimeSlot.prototype.calcDuration = function () {
	var dtStartDate		= DateToJSDate(YYYYMMDDToDate(this.getDate()));
	var dtStopDate		= DateToJSDate(YYYYMMDDToDate(this.getEndDate()));
	var tmStartTime		= TimeToJSTime(HHMMSSToTime(this.getStart()));
	var tmStopTime		= TimeToJSTime(HHMMSSToTime(this.getStop()));
	var fDiff			= (tmStopTime.getTime() - tmStartTime.getTime()) + (dtStopDate.getTime() - dtStartDate.getTime());
	this.fHours			= fDiff / 1000 / 60 / 60;
	this.fHours			= this.fHours < 0 ? 24 + this.fHours : this.fHours;
	var octlDuration	= document.getElementById('dur' + this.getID());
	if (octlDuration) octlDuration.value = formatDuration(this.fHours);
}

//********************************************************************************
// CONTROL: ctlButton
//********************************************************************************
function ctlButton(sID, sLabel, bReadonly, bVisible) {
	this.base	= new ctlCommon(sID, true, bReadonly, bVisible);
	this.sLabel = sLabel;
}
// Inherited...
ctlButton.prototype.toString = function () {
	var str = this.base.toString();
	str += '<BUTTON class=FormButton id=btn' 
			+ this.getID() 
			+ ' style="display:' + (this.isVisible() ? 'inline' : 'none') + '" onclick="OnClick(\'' 
			+ this.getID() 
			+ '\');return false;" ' 
			+ (!this.isReadonly() == false ? 'disabled' : '') 
			+ '>';
	str += this.sLabel;
	str += '</BUTTON>';
	return str;
}
ctlButton.prototype.focus = function () {
	if (!this.isReadonly()) {
		var oBTN = document.getElementById('btn' + this.getID());
		oBTN.focus();
	}
}
ctlButton.prototype.blur = function () { return this.base.blur(); }
ctlButton.prototype.click = function () { if (!this.isReadonly()) return this.base.click(); }
ctlButton.prototype.isVisible = function () { return this.base.isVisible(); }
ctlButton.prototype.isRequired = function () { return this.base.isRequired(); }
ctlButton.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlButton.prototype.isDirty = function () { return this.base.isDirty(); }
ctlButton.prototype.clear = function () { return this.base.clear(); }
ctlButton.prototype.show = function (bVal) {
	var oBTN = document.getElementById('btn' + this.getID());
	oBTN.style.display = (bVal ? 'inline' : 'none');
	return this.base.show(bVal);
}
ctlButton.prototype.readonly = function (bVal) {
	var oBTN = document.getElementById('btn' + this.getID());
	oBTN.disabled = !bVal?0:1;
	return this.base.readonly(bVal);
}
ctlButton.prototype.required = function (bVal) { return this.base.required(bVal); }
ctlButton.prototype.getToken = function () { return this.base.getToken(); }
ctlButton.prototype.getID = function () { return this.base.getID(); }
ctlButton.prototype.getLabel = function () { return this.sLabel; }
ctlButton.prototype.setLabel = function (sNewLabel) {
	this.sLabel = sNewLabel;
	document.getElementById('btn' + this.getID()).innerText = this.sLabel;
}

//********************************************************************************
// CONTROL: ctlInvoiceItem
//********************************************************************************
function ctlInvoiceItem(sID, sItemCode, sItemName, fPrice, lTaxCodeID, sTaxCodes, bRequired, bReadonly, bVisible) {
	this.base		= new ctlCommon(sID, bRequired, bReadonly, bVisible);
	this.sItemCode		= sItemCode;
	this.sItemName		= sItemName;
	this.fPrice			= fPrice;
	this.lTaxCodeID		= lTaxCodeID;
	this.sTaxCodes 		= sTaxCodes;
	this.zTaxCodes 		= sTaxCodes.split(sDelimiter);
	zControls[zControls.length] = this;
}
ctlInvoiceItem.prototype.getItemCode = function () {
	var octlItemCode = document.getElementById('itemcode' + this.getID());
	return (octlItemCode ? octlItemCode.value : this.sItemCode);
}
ctlInvoiceItem.prototype.setItemCode = function (sNewCode) {
	this.sItemCode = sNewCode;
	var octlItemCode = document.getElementById('itemcode' + this.getID());
	if (octlItemCode) octlItemCode.value = this.sItemCode;
	this.change();
	octlItemCode.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlInvoiceItem.prototype.getItemName = function () {
	var octlItemName = document.getElementById('itemname' + this.getID());
	return (octlItemName ? octlItemName.value : this.sItemName);
}
ctlInvoiceItem.prototype.setItemName = function (sNewName) {
	this.sItemName = sNewName;
	var octlItemName = document.getElementById('itemname' + this.getID());
	if (octlItemName) octlItemName.value = this.sItemName;
	this.change();
	octlItemName.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlInvoiceItem.prototype.getPrice = function () {
	var oTXT = document.getElementById('curprice' + this.getID());
	return oTXT ? StringToJSFloat(oTXT.value) : this.fPrice;
}
ctlInvoiceItem.prototype.setPrice = function (fNewPrice) {
	this.fPrice = fNewPrice;
	var oTXT = document.getElementById('curprice' + this.getID());
	oTXT.value = formatCurrency(JSFloatToString(this.fPrice));
	this.change();
	if (!this.isReadonly()) oTXT.className = (this.isValid() ? '' : 'INPUTERROR');
}
ctlInvoiceItem.prototype.getTaxCode = function () {
	var oSEL = document.getElementById('seltaxcode' + this.getID());
	return oSEL.value;
}
ctlInvoiceItem.prototype.setTaxCode = function (lNewTaxCode) {
	var oSEL = document.getElementById('seltaxcode' + this.getID());
	for (var x = 0; x < oSEL.options.length; x++) {
		if (oSEL.options[x].value == lNewTaxCode) {
			oSEL.selectedIndex = x;
			break;
		}
	}
}
ctlInvoiceItem.prototype.toString = function () {
	var str = this.base.toString();
	str += "<TABLE id=\"tbl" + this.getID() + "\" cellspacing=\"0\" cellpadding=\"0\" style=\"color:black;\">";
	str += "<TR>";
	str += "<TD nowrap>";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"itemcode" + this.getID() + "\" " 
			+ "value=\"" + this.getItemCode() + "\" "
			+ "maxlength=\"" + lenJXPInvoiceItem_ItemCode + "\" "
			+ "style=\"width:90px;text-align:center;\" "
			+ "onfocus=\"" + this.getID() + ".focus1();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += "<BUTTON id=\"btn" + this.getID() + "\" class=\"ImageButton\" tabindex=\"-1\" onclick=\"" + this.getID() + ".click();return false;\" style=\"visibility:" + (!this.isReadonly()?"visible":"hidden") + "\">";
	str += "<IMG align=\"middle\" style=\"cursor:pointer;\" SRC=\"../images/icons/find.png\"/>";
	str += "</BUTTON>";
	str += "<TD>";
	str += "<INPUT type=\"text\" "
			+ (this.isReadonly() ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"itemname" + this.getID() + "\" " 
			+ "value=\"" + this.getItemName() + "\" "
			+ "maxlength=\"" + lenJXPInvoiceItem_ItemName + "\" "
			+ "style=\"width:200px;text-align:left;\" "
			+ "onfocus=\"" + this.getID() + ".focus1();\" "
			+ "onblur=\"" + this.getID() + ".blur();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += "</TD>";
	str += "</TR>";
	str += "<TR>";
	str += "<TD nowrap align=\"left\">";
	str += "<INPUT type=\"text\" "
			+ (!this.isReadonly() == false ? "readonly class=\"INPUTREADONLY\"" : this.isRequired() ? "required class=\"INPUTREQUIRED\"" : "") + " "
			+ "id=\"curprice" + this.getID() + "\" " 
			+ "value=\"" + formatCurrency(JSFloatToString(this.getPrice())) + "\" "
			+ "style=\"width:100px;text-align:right;display:" + (this.isVisible()?"block":"none") + "\" "
			+ (!this.isReadonly() ? "" : "tabindex=\"-1\" ")
			+ "onfocus=\"" + this.getID() + ".focusprice();\" "
			+ "onblur=\"" + this.getID() + ".blurprice();\" "
			+ "onchange=\"" + this.getID() + ".change();\" />";
	str += "</TD>";
	str += "<TD nowrap>";
	str += "&nbsp;&nbsp;" + sTaxCodeLabel + ":&nbsp;";
	str += "<SELECT " + (this.isReadonly() == false ? "" : "disabled=true") + " id=seltaxcode" + this.getID()
			+ " onchange=\"" + this.getID() + ".change()\""
			+ " onfocus=\"" + this.getID() + ".isValid();\" "
			+ " onblur=\"" + this.getID() + ".blur();\">";
	str += "<OPTION value=\"0\" " + (this.lTaxCodeID == 0 ? "selected" : "") + ">" + sNoneLabel;
	if (this.sTaxCodes.length > 0) {
		for (var x = 0; x < this.zTaxCodes.length; x++) {
			var zTaxCode = this.zTaxCodes[x].split(sSubDelimiter);
			str += "<OPTION value=\"" + zTaxCode[0] + "\" " + (this.lTaxCodeID == zTaxCode[0] ? "selected" : "") + ">" + zTaxCode[1].replace(/#124/g,'\|').replace(/#59/g,'\;').replace(/#39/g,'&#39;').replace(/#34/g,'&#34;');
		}
	}
	str += "</SELECT>";
	str += "</TD>";
	str += "</TR>";
	str += "</TABLE>";
	return str;
}
ctlInvoiceItem.prototype.focus = function () {
	if (!this.isReadonly()) {
		var octlItemCode = document.getElementById('itemcode' + this.getID());
		var octlItemName = document.getElementById('itemname' + this.getID());
		var oTXT = document.getElementById('curprice' + this.getID());
		var oSEL = document.getElementById('seltaxcode' + this.getID());
		octlItemCode.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlItemName.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oSEL.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlItemCode.focus();
		return this.base.focus();
	}
}
ctlInvoiceItem.prototype.focus1 = function () {
	if (!this.isReadonly()) {
		var octlItemCode = document.getElementById('itemcode' + this.getID());
		var octlItemName = document.getElementById('itemname' + this.getID());
		var oTXT = document.getElementById('curprice' + this.getID());
		var oSEL = document.getElementById('seltaxcode' + this.getID());
		octlItemCode.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		octlItemName.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oSEL.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		return this.base.focus();
	}
}
ctlInvoiceItem.prototype.focusprice = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('curprice' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTHIGHLIGHTERROR' : 'INPUTHIGHLIGHT');
		oTXT.style.textAlign = 'left';
		return this.base.focus();
	}
}
ctlInvoiceItem.prototype.blurprice = function () {
	if (!this.isReadonly()) {
		var oTXT = document.getElementById('curprice' + this.getID());
		oTXT.className = (!this.isValid() ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oTXT.value = formatCurrency(oTXT.value);
		oTXT.style.textAlign = 'right';
		return this.base.blur();
	}
}
ctlInvoiceItem.prototype.blur = function () {
	if (!this.isReadonly()) {
		var octlItemCode = document.getElementById('itemcode' + this.getID());
		var octlItemName = document.getElementById('itemname' + this.getID());
		var oTXT = document.getElementById('curprice' + this.getID());
		var oSEL = document.getElementById('seltaxcode' + this.getID());
		var bValid = this.isValid();
		octlItemCode.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		octlItemName.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oTXT.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		oSEL.className = (!bValid ? 'INPUTERROR' : this.isRequired() ? 'INPUTREQUIRED' : '');
		return this.base.blur();
	}
}
function ctlInvoiceItem_clickback(sID) {
	var sChoice = popupReturnValue;
	if (sChoice != '') {
		var zChoice = sChoice.split(sDelimiter);
		var oCtl = eval(sID);
		oCtl.setItemCode(zChoice[0].replace(/&#59/g,';').replace(/#124;/g, '\|'));
		oCtl.setItemName(zChoice[1].replace(/&#59/g,';').replace(/#124;/g, '\|'));
		oCtl.setPrice(zChoice[2]);
		oCtl.setTaxCode(zChoice[3]);
	}
}
ctlInvoiceItem.prototype.click = function () {
	ShowPopUp('../choosers/chooseinvoiceitem.jsp;jsessionid=' + sSessionID,255,265, 'parent.ctlInvoiceItem_clickback("' + this.getID() + '")');
	this.base.click();
}
ctlInvoiceItem.prototype.change = function () {
	return this.base.change();
}
ctlInvoiceItem.prototype.isVisible = function () { return this.base.isVisible(); }
ctlInvoiceItem.prototype.isRequired = function () { return this.base.isRequired(); }
ctlInvoiceItem.prototype.isReadonly = function () { return this.base.isReadonly(); }
ctlInvoiceItem.prototype.isDirty = function () { return this.base.isDirty(); }
ctlInvoiceItem.prototype.isValid = function () {
	if (!this.isReadonly()) {
		var octlItemCode = document.getElementById('itemcode' + this.getID());
		if (octlItemCode.value.length == 0 && this.isRequired()) {
			octlItemCode.className = 'INPUTERROR'; return false;
		}
		else {
			octlItemCode.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}

		var octlItemName = document.getElementById('itemname' + this.getID());
		if (octlItemName.value.length == 0 && this.isRequired()) {
			octlItemName.className = 'INPUTERROR'; return false;
		}
		else {
			octlItemName.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
		var oTXT = document.getElementById('curprice' + this.getID());
		if (oTXT.value.length == 0 && this.isRequired()) {
			oTXT.className = 'INPUTERROR'; return false;
		}
		else if (!isValidCurrency(oTXT.value)) {
			oTXT.className = 'INPUTERROR'; return false;
		}
		else {
			oTXT.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}

		var oSEL = document.getElementById('seltaxcode' + this.getID());
		if (oSEL.value.length == 0 && this.isRequired()) {
			oSEL.className = 'INPUTERROR'; return false;
		}
		else {
			oSEL.className = (this.isReadonly() ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
		}
	}
	return true;
}
ctlInvoiceItem.prototype.clear = function () { return this.base.clear(); }
ctlInvoiceItem.prototype.show = function (bVal) { document.getElementById('tbl' + this.getID()).style.display=(bVal?'block':'none');return this.base.show(bVal); }
ctlInvoiceItem.prototype.readonly = function (bVal) {
	var octlItemCode = document.getElementById('itemcode' + this.getID());
	octlItemCode.readOnly = bVal;
	octlItemCode.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var octlItemName = document.getElementById('itemname' + this.getID());
	octlItemName.readOnly = bVal;
	octlItemName.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var oTXT = document.getElementById('curprice' + this.getID());
	oTXT.readOnly = bVal;
	oTXT.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	var oSEL = document.getElementById('seltaxcode' + this.getID());
	oSEL.readOnly = bVal;
	oSEL.className = (bVal ? 'INPUTREADONLY' : this.isRequired() ? 'INPUTREQUIRED' : '');
	return this.base.readonly(bVal);
}
ctlInvoiceItem.prototype.required = function (bVal) {
	this.base.required(bVal);
	if (!this.isReadonly() && this.isValid()) {
		var octlDate = document.getElementById('dat' + this.getID());
		octlDate.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlEndDate = document.getElementById('datEnd' + this.getID());
		octlEndDate.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlStart = document.getElementById('tm1' + this.getID());
		octlStart.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlStop = document.getElementById('tm2' + this.getID());
		octlStop.className = (bVal ? 'INPUTREQUIRED' : '');
		var octlDuration = document.getElementById('dur' + this.getID());
		octlDuration.className = (bVal ? 'INPUTREQUIRED' : '');
	}
}
ctlInvoiceItem.prototype.getToken = function () { return this.base.getToken(); }
ctlInvoiceItem.prototype.getID = function () { return this.base.getID(); }

//********************************************************************************
// MASK: ctlTimeMask
//********************************************************************************
function ctlTimeMask(sctlTimeID) {
	this.sctlTimeID = sctlTimeID;
	this._CultureAMPMPlaceholder = 'AM;PM';
	this._CultureTimePlaceholder = ':';
	this._PromptChar = '_';
	this._DelimitStartDup = '{';
	this._DelimitEndDup = '}';   
	this._AutoCompleteValue = '';
	this._CharsEditMask = '9L$CAN?';
	this._CharsSpecialMask = ':';				// at runtime replace with culture property (: = Time placeholder)
	this._MaskConv = '';						// i.e.: 9{2} => 99 , 9{2}/9{2}/9{2} = 99/99/99
	this._DirectSelText = '';					// save the Direction selected Text (only for ie)
	this._initialvalue = '';					// save the initial value for verify changed
	this._LogicSymbol = '';						// save the symbol Negative or AM/PM 
	this._LogicTextMask = '';					// save logic mask with text input
	this._LogicMask = '';						// save logic mask without text
	this._LogicMaskConv = '';					// save logic mask without text and without escape
	this._LogicPrompt = String.fromCharCode(1);	// ID prompt char
	this._LogicEscape = String.fromCharCode(2);	// ID escape char
	this._LogicFirstPos = -1;					// first valid position
	this._LogicLastPos = -1;					// Last valid position 
	this._QtdValidInput = 0;					// Qtd Valid input Position
	this._InLostfocus = false;					// Flag to validate in lost focus not duplicate clearMask execute
	this._Filtered = '';
	this._Mask = '99:99';
	this._charLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	this._charNumbers = '0123456789';
	this._charEscape = "\\";
}

ctlTimeMask.prototype._onFocus = function (eEvt) {
    var evt = (eEvt == null ? (ie ? event : Event) : eEvt);
    var e = this.get_element();
    this._InLostfocus = false;
    var Inipos = this._InitValue();
    var ClearText = this._getClearMask(e.value);
    this._initialvalue = ClearText;
    if (this._CultureAMPMPlaceholder != '' && ClearText == '') this.InsertAMPM('A');
    this.setSelectionRange(Inipos,Inipos);
}
ctlTimeMask.prototype._InitValue = function () {
    var masktxt = this._createMask();
    var Inipos = this._LogicFirstPos;
    var initValue = '';
    var e = this.get_element();
    this._LogicSymbol = '';
    if (e.value != '' && e.value != masktxt) initValue = e.value;
    e.value = (masktxt);
    if (initValue != '') this.loadValue(initValue,this._LogicFirstPos);
    return Inipos;
}
ctlTimeMask.prototype._getClearMask = function (masktext) {
    var i = 0;
    var clearmask = "";
    var qtdok = 0;
    while (i < parseInt(this._LogicTextMask.length,10)) {
        if (qtdok < this._QtdValidInput) {
            if (this._isValidMaskedEditPosition(i) && this._LogicTextMask.substring(i, i+1) != this._LogicPrompt) {
                clearmask += this._LogicTextMask.substring(i,i+1);
                qtdok++;
            }
            else if (this._LogicTextMask.substring(i, i+1) != this._LogicPrompt && this._LogicTextMask.substring(i, i+1) != this._LogicEscape) {
                if (this._LogicTextMask.substring(i,i+1) == this._CultureTimePlaceholder) clearmask += (clearmask == "")?"":this._CultureTimePlaceholder;
            }
        }
        i++;
    }
    if (this._LogicSymbol != "" && clearmask != "") clearmask += " " + this._LogicSymbol;
    return clearmask;    
}
ctlTimeMask.prototype.InsertAMPM = function (value) {
    var masktext = this.get_element().value;
    var ASymMask = this._CultureAMPMPlaceholder.split(';');
    var symb =  '';
    if (ASymMask.length == 2) {
        if (value.toUpperCase() == this.get_CultureFirstLetterAM().toUpperCase()) symb = ASymMask[0];
        else if (value.toUpperCase() == this.get_CultureFirstLetterPM().toUpperCase()) symb = ASymMask[1];
        this._LogicSymbol = symb;
    }
    masktext = masktext.substring(0,this._LogicLastPos+2) + symb + masktext.substring(this._LogicLastPos+2+symb.length);
    this.get_element().value = (masktext);
}
ctlTimeMask.prototype.setSelectionRange = function (selectionStart, selectionEnd) {
	input = this.get_element();
	if (ie) {
		var range = input.createTextRange();
		range.collapse(true);
		range.moveEnd('character', selectionEnd);
		range.moveStart('character', selectionStart);
		range.select();
	}
	else if (moz) input.setSelectionRange(selectionStart, selectionEnd);
}
ctlTimeMask.prototype.get_element = function () {
	return document.getElementById(this.sctlTimeID);
}
ctlTimeMask.prototype._createMask = function () {
    var text;
    if (this._MaskConv == '' && this._Mask != '') this._convertMask();
    text = this._MaskConv;
    var i = 0;
    var masktext = "";
    var flagescape = false;
    this._LogicTextMask = "";
    this._QtdValidInput = 0;
    while (i < parseInt(text.length,10)) {
        if (text.substring(i, i+1) == this._charEscape && flagescape == false) flagescape = true;
        else if (this._CharsEditMask.indexOf(text.substring(i, i+1)) == -1) {
            if (flagescape == true) {
                flagescape = false;
                masktext += text.substring(i,i+1);
                this._LogicTextMask += this._LogicEscape;
            }
            else {
                if (this._CharsSpecialMask.indexOf(text.substring(i, i+1)) != -1) {
                    this._QtdValidInput ++;
                    if (text.substring(i, i+1) == ':') {
                        masktext += this._CultureTimePlaceholder;
                        this._LogicTextMask += this._CultureTimePlaceholder;
                    }
                }
                else {
                    masktext += text.substring(i,i+1);
                    this._LogicTextMask += text.substring(i,i+1);
                }
            }
        } 
        else {
            if (flagescape == true) {
                flagescape = false;
                masktext += text.substring(i,i+1);
                this._LogicTextMask += this._LogicEscape;
            }
            else {
                this._QtdValidInput ++;
                masktext += this._PromptChar;
                this._LogicTextMask += this._LogicPrompt;
            }
        }
        i++;
    }
    this._LogicFirstPos = -1;
    this._LogicLastPos = -1;
    this._LogicMask = this._LogicTextMask;
    for (i = 0 ; i < parseInt(this._LogicMask.length,10) ; i++) {
        if (this._LogicFirstPos == -1 && this._LogicMask.substring(i,i+1) == this._LogicPrompt) this._LogicFirstPos = i;
        if (this._LogicMask.substring(i,i+1) == this._LogicPrompt) this._LogicLastPos = i;
    }
    return masktext;    
}
ctlTimeMask.prototype._convertMask = function () {
    this._MaskConv = '';
    var qtdmask = '';
    var maskchar = '';
    for (i = 0 ; i < parseInt(this._Mask.length,10) ; i++) {
      if (this._CharsEditMask.indexOf(this._Mask.substring(i, i+1)) != -1) {
        if (qtdmask.length == 0) {
            this._MaskConv += this._Mask.substring(i, i+1);
            qtdmask = '';
            maskchar = this._Mask.substring(i, i+1);
        }
        else if (this._Mask.substring(i, i+1) == '9') qtdmask += '9';
        else if (this._Mask.substring(i, i+1) == '0') qtdmask += '0';
      }
      else if (this._CharsEditMask.indexOf(this._Mask.substring(i, i+1)) == -1 && this._Mask.substring(i, i+1) != this._DelimitStartDup && this._Mask.substring(i, i+1) != this._DelimitEndDup) {
        if (qtdmask.length == 0) {
            this._MaskConv += this._Mask.substring(i, i+1);
            qtdmask = '';
            maskchar = '';
        }
        else if (this._charNumbers.indexOf(this._Mask.substring(i, i+1)) != -1) qtdmask += this._Mask.substring(i, i+1);
      }
      else if (this._Mask.substring(i, i+1) == this._DelimitStartDup && qtdmask == "") qtdmask = '0';
      else if (this._Mask.substring(i, i+1) == this._DelimitEndDup && qtdmask != "") {
        qtddup = parseInt(qtdmask,10) -1;
        if (qtddup > 0) {
            for (q = 0 ; q < qtddup ; q++) {
                this._MaskConv += maskchar;
            }
        }
        qtdmask = '';
        maskchar = '';
      }
    }
    var FirstPos = -1;
    var LastPos = -1;
    var flagescape = false;
    for (i = 0 ; i < parseInt(this._MaskConv.length,10) ; i++) {
        if (this._MaskConv.substring(i, i+1) == this._charEscape && !flagescape) flagescape = true;
        else if (this._CharsEditMask.indexOf(this._MaskConv.substring(i, i+1)) != -1 && !flagescape) {
            if (FirstPos == -1) FirstPos = i;
            LastPos = i;
        } 
        else if(flagescape) flagescape = false;
    }
    var ASymMask = this._CultureAMPMPlaceholder.split(';');
    var SymMask = '';
    if (ASymMask.length == 2) {
        SymMask = this._charEscape + ' ';
        for (i = 0 ; i < parseInt(ASymMask[0].length,10) ; i++) {
            SymMask += this._charEscape + ' ';
        }
    }
    this._MaskConv = this._MaskConv.substring(0,LastPos+1) + SymMask + this._MaskConv.substring(LastPos+1);
    this._convertMaskNotEscape();
}
ctlTimeMask.prototype.get_CultureFirstLetterAM = function () {
    if (this._CultureAMPMPlaceholder != "") {
        var ASymMask = this._CultureAMPMPlaceholder.split(";");
        return ASymMask[0].substring(0,1);
    }
    return "";
}   
ctlTimeMask.prototype.get_CultureFirstLetterPM = function () {
    if (this._CultureAMPMPlaceholder != "") {
        var ASymMask = this._CultureAMPMPlaceholder.split(";");
        return ASymMask[1].substring(0,1);
    }
    return "";
}   
ctlTimeMask.prototype.loadValue = function (initValue,logicPosition) {
    var oldfocus = this._InLostfocus;   
    var i = 0;
    this._InLostfocus = false;
    for (i = 0 ; i < parseInt(initValue.length,10) ; i++) {
        var c = initValue.substring(i,i+1);     
        if (this.get_CultureFirstLettersAMPM().toUpperCase().indexOf(c.toUpperCase()) != -1) this.InsertAMPM(c);
        if (this._processKey(logicPosition,c)) {
            this._insertContent(c,logicPosition);
            logicPosition  = this._getNextPosition(logicPosition+1);
        }
    }
    this._InLostfocus = oldfocus;
}
ctlTimeMask.prototype.get_CultureFirstLettersAMPM = function () {
    if (this._CultureAMPMPlaceholder != "") {
        var ASymMask = this._CultureAMPMPlaceholder.split(";");
        return (ASymMask[0].substring(0,1) + ASymMask[1].substring(0,1));
    }
    return "";
}
ctlTimeMask.prototype._processKey = function (poscur,key) {
    var posmask = this._LogicMaskConv;
    var filter;
    if  (posmask.substring(poscur,poscur+1) == "9") filter = this._charNumbers;
    else if  (posmask.substring(poscur,poscur+1).toUpperCase() == "L") filter = this._charLetters + this._charLetters.toLowerCase();
    else if  (posmask.substring(poscur,poscur+1) == "$") filter = this._charLetters + this._charLetters.toLowerCase() + " ";
    else if  (posmask.substring(poscur,poscur+1).toUpperCase() == "C") filter = this._Filtered;
    else if  (posmask.substring(poscur,poscur+1).toUpperCase() == "A") filter = this._charLetters + this._charLetters.toLowerCase() + this._Filtered;
    else if  (posmask.substring(poscur,poscur+1).toUpperCase() == "N") filter = this._charNumbers + this._Filtered;
    else if  (posmask.substring(poscur,poscur+1) == "?") filter = "";
    else return false;
    if (filter == "") return true;
    return (!filter || filter.length == 0 || filter.indexOf(key) != -1);
}    
ctlTimeMask.prototype._convertMaskNotEscape = function () {
    this._LogicMaskConv = "";
    var atumask = this._MaskConv;
    var flagescape = false;
    for (i = 0 ; i < parseInt(atumask.length,10); i++) {
        if (atumask.substring(i, i+1) == this._charEscape) flagescape = true;
        else if (!flagescape) this._LogicMaskConv += atumask.substring(i, i+1);
        else {
            this._LogicMaskConv += this._LogicEscape;
            flagescape = false;
        }
    }
}
ctlTimeMask.prototype._isValidMaskedEditPosition = function (pos) {
    return (this._LogicMask.substring(pos,pos+1) == this._LogicPrompt);
}
ctlTimeMask.prototype._insertContent = function (value,curpos) {
    var masktext = this.get_element().value;
    masktext = masktext.substring(0,curpos) + value + masktext.substring(curpos+1);
    this._LogicTextMask = this._LogicTextMask.substring(0,curpos) + value + this._LogicTextMask.substring(curpos+1);
    this.get_element().value = (masktext);
}    
ctlTimeMask.prototype._getNextPosition = function (pos) {
    while (!this._isValidMaskedEditPosition(pos) && pos < this._LogicLastPos+1) {
        pos++;
    }
    if (pos > this._LogicLastPos+1) pos = this._LogicLastPos+1;
    return pos;
}
ctlTimeMask.prototype._onKeyPressdown = function (eEvt) {
    var evt = (eEvt == null ? (ie ? event : Event) : eEvt);
    if (evt == null) return;
    if (this.get_element().readOnly) {
        this._SetCancelEvent(evt);
        return ;
    }
    if ((ie ? evt.keyCode : evt.charCode) == 13) {
        this._onBlur(evt);
        return;
    }
    if (!ie) if (this._InLostfocus) this._onFocus(evt);
    if (ie) {
        var scanCode = (ie ? evt.keyCode : evt.charCode);
        this._OnNavigator(scanCode,evt,true)
    }
}
ctlTimeMask.prototype._SetCancelEvent = function (evt) {
    if (ie) evt.returnValue = false;
    else {
        if (typeof(evt.returnValue) != "undefined") evt.returnValue = false;
        if (evt.preventDefault) evt.preventDefault();
    }
}
ctlTimeMask.prototype._onBlur = function (eEvt) {
    var evt = (eEvt == null ? (ie ? event : Event) : eEvt);
    this._InLostfocus = true;
    ValueText = this.get_element().value;
    ClearText = this._getClearMask(ValueText);
    if (ClearText != "") {
        var CurDate = new Date();
        var Hcur = CurDate.getHours().toString();
        if (Hcur.length < 2) Hcur = "0" + Hcur;
        if (this._AutoCompleteValue != "" ) Hcur = this._AutoCompleteValue.substring(0,2);
        var Symb = "";
        if (this._CultureAMPMPlaceholder != "") {
            var m_arrtm = this._CultureAMPMPlaceholder.split(";");
            var Symb = m_arrtm[0].substring(0,1);
            if (Hcur > 12) {
                Hcur = (parseInt(Hcur,10) - 12).toString();
                if (Hcur.length < 2) Hcur = "0" + Hcur;
                Symb = m_arrtm[1].substring(0,1);
            }
        }
        var Mcur = CurDate.getMinutes().toString();
        if (Mcur.length < 2) Mcur = "0" + Mcur;
        if (this._AutoCompleteValue != "" ) Mcur = this._AutoCompleteValue.substring(3,2);
        var Scur = CurDate.getSeconds().toString();
        if (Scur.length < 2) Scur = "0" + Scur;
        var maskvalid = this._MaskConv.substring(this._LogicFirstPos,this._LogicFirstPos+this._LogicLastPos+1);    
        var PH = ValueText.substring(this._LogicFirstPos,this._LogicFirstPos+2);
        PH = this._AdjustElementTime(PH,Hcur);
        var PM = ValueText.substring(this._LogicFirstPos+3,this._LogicFirstPos+5);
        PM = this._AdjustElementTime(PM,Mcur);
        if (maskvalid == "99" + this._CultureTimePlaceholder + "99" + this._CultureTimePlaceholder + "99") {
            if (this._AutoCompleteValue != "" ) Scur = this._AutoCompleteValue.substring(5);
            PS = ValueText.substring(this._LogicFirstPos+6,this._LogicLastPos+1);
            PS = this._AdjustElementTime(PS,Scur);
            ValueText = ValueText.substring(0,this._LogicFirstPos) + PH + this._CultureTimePlaceholder + PM + this._CultureTimePlaceholder + PS + ValueText.substring(this._LogicLastPos+1);
            this._LogicTextMask = this._LogicTextMask.substring(0,this._LogicFirstPos) + PH + this._CultureTimePlaceholder + PM + this._CultureTimePlaceholder + PS + this._LogicTextMask.substring(this._LogicLastPos+1);
        }
        else {
            ValueText = ValueText.substring(0,this._LogicFirstPos) + PH + this._CultureTimePlaceholder + PM + ValueText.substring(this._LogicLastPos+1);
            this._LogicTextMask = this._LogicTextMask.substring(0,this._LogicFirstPos) + PH + this._CultureTimePlaceholder + PM + this._LogicTextMask.substring(this._LogicLastPos+1);
        }
        this.get_element().value = (ValueText);
        ClearText = this._getClearMask(ValueText);
    }
    this.get_element().value = (ClearText);
    ValueText = ClearText;
}
ctlTimeMask.prototype._OnNavigator = function (scanCode,evt,navkey) {
    if (!navkey) return true;
    var curpos;
    if (this._processDeleteKey(scanCode)) {
        curpos = this._getCurrentPosition();
        if (curpos <= this._LogicFirstPos) this.setSelectionRange(this._LogicFirstPos,this._LogicFirstPos);
        this._SetCancelEvent(evt);
        return false;
    }
    if((evt.ctrlKey || evt.altKey || evt.shiftKey || evt.metaKey)) {
        if (scanCode == 39 && evt.ctrlKey) {
            this._DirectSelText = "R";
            curpos = this._getCurrentPosition();
            if (curpos >= this._LogicLastPos+1) {
                this.setSelectionRange(this._LogicLastPos+1,this._LogicLastPos+1);
                this._SetCancelEvent(evt);
                return false;
            }
            return  true;
        }
        else if (scanCode == 37 && evt.ctrlKey) {
            this._DirectSelText = "L";
            curpos = this._getCurrentPosition();
            if (curpos <= this._LogicFirstPos) {
                this.setSelectionRange(this._LogicFirstPos,this._LogicFirstPos);
                this._SetCancelEvent(evt);
                return false;
            }
            return true;
        }
        else if (scanCode == 35 && evt.shiftKey) { //END 
            this._DirectSelText = "R";
            curpos = this._getCurrentPosition();
            this.setSelectionRange(curpos,this._LogicLastPos+1);
            this._SetCancelEvent(evt);
            return false;
        }
        else if (scanCode == 36 && evt.shiftKey) { //Home 
            this._DirectSelText = "L";
            curpos = this._getCurrentPosition();
            this.setSelectionRange(this._LogicFirstPos,curpos);
            this._SetCancelEvent(evt);
            return false;
        }
        else if (scanCode == 35 || scanCode == 34) { //END or pgdown
            this._DirectSelText = "R";
            this.setSelectionRange(this._LogicLastPos+1,this._LogicLastPos+1);
            this._SetCancelEvent(evt);
            return false;
        }
        else if (scanCode == 36 || scanCode == 33) { //Home or pgup
            this._DirectSelText = "L";
            this.setSelectionRange(this._LogicFirstPos,this._LogicFirstPos);
            this._SetCancelEvent(evt);
            return false;
        }
        return true;
    }
    if (scanCode == 35 || scanCode == 34) { //END or pgdown
        this._DirectSelText = "R";
        this.setSelectionRange(this._LogicLastPos+1,this._LogicLastPos+1);
        this._SetCancelEvent(evt);
        return false;
    }
    else if (scanCode == 36 || scanCode == 33) { //Home or pgup
        this._DirectSelText = "L";
        this.setSelectionRange(this._LogicFirstPos,this._LogicFirstPos);
        this._SetCancelEvent(evt);
        return  false;
    }
    else if (scanCode == 37) {
        this._DirectSelText = "L";
        curpos = this._getCurrentPosition();
        if (curpos <= this._LogicFirstPos) {
            this.setSelectionRange(this._LogicFirstPos,this._LogicFirstPos);
            this._SetCancelEvent(evt);
            return false;
        }
        return true;
    }
    else if (scanCode == 38 || scanCode == 40) {
        this._SetCancelEvent(evt);
        return false;
    }
    else if (scanCode == 39) {
        this._DirectSelText = "R";
        curpos = this._getCurrentPosition();
        if (curpos >= this._LogicLastPos+1) {
            this.setSelectionRange(this._LogicLastPos+1,this._LogicLastPos+1);
            this._SetCancelEvent(evt);
            return false;
        }
        return true;
    }
    return true;
}
ctlTimeMask.prototype._AdjustElementTime = function (value,ValueDefault) {
    var emp = true;    
    for (i = 0 ; i < parseInt(value.length,10) ; i++) {
        if (value.substring(i,i+1) != this._PromptChar) emp = false;
    }
    if (emp) return ValueDefault;
    for (i = 0 ; i < parseInt(value.length,10) ; i++) {
        if (value.substring(i,i+1) == this._PromptChar) value = value.substring(0,i) + "0" + value.substring(i+1);
    }
    return value;
}
ctlTimeMask.prototype._processDeleteKey = function (scanCode) {
    if (scanCode == 46 /*delete*/)  {
        var curpos = this._deleteTextSelection();
        if (curpos == -1) {
            curpos = this._getCurrentPosition();
            this._deleteAtPosition(curpos);
        }
        this.setSelectionRange(curpos,curpos);
        return true;
    }
    else if (scanCode == 8 /*back-space*/) {
        var curpos = this._getCurrentPosition();
        if (curpos <= this._LogicFirstPos) return true;
        this._deleteAtPosition(curpos);
        this.setSelectionRange(curpos,curpos);
        curpos = this._deleteTextSelection();
        if (curpos == -1) {
            curpos = this._getPreviousPosition(this._getCurrentPosition()-1);
            this._backspace(curpos);
        }
        this.setSelectionRange(curpos,curpos);
        return true;
    }
    return false;
}
ctlTimeMask.prototype._deleteTextSelection = function () {
    var masktext = this.get_element().value;
    var input = this.get_element();
    var ret = -1;
    var lenaux = -1;
    var begin = -1;
    if (ie) {
        sel = document.selection.createRange();
        if (sel.text != "") {
            var aux = sel.text + String.fromCharCode(3);
            sel.text = aux;
            dummy = input.createTextRange();
            dummy.findText(aux);
            dummy.select();
            begin = input.value.indexOf(aux);
            if (this._DirectSelText == "P") {
                this._DirectSelText = "";
                ret = begin;
            }
            else ret = begin;
            document.selection.clear();
            lenaux = parseInt(aux.length,10)-1;
        }
    }
    else if (moz) {
        if (input.selectionStart != input.selectionEnd) {
            var ini = parseInt(input.selectionStart,10);
            var fim = parseInt(input.selectionEnd,10);
            lenaux = fim - ini;
            begin=input.selectionStart;
            if (this._DirectSelText == "P") {
                this._DirectSelText = "";
                input.selectionEnd = input.selectionStart;
                ret = begin;
            }
            else {
                input.selectionEnd = input.selectionStart;
                ret = begin;
            }
        }
    }
    if (ret !=-1) {
        for (i = 0 ; i < lenaux ; i++) {
            if (this._isValidMaskedEditPosition(begin+i)) {
                masktext = masktext.substring(0,begin+i) + this._PromptChar + masktext.substring(begin+i+1);
                this._LogicTextMask = this._LogicTextMask.substring(0,begin+i) + this._LogicPrompt + this._LogicTextMask.substring(begin+i+1);
            }
        }
        this.get_element().value = (masktext);
    }
    return ret;
}
ctlTimeMask.prototype._getCurrentPosition = function () {
    begin = 0;
    input = this.get_element();
    if (moz) begin = parseInt(input.selectionStart,10);
    else if (ie) {
        sel = document.selection.createRange();
        if (sel.text != "") {
            var aux = ""
            if (this._DirectSelText == "R") aux = sel.text + String.fromCharCode(3);
            else if (this._DirectSelText == "L") aux = String.fromCharCode(3) + sel.text ;
            sel.text = aux;
            this._DirectSelText == "";
        }
        else {
            sel.text = String.fromCharCode(3);
            this._DirectSelText == "";
        }
        dummy = input.createTextRange();
        dummy.findText(String.fromCharCode(3));
        dummy.select();
        begin = input.value.indexOf(String.fromCharCode(3));
        document.selection.clear();
    }
    if (begin > this._LogicLastPos+1) begin = this._LogicLastPos+1;
    if (begin < this._LogicFirstPos) begin = this._LogicFirstPos;
    return begin;
}
ctlTimeMask.prototype._deleteAtPosition = function (curpos) {
    var masktext = this.get_element().value;
    if (this._isValidMaskedEditPosition(curpos)) {
        var resttext = masktext.substring(curpos+1);
        var restlogi = this._LogicTextMask.substring(curpos+1);
        masktext = masktext.substring(0,curpos) + this._PromptChar;
        this._LogicTextMask = this._LogicTextMask.substring(0,curpos) + this._LogicPrompt;
        for (i = 0 ; i < parseInt(resttext.length,10) ; i++) {
            if (this._isValidMaskedEditPosition(curpos+1+i)) {
                masktext += this._PromptChar;
                this._LogicTextMask += this._LogicPrompt;
            }
            else {
                masktext += resttext.substring(i,i+1);
                this._LogicTextMask += restlogi.substring(i,i+1);
            }
        }
        posaux = this._getNextPosition(curpos);
        for (i = 0 ; i < parseInt(resttext.length,10) ; i++) {
            if (this._isValidMaskedEditPosition(curpos+1+i) && restlogi.substring(i,i+1) != this._LogicPrompt) {
                masktext = masktext.substring(0,posaux) + resttext.substring(i,i+1) + masktext.substring(posaux+1);
                this._LogicTextMask = this._LogicTextMask.substring(0,posaux) + restlogi.substring(i,i+1) + this._LogicTextMask.substring(posaux+1);
                posaux = this._getNextPosition(posaux+1);
            }
        }            
        this.get_element().value = (masktext);
    }
}
ctlTimeMask.prototype._getPreviousPosition = function (pos) {
    while (!this._isValidMaskedEditPosition(pos) && pos > this._LogicFirstPos) { pos--; }
    if (pos < this._LogicFirstPos) pos = this._LogicFirstPos;
    return pos;
}
ctlTimeMask.prototype._backspace = function (curpos) {
    var masktext = this.get_element().value;
    if (this._isValidMaskedEditPosition(curpos)) {
        masktext = masktext.substring(0,curpos) + this._PromptChar + masktext.substring(curpos+1);
        this._LogicTextMask = this._LogicTextMask.substring(0,curpos) + this._LogicPrompt + this._LogicTextMask.substring(curpos+1);
        this.get_element().value = (masktext);
    }
}
ctlTimeMask.prototype._onKeyPress = function (eEvt) {
    var evt = (eEvt == null ? (ie ? event : Event) : eEvt);
    if (evt == null) return;
    if (this.get_element().readOnly) {
        this._SetCancelEvent(evt);
        return;
    }
    var scanCode;
    var navkey = false;
    if (ie) scanCode = evt.keyCode;
    else {
        scanCode = evt.charCode;
        if (evt.keyIdentifier) {
            if (evt.ctrlKey || evt.altKey || evt.metaKey) return;
            if (evt.keyIdentifier.substring(0,2) != "U+") return;
            if (scanCode == 63272) {
                scanCode = 46;
                navkey = true;
            }
            else if (scanCode == 63302) {
                scanCode = 45;
                navkey = true;
            }
            else if (scanCode == 63233) {
                scanCode = 40;
                navkey = true;
            }
            else if (scanCode == 63235) {
                scanCode = 39;
                navkey = true;
            }
            else if (scanCode == 63232) {
                scanCode = 38;
                navkey = true;
            }
            else if (scanCode == 63234) {
                scanCode = 37;
                navkey = true;
            }
            else if (scanCode == 63273) {
                scanCode = 36;
                navkey = true;
            }
            else if (scanCode == 63275) {
                scanCode = 35;
                navkey = true;
            }
            else if (scanCode == 63277) {
                scanCode = 34;
                navkey = true;
            }
            else if (scanCode == 63276) {
                scanCode = 33;
                navkey = true;
            }
            else if (scanCode == 3) {
                scanCode = 13;
                navkey = true;
            }
        }
        if (typeof(evt.which) != "undefined" && evt.which !=null) {
            if (evt.which == 0) navkey = true;
        }
        if (navkey && scanCode == 13) {
            this._onBlur(evt);
            return;
        }
        if (scanCode == 8) navkey = true;
        if (!this._OnNavigator(scanCode,evt,navkey)) return;
        if (this.SpecialNavKey(scanCode,navkey)) return;
    }
    if (scanCode && scanCode >= 0x20 /* space */) {
        var c = String.fromCharCode(scanCode);
        var curpos = -1;
        if (ie) curpos = this._deleteTextSelection(); 
        if (curpos == -1) curpos = this._getCurrentPosition();
        if (curpos <= this._LogicFirstPos) {
            this.setSelectionRange(this._LogicFirstPos,this._LogicFirstPos);
            curpos = this._LogicFirstPos;
        }
        else if (curpos >= this._LogicLastPos+1) {
            this.setSelectionRange(this._LogicLastPos+1,this._LogicLastPos+1);
            curpos = this._LogicLastPos+1;
        }
        var logiccur = curpos;
        if (this.get_CultureFirstLettersAMPM().toUpperCase().indexOf(c.toUpperCase()) != -1) {
            this.InsertAMPM(c);
            this.setSelectionRange(curpos,curpos);
            this._SetCancelEvent(evt);
            return ;
        }
        else if (this._processKey(logiccur,c)) {
            this._insertContent(c,curpos);
            curpos = this._getNextPosition(curpos+1);
            this.setSelectionRange(curpos,curpos);
            this._SetCancelEvent(evt);
            return ;
        }
        else {
            if (!this.SpecialNavKey(scanCode,navkey)) this._SetCancelEvent(evt);
            return;
        }
    }
}
ctlTimeMask.prototype.SpecialNavKey = function (keyCode,navkey) {
    if (ie) return false;
    return (keyCode >= 33 && keyCode <= 45 && navkey);
}
