HxG_5.prototype.JSFSpinner=function () {
this.type=hX_5.CMP_spinner;
this.buttonBorder=-1;
this.buttonColor=hX_5.CLR_BTN;
this.interval=this.interval1=this.interval2=this.saveArgs=null;
this.dataType=hX_5.CVT_number;
this.NPid=this.NVid=hX_5._E;
this.NP=this.NV=null;
this.localNP=this.localNV=false;
this.spinstate=0;
this.JSFBTN=this.mouseToken=this.valueToken=null;
this.attributeTable=[];
this.attributeTable ['type']=['dataType',		hX_5.ARG_TO_NAN,	true,	null,	null];
this.attributeTable ['validator']=['NVid',			hX_5.ARG_TO_NAN,	false,	null,	null];
this.attributeTable ['converter']=['NPid',			hX_5.ARG_TO_NAN,	false,	null,	null];
this.attributeTable ['increment']=['interval',		hX_5.ARG_TO_NUM,	false,	0,		9999999];
this.attributeTable ['increment1']=['interval1',		hX_5.ARG_TO_NUM,	false,	0,		9999999];
this.attributeTable ['increment2']=['interval2',		hX_5.ARG_TO_NUM,	false,	0,		9999999];
this.attributeTable	['button-color']=['buttonColor',	hX_5.ARG_TO_NAN,	false,	null,	null];
this.attributeTable	['button-border']=['buttonBorder',	hX_5.ARG_TO_NUM,	false,	-1,		3];
this.setAttribute(arguments);
}
HxG_5.prototype.JSFSpinner.prototype.onPageLoad=function () {
if (this.dataType != hX_5.CVT_number && this.dataType != hX_5.CVT_datetime) this.dataType=hX_5.CVT_number;
if (this.NPid && this.NP == null) this.NP=hX_5.getConverterById(this.NPid);
if (this.NP == null) {
this.NP=(this.dataType==hX_5.CVT_datetime)?(new hX_5.DateTimeConverter()):(new hX_5.NumberConverter());
this.localNP=true;
}
if (this.NVid && this.NV == null) this.NV=hX_5.getValidatorById(this.NVid);
if (this.NV == null) {
this.NV=(this.dataType == hX_5.CVT_datetime)?(new hX_5.DateTimeValidator()):(new hX_5.NumberValidator());
this.localNV=true;
}
this.JSFBTN=new hX_5.JSFSubButton(this, 2, this.buttonBorder, this.buttonColor, hX_5.L[this.lc].STR_SPINNER_INCREMENT, hX_5.L[this.lc].STR_SPINNER_DECREMENT, false);
this.redraw();
return true;
}
HxG_5.prototype.JSFSpinner.prototype.redraw=function (resizeOnly) {
if (this.JSFBTN) this.JSFBTN.size(resizeOnly);
return true;
}
HxG_5.prototype.JSFSpinner.prototype.uirelease=function (free) {
this.spinstate=0;
if (this.JSFBTN) this.JSFBTN.depress ("btn1", false);
if (this.JSFBTN) this.JSFBTN.depress ("btn2", false);
if (free!=null) hX_5.uirelease(true);
return true;
}
HxG_5.prototype.JSFSpinner.prototype.destroy=function () {
if (this.JSFBTN) {
if (this.JSFBTN.destroy) this.JSFBTN.destroy();
delete this.JSFBTN;
}
if (this.localNV) delete this.NV;
if (this.localNP) delete this.NP;
delete this.attributeTable;
return true;
}
HxG_5.prototype.JSFSpinner.prototype.setValue=function (value, notify, returns) {
var r=false;
if (this.DOMobj) {
var ivalue=(hX_5.isString(value))?this.NP.stringToValue (value):value;
if (ivalue!=null) {
ivalue=this.NV.coerce (ivalue, this.NP);
if (returns)
r=(ivalue != null) ? this.NP.valueToString(ivalue) : hX_5._E;
else {
this.DOMobj.value=(ivalue != null) ? this.NP.valueToString(ivalue) : hX_5._E;
if (notify) {
hX_5.i.markEvent (this.DOMobj, hX_5._onF);
hX_5.i.fireEvent (this.DOMobj, hX_5._onC);
hX_5.i.fireEvent (this.DOMobj, hX_5._onB);
}
r=true;
}
}
}
return r;
}
HxG_5.prototype.JSFSpinner.prototype.getValue=function(cast) {
if (this.DOMobj) return (cast)?(this.NV.coerce(this.DOMobj.value, this.NP)):this.DOMobj.value;
return null;
}
HxG_5.prototype.JSFSpinner.prototype.reValue=function (buttonitem, notify, inValue) {
if (this.DOMobj) {
var pos, delta=0, token=hX_5._E, value=(inValue!=null) ? this.NV.coerce(inValue, this.NP) : this.getValue(true);
if (value == null || isNaN(value))
value=(this.dataType==hX_5.CVT_datetime) ? new Date() : new Number(0);
else {
delta=this.interval;
if (this.dataType==hX_5.CVT_datetime && this.interval1!=null) {
if (this.mouseToken!=null) token=this.mouseToken;
else {
pos=hX_5.sel.getCaretPos(this.DOMobj, false);
token=this.NP.stringToLastToken(this.getValue(), pos);
}
if (token==hX_5._lH) delta=this.interval;
else if (token==hX_5._lM) delta=this.interval1;
else delta=this.interval2;
}
delta=(buttonitem == "btn1") ? delta : -delta;
if (this.dataType==hX_5.CVT_number) {
var absdelta=(delta < 0) ? -(delta) : delta;
if (absdelta >= 5) value=(delta >= 0)?((Math.floor(value/absdelta))* absdelta):((Math.ceil(value/absdelta))* absdelta);
}
}
if (this.dataType==hX_5.CVT_number) {
var absD=(delta < 0) ? -(delta) : delta;
if (absD < 1) {
var delta1, power10, power=(absD < .01) ? 3 : ((absD < .1) ? 2 : 1);
power10=Math.pow(10,power);
delta1=delta*power10; value1=value*power10;
value=(value1 + delta1)/power10;
} else  value=value + delta;
} else {
var wasDay=value.getDate();
hX_5.cal.adjustDate(value,0,0,0,0,0,delta);
if (value.getDate()!=wasDay) {
if (delta <=0) {
value.setDate(wasDay);
value.setHours(0);
value.setMinutes(0);
value.setSeconds(0);
} else {
value.setDate(wasDay);
value.setHours(23);
value.setMinutes(59);
value.setSeconds(59);
}
}
}
if (inValue!=null)
return (this.setValue(value, false, true));
else {
this.setValue (value, notify);
if (this.interval1!=null) {
var newpos=this.NP.posFromLastToken(this.getValue(), token);
hX_5.sel.setCaretPos(this.DOMobj, newpos);
this.valueToken=token;
}
}
}
return null;
}
HxG_5.prototype.JSFSpinner.prototype.setAttribute=function(a) {
var wasV=this.NVid, wasC=this.NPid;
hX_5.parseArg (this.attributeTable, this, a);
if (this.bDsc) {
this.bDsc.btnColor=this.buttonColor
 this.bDsc.btnBorder=this.buttonBorder;
}
if (this.NPid && this.NPid != wasC) this.NP=hX_5.getConverterById(this.NPid);
if (this.NVid && this.NVid != wasV) this.NV=hX_5.getValidatorById(this.NVid);
if (this.dataType == hX_5.CVT_datetime) {
if (this.interval1==null) {
this.interval=(this.interval!=null || this.interval==0) ? this.interval : 3600;
this.interval2=null;
} else {
this.interval=(this.interval !=null) ? this.interval  : 0;
this.interval1=(this.interval1!=null) ? this.interval1 : 0;
this.interval2=(this.interval2!=null) ? this.interval2 : 0;
if (this.interval==0 && this.interval1==0 && this.interval2==0) {
this.interval=60; this.interval1=60; this.interval2=60;
} else {
if (this.interval==0 && this.interval1!=0) this.interval=this.interval1;
if (this.interval==0) this.interval=60;
if (this.interval1==0) this.interval1=this.interval;
if (this.interval2==0) this.interval2=this.interval1;
}
}
} else
 this.interval=(this.interval!=null && this.interval!=0) ? this.interval : 1;
this.mouseToken=this.valueToken=null;
if (this.HTMLrendered) this.redraw();
return true;
}
HxG_5.prototype.JSFSpinner.prototype.getAttribute=function (attribute) {
return (hX_5.getArg(this.attributeTable, this, attribute));
}
HxG_5.prototype.JSFSpinner.prototype.isRedirectFcnKey=function (evt) {
if (evt.altKey || evt.ctrlKey) return false;
var code=(evt.keyCode && (evt.keyCode != 0)) ? evt.keyCode : -1;
if (code == hX_5.KEY_UPARROW || code == hX_5.KEY_DNARROW) return true;
return false;
}
HxG_5.prototype.JSFSpinner.prototype.doRedirectFcnKey=function (evt, newValue) {
var r=null, code=(evt.keyCode && (evt.keyCode != 0))?evt.keyCode:-1;
if (evt.altKey || evt.ctrlKey) return r;
if (code == hX_5.KEY_UPARROW) r=this.reValue("btn1", false, newValue);
else if (code == hX_5.KEY_DNARROW) r=this.reValue("btn2", false, newValue);
return r;
}
HxG_5.prototype.JSFSpinner.prototype.dispatchComponent=function (item, evt, action, keycode) {
var pos, saveToken=this.mouseToken;
this.mouseToken=null;
if (item == "btn1" || item == "btn2") {
switch (action) {
case hX_5._evMC:
this.mouseToken=saveToken;
this.uirelease(true);
this.JSFBTN.depress (item, true);
this.reValue(item, true);
this.uirelease(true);
break;
case hX_5._evMCC:
this.mouseToken=saveToken;
this.uirelease(true);
if (hX_5.brw.isIE()) {
this.JSFBTN.depress (item, true);
this.reValue(item, true);
this.uirelease(true);
}
break;
case hX_5._evMD:
if (this.dataType==hX_5.CVT_datetime) {
pos=(hX_5.sel.getCaretPos(this.DOMobj));
if (this.interval1!=null && hX_5.brw.isIE() && pos<0 && this.valueToken!=null)
this.mouseToken=this.valueToken;
else
 this.mouseToken=(pos>=0)?this.NP.stringToLastToken(this.getValue(), pos):null;
} else this.mouseToken=null;
this.uirelease(true);
this.JSFBTN.depress (item, true);
this.spinstate=1;
hX_5.i.startTimerTimed (this.id, item, "start", 400);
break;
case hX_5._evMO:
case hX_5._evMU:
this.mouseToken=saveToken;
if (this.spinstate == 1) this.uirelease(true);
break;
case hX_5._evKD:
if (this.spinstate == 0) this.uirelease(true);
if (keycode == hX_5.KEY_ENTER || keycode == hX_5.KEY_SPACEBAR) {
this.spinstate=1;
this.JSFBTN.depress (item, true);
this.reValue(item, true);
hX_5.i.cancelAction(evt);
return false;
} else if (!evt.ctrlKey && keycode == hX_5.KEY_UPARROW) {
this.spinstate=1;
this.JSFBTN.depress ("btn1", true);
this.reValue("btn1", true);
hX_5.i.cancelAction(evt);
return false;
} else if (!evt.ctrlKey && keycode == hX_5.KEY_DNARROW) {
this.spinstate=1;
this.JSFBTN.depress ("btn2", true);
this.reValue("btn2", true);
hX_5.i.cancelAction(evt);
return false;
} else if (!evt.ctrlKey && (keycode >= hX_5.KEY_SPACEBAR && keycode <= hX_5.KEY_DNARROW)) {
hX_5.i.cancelAction(evt);
return false;
}
break;
case hX_5._evKU:
if (keycode >= hX_5.KEY_SPACEBAR && keycode <= hX_5.KEY_DNARROW) {
if (this.spinstate == 1) this.uirelease(true);
hX_5.i.cancelAction(evt);
return false;
}
break;
case hX_5._evKP:
if (keycode >= hX_5.KEY_SPACEBAR && keycode <= hX_5.KEY_DNARROW) {
hX_5.i.cancelAction(evt);
return false;
}
break;
default:
if (action!=hX_5._evMM)
this.uirelease(true);
}
} else if (item==hX_5._lINP) {
if (action==hX_5._evF) {
this.mouseToken=null;
} else if (action==hX_5._evKD) {
this.uirelease();
if (!evt.altKey && !evt.ctrlKey) {
if (keycode == hX_5.KEY_UPARROW) this.reValue("btn1", false);
else if (keycode == hX_5.KEY_DNARROW) this.reValue("btn2", false);
}
}
} else {
this.uirelease(true);
}
return true;
}
HxG_5.prototype.JSFSpinner.prototype.dispatchTimer=function (item, action) {
if (item == "btn1" || item == "btn2") {
if (action == "spin") this.reValue(item, true);
else if (action == "start") hX_5.i.startTimerInterval (this.id, item, "spin", 75);
}
}
