function format_number(pnumber,decimals) {
	if (isNaN(pnumber)) { return 0};
	if (pnumber=='') { return 0};

	var IsNegative=(parseInt(pnumber)<0);
	if(IsNegative)pnumber=-pnumber;

	var snum = new String(pnumber);
	var sec = snum.split('.');
	var whole = parseInt(sec[0]);
	var result = '';
	if(sec.length > 1){
		var dec = new String(sec[1]);
		dec = parseInt(dec)/Math.pow(10,parseInt(dec.length-decimals-1));
	Math.round(dec);
	dec = parseInt(dec)/10;

	if(IsNegative)
	{
	var x = 0-dec;
		x = Math.round(x);
	dec = - x;
	}
	else
	{
		dec = Math.round(dec);
	}

	/*
	* If the number was rounded up from 9 to 10, and it was for 1 'decimal'
	* then we need to add 1 to the 'whole' and set the dec to 0.
	*/
	if(dec==Math.pow(10, parseInt(decimals)))
	{
	whole+=1;
	dec="0";
	}

		dec = String(whole) + "." + String(dec);
		var dot = dec.indexOf('.');
		if(dot == -1){
		dec += '.';
		dot = dec.indexOf('.');
		}
	var l=parseInt(dot)+parseInt(decimals);
		while(dec.length <= l) { dec += '0'; }
		result = dec;
	} else{
		var dot;
		var dec = new String(whole);
		dec += '.';
		dot = dec.indexOf('.');
	var l=parseInt(dot)+parseInt(decimals);
		while(dec.length <= l) { dec += '0'; }
		result = dec;
	}
	if(IsNegative)result="-"+result;
	return result;
}

function popWindow(mypage,w,h,t,l){
	if(!l) l = (screen.width) ? (screen.width - w) /2 : 100;
	if(!t) t = (screen.height) ? (screen.height - h) /2 : 100;
	settings='width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	popWin = window.open(mypage,'popWin',settings);
}

//configuration
var infDivID = 'popInfoDiv'; //ID of the <DIV> tag
var infDivOverlap = 3; //pixels ovelap on link
var infDivOutTime = 5; //amount of seconds before hidding

//needed
var tmr;
var lastPopInfo;

//pop up an info DIV.
//call with empty txt value to hide the object.
function popInfo(obj,txt){
	if(obj){
		//get popup div element
		infDiv = document.getElementById(infDivID);
		if(infDiv){
			//kill timer
			clearTimeout(tmr);
			//check what to do... over or out...
			if(txt){
				//kill last pop div, when one is there....
				if(lastPopInfo)
					infDiv.style.visibility = "hidden";
				//get position
				t = obj.offsetTop;
				l = obj.offsetLeft;
				//patch position when we are in an other element...
				if(obj.offsetParent.offsetTop){
					obj2 = obj;
					while(obj2.offsetParent){
						t += obj2.offsetParent.offsetTop;
						l += obj2.offsetParent.offsetLeft;
						obj2 = obj2.offsetParent;
					}
				}
				//puse the popup to the link....
				infDiv.style.top = t + obj.offsetHeight - infDivOverlap;
				infDiv.style.left = l + obj.offsetHeight - infDivOverlap;
				infDiv.innerHTML = txt; //set text...
				infDiv.style.visibility = "visible"; //make it visible
				lastPopInfo = infDiv; //remember current div for next over or out...
			}else{
				//it's an out... kill it on a timer...
				tmr = setTimeout('infDiv.style.visibility = "hidden"', (infDivOutTime * 100));
			}
		}
	}
}


