JavaLikeCalc.JavaScript
curTm = SYS.time();
if(n == 0 && !time) { time = curTm; bTime = time - 30; }
size_en = Text1_en = Text2_en = prev1_en = next1_en = date_en = dateBeg_en = !n;
szVal = time - bTime;

//Archive size
if(n) {
	if(vCur >= 0)	cPos = aCur - vCur;
	if(cPos < 0)		cPos += aSize;
	Text3_text = Text3_text.parse(0,"\n") + "\n" + (cPos+1) + "(" + aSize + ")";
}
else Text3_text = Text3_text.parse(0,"\n");

//Events process
prevTime = time;
for(off = 0, ev_rez = ""; (evCur=event.parse(0,"\n",off)).length; ) {
	//SYS.messInfo("Trend control","Event: "+evCur);
	if(evCur == "ws_LnAccept:/size") {
		size_value = SYS.time2str(szVal=SYS.str2time(size_value,false), false);
		time += 1;
	}
	else if(evCur == "ws_LnAccept:/dateBeg") { szVal = max(1, date_value-dateBeg_value); time += 1; }
	else if(evCur == "ws_LnAccept:/date") time = min(curTm, max(szVal,date_value));
	else if(evCur == "ws_BtPress:/curtime") {	
		if(n == 0) time = curTm;
		else vCur = aCur;
	}
	else if(evCur == "ws_BtPress:/prev") {
		if(n == 0) time = min(curTm, max(szVal,time-szVal));
		else vCur = -2;
	}
	else if(evCur == "ws_BtPress:/next") {
		if(n == 0) time = min(curTm, max(szVal,time+szVal)); 
		else vCur = -1;
	}
	else if(evCur == "ws_BtPress:/prev1") time = min(curTm, max(5*szVal,time-5*szVal));
	else if(evCur == "ws_BtPress:/next1") time = min(curTm, max(5*szVal,time+5*szVal));
	else ev_rez += (evCur+"\n");
}
event = ev_rez;

//Time control
date_value = time;
if(n == 0 && prevTime != time) { bTime = time - szVal; doc=""; }
size_value = SYS.time2str(szVal, false);
dateBeg_value = date_value - szVal;

//Checking for correct linking with document
if(this.attr("pgOpen") && this.attr("pgOpenSrc").length && (tVl=this.wdgAt(this.attr("pgOpenSrc"),true)) && !tVl.ownerPage().attr("pgOpen"))
	this.wdgAt("/s/pg_control/pg_terminator",true).attrSet("pgOpen", true);