JavaLikeCalc.JavaScript
if(f_start) {
	//Init the avialable parameters
	colors = new Array("#ae77c3", "orange", "blue", "#199696", "#3264C8", "tomato", "magenta", "#B6B600", "#69695C", "darkcyan");
	params = new Array();
	params.repHour = repHour;
	for(iP = 1; iP <= 10; iP++) {
		pO = new Object();
		pO.name = this.doc.attr("p"+iP+"name");
		pO.var = this.doc.attr("p"+iP+"var");
		pO.ed = this.doc.attr("p"+iP+"ed");
		if(pO.ed.isEVal())	pO.ed = "";
		pO.prec = this.doc.attr("p"+iP+"prec");
		pO.min = this.doc.attr("p"+iP+"min");
		pO.max = this.doc.attr("p"+iP+"max");
		pO.isCntr = this.doc.attr("p"+iP+"cntr");
		pO.color = colors[iP-1];
		if(pO.prec.isEVal())	pO.prec = 0;
		if(!pO.name.isEVal() && pO.name.length && !pO.var.isEVal() && (aO=SYS.nodeAt(pO.var).arch()))
			params.push(pO);
	}
	this.doc.attrSet("params", params);

	if(!n) { time = SYS.time(); lastTime = 0; }
	return;
}

curMin = curHour = curDay = curMonth = curYear = 0;

for(off = 0, ev_rez = ""; (ev_cur=event.parse(0,"\n",off)).length; )
	if(ev_cur == "ws_FocusIn:/doc")	ev_rez += "ws_FocusIn";
	else ev_rez += ev_cur;
event = ev_rez;

//Build the document dynamically
if(!n) {
	if(time == lastTime)	return;

	if(abs(time-lastTime) == 30*24*60*60)	time -= 10*24*60*60;

	time = min(time, SYS.time());

	SYS.localtime(time, 0, curMin, curHour, curDay, curMonth, curYear);
	if(curDay == 1 && (curHour < repHour || (curHour == repHour && !curMin))) {
		doc_bTime = SYS.mktime(0, 0, repHour, 1, curMonth ? curMonth-1 : 11, curMonth?curYear:curYear-1);
		doc_time = SYS.mktime(0, 0, repHour, 1, curMonth, curYear);
	}
	else	{
		doc_bTime = SYS.mktime(0, 0, repHour, 1, curMonth, curYear);
		doc_time = SYS.mktime(0, 0, repHour, 1, curMonth+1, curYear);
	}

	time = lastTime = doc_time;
	bTime = time - 30*24*60*60; // doc_bTime;
	doc_doc = "";

	return;
}

//Document generation one per hour 
curMin = curHour = curDay = curMonth = curYear = 0;
SYS.localtime(SYS.time(), 0, curMin, curHour, curDay, curMonth, curYear);
if(!doc_bTime) {
	if(curDay == 1 && curHour < repHour)
		doc_bTime = SYS.strptime(""+((curMonth==0)?(curYear-1):curYear)+"-"+(curMonth?curMonth:12)+"-1 "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
	else doc_bTime = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-1 "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
}
if(lastHour < 0 || lastDay < 0 || lastMin < 0 || lastMonth < 0)
	SYS.localtime(doc_bTime, 0, lastMin, lastHour, lastDay, lastMonth);

//Archive last not closed document
if(closeDoc == true) { if(!doc_process)	{ this.doc.attrSet("aCur", -1);/*doc_aCur = -1;*/ closeDoc = false; } }
else if(doc_time && doc_time < doc_bTime)	{
	closeDoc = true;
	SYS.localtime(doc_time, 0, 0, 0, curDay, curMonth, curYear);
	if(curDay == 1 && curHour < repHour) {
		doc_time = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-1 "+repHour+":0:0", "%Y-%m-%d %H:%M:%S");
		doc_bTime = SYS.strptime(""+((curMonth==0)?(curYear-1):curYear)+"-"+(curMonth?curMonth:12)+"-1 "+repHour+":0:0", "%Y-%m-%d %H:%M:%S");
	}
	else {
		doc_time = SYS.strptime(""+((curMonth==11)?(curYear+1):curYear)+"-"+((curMonth==11)?1:curMonth+2)+"-1 "+repHour+":0:0", "%Y-%m-%d %H:%M:%S");
		doc_bTime = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-1 "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
	}
}
// Archive the document
else if(curMonth != lastMonth && curDay >= 1 && curHour >= repHour && curMin >= 3)	{
	closeDoc = true;
	doc_time = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-1 "+repHour+":0:0", "%Y-%m-%d %H:%M:%S");
	lastMonth = curMonth;
}
// Periodic not full update
else if(curMin != lastMin && !(curMin%5))	{
	lastMin = curMin;
	doc_time = SYS.time() - 5*60;
	SYS.localtime(doc_time, 0, 0, curHour, curDay, curMonth, curYear);
	if(curDay == 1 && curHour < repHour)
		doc_bTime = SYS.strptime(""+((curMonth==0)?(curYear-1):curYear)+"-"+(curMonth?curMonth:12)+"-1 "+repHour+":0:0", "%Y-%m-%d %H:%M:%S");
	else doc_bTime = SYS.strptime(""+curYear+"-"+(curMonth+1)+"-1 "+repHour+":0:0","%Y-%m-%d %H:%M:%S");
}