function fId(_sId) {
	return document.getElementById(_sId);
}

function fPosX(_oElement) {
	var nX = _oElement.offsetLeft;
	var oElement = _oElement;
	while(oElement.offsetParent) {
		oElement = oElement.offsetParent;
		nX += oElement.offsetLeft;
	}
	return nX;
}

function fPosY(_oElement) {
	var nY = _oElement.offsetTop;
	var oElement = _oElement;
	while(oElement.offsetParent) {
		oElement = oElement.offsetParent;
		nY += oElement.offsetTop;
	}
	return nY;
}

function fCheckDate(_nDay, _nMonth, _nYear) {
	_nDay = Math.round(_nDay);
	_nMonth = Math.round(_nMonth);
	_nYear = Math.round(_nYear);
	var aLengths = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	if(_nDay <= aLengths[_nMonth] || (_nMonth == 1 && _nDay == 29 && _nYear % 4 == 0)) {
		return true;
	} else {
		return false;
	}
}

function fReadyEvent(_nId) {
	fId('event_' + _nId).style.display = 'none';
	fAjaxRequest('sysAjax.php?action=eventDel&nId=' + _nId)
	if(fGetVisibleRows(fId("eventTable")) == 1) {
		fId("eventTableDiv").style.display = "none";
	}
}

function fGetVisibleRows(_oTable) {
	var nCount = 0;
	for(var i = 0; i < _oTable.rows.length; i++) {
		if(_oTable.rows[i].style.display != "none") {
			nCount++;
		}
	}
	return nCount;
}

function fShowHideEventtable() {
	if(fId("eventTableBody").style.display == "none") {
		fId("eventTableBody").style.display = "";
		fId("eventTableIcon").src = "images/icons/" + sIconpack + "/circle_up_16.png";
		fAjaxRequest("sysAjax.php?action=setUseroption&sName=sysShowEventbox&sValue=yes");
	} else {
		fId("eventTableBody").style.display = "none";
		fId("eventTableIcon").src = "images/icons/" + sIconpack + "/circle_down_16.png";
		fAjaxRequest("sysAjax.php?action=setUseroption&sName=sysShowEventbox&sValue=no");
	}
}