function getObj(n, d) { //pinched from MM_find_obj v4.01
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}
function positionToWindow(div, x, y){
	var o = getObj(div);
	if (window.innerHeight){
		o.style.top = window.pageYOffset + y;
		o.style.left = window.pageXOffset + x;
	}else if(document.documentElement && document.documentElement.scrollTop){
		o.style.top = document.documentElement.scrollTop + y;
		o.style.left = document.documentElement.scrollLeft + x;
	}else if(document.body){
		o.style.top = document.body.scrollTop+y;
		o.style.left = document.body.scrollLeft+x;
	}
}
function doNothing(){
}
// function to show/hide a div
function switchDiv(strDivName,bolVisible){
	objElement = getObj(strDivName);
	if(!bolVisible){
		objElement.style.display = "none";
	} else {
		objElement.style.display = "block";
	}
}
function hideObj(obj){
	obj.style.display = "none";
}
// function to find X position of object relative to left
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
// function to find Y position of object relative to right
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function strltrim() {
	//Match spaces at beginning of text and replace with a null string
	return this.replace(/^\s+/,'');
}
function strrtrim() {
	//Match spaces at end of text and replace with a null string
	return this.replace(/\s+$/,'');
}
function strtrim() {
	//Match spaces at beginning and end of text and replace
	//with null strings
	return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
// empty function to use instead of hash mark for js links
function doNothing(){
}
String.prototype.ltrim = strltrim;
String.prototype.rtrim = strrtrim;
String.prototype.trim = strtrim;


// number methods
function roundNumber(n, d) {
    return padDecimals(Math.round(n*Math.pow(10, d))/Math.pow(10, d), d)
}

function padDecimals(v, d) {
    v = v.toString();
    if (v.indexOf(".") == -1){// check point
        v += d > 0 ? "." : "";
    }
    else{
        d = d - (v.length-(v.indexOf(".")+1));
    }
	while(d>0){
		v += "0";
		d--;
	}
    return v;
}



