/*
copyright by
F.H.U. Slawomir Kaniecki
e-mail: kontakt (at) www-editor (dot) net
/**/

//	number_format($num, 2, '.', '')
function number_format(sum) {
	/* formatowanie do 2 miejsc po przecinku ... */
	sum = Math.round(parseFloat(sum) * 100)
	sum = sum + '';
	if (sum.length == 1) sum = '00' + sum;
	if (sum.length == 2) sum = '0'  + sum;
	sum = sum.replace(/([0-9]+)([0-9]{2})/, "$1.$2");
	/* END formatowanie do 2 miejsc po przecinku ... */
	return sum
}

function oid(id) {
	if (id) return document.getElementById(id);
}

function oname(id) {
	if (id) return document.getElementsByName(id);
}

function trim(txt) {
	for (r=txt.length-1; (txt.charAt(r) == ' ' || txt.charAt(r) == '\t' || txt.charAt(r) == '\n' || txt.charAt(r) == '\r'); r--) {}
	if (r > -1) for (l=0; (txt.charAt(l) == ' ' || txt.charAt(r) == '\t' || txt.charAt(r) == '\n' || txt.charAt(r) == '\r'); l++) {}
	return (r > -1) ? txt.substring(l, r+1) : '';
}

function element_position(el) {
	var ret = new Object();
	ret.left = 0;
	ret.top  = 0;
	var o = el;
	ret.left = o.offsetLeft;
	ret.top  = o.offsetTop;
	//	while (o = o.parentNode) {
	while (o = o.offsetParent) {
		ret.left = ret.left + o.offsetLeft;
		ret.top  = ret.top  + o.offsetTop;
	}
	return ret;
}


