
var isNetscape = false;
var displayOnVal = "block";
var cellDisplay = "block";
if(navigator.org=='netscape'){
	isNetscape = true;
	displayOnVal = 'table-row';
	cellDisplay = 'table-cell';
}





//rounds number to X decimal places, defaults to 0 
function round(number,X) {
	X = (!X ? 0 : X);
	if(X==0)
		return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
	else
		return Xtend(Math.round(number*Math.pow(10,X))/Math.pow(10,X), X);
}

function roundNoEx(number,X){
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}


function Xtend(Q,X) { 
	var P;
    Q = String(Q);
    while ((P=Q.indexOf('.'))<0) 
		Q+='.';
    while (Q.length <= P+X) 
		Q+='0';
    return Q; 
}

function GCD( a,  b)
{
    return b!=0? GCD(b, a % b): a;
}



function  roundToNearestTick(input, tickSize){
	//alert("input: " + input + " tickSize: "+tickSize);
	
	var multiple = round(input/tickSize, 0);
	var output = (multiple * tickSize);

	//alert("output: " + output );

	return (multiple * tickSize);
}



function addEvent(obj, evType, fn, useCapture){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}else if (obj.attachEvent){
		obj.attachEvent("on"+evType, fn);
	} else {
	    alert("Handler could not be attached");
	}
} 

function showWin(url, winname, width, height, scrollbars, toolbars){
	var midx=screen.width/2;
	var midy=screen.height/2;
	
	var winw=width;
	var winh=height;
	
	var winl=midx-(winw/2);
	var wint=midy-(winh/2);
	var scrolltxt = "";
	var tooltxt = "";
	if(scrollbars)
		scrolltxt=",scrollbars=yes";
	if(toolbars)
		tooltxt=",toolbar=yes";
	var winprops =
	"width="+winw+",height="+winh+",left="+winl+",top="+wint+",resizable=yes"+scrolltxt+tooltxt;

	win=open(url,winname,winprops);
	win.focus();

	return false;

}



function setEventFrameHeight(){
	var parHeight = parent.getClientHeight() -160;

	var frameHeight=document.body.scrollHeight+5
	if(isNetscape){
		frameHeight= document.height+5 ;
	}

	if(frameHeight<parHeight)
		frameHeight = parHeight;
		
	parent.getElementById("eventFrame").height = frameHeight;

}

function getOffsetTop (el) {
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
   ot += el.offsetTop;
  return ot;
}


