// ###########################################################
// function getInsideWindowWidth()
// This function returns the indise width of the browser
// window in pixels.

function getInsideWindowWidth() {
        if (window.innerWidth) return window.innerWidth
		else return document.body.clientWidth }

// end getInsideWindowWidth()

// ###########################################################
// function getInsideWindowHeight()
// This function returns the indise height of the browser
// window in pixels.

function getInsideWindowHeight() {
        if (window.innerHeight) return window.innerHeight
		else return document.body.clientHeight }

// end getInsideWindowHeight()

// ###########################################################
// function findWidth(objectID)
// This function receives a DHTML layer object ID, and returns
// the element's width value in pixels.

function findWidth(objectID) {

	var dom = findDOM(objectID,0);
	if (dom.offsetWidth) 
		return dom.offsetWidth;
	if (dom.clip.width)
		return dom.clip.width;
	return (null);
	
}
// end function findWidth(objectID)

// ###########################################################
// function findHeight(objectID)
// This function receives a DHTML layer object ID, and returns
// the element's height value in pixels.

function findHeight(objectID) {

	var dom = findDOM(objectID,0);
	if (dom.offsetHeight) 
		return dom.offsetHeight;
	if (dom.clip.height)
		return dom.clip.height;
	return (null);
	
}
// end function findWidth(objectID)

// ###########################################################
// function shiftTo(obj,x,y)
// This function receives a DHTML layer object ID, and an x/y 
// coordinate. The object is moved to the specified x/y
// location within the browser window.

function shiftTo(objID, x, y) {
	objRef = findDOM(objID,1);
	objRef.left = x;
	objRef.top = y;
}
// end function shiftTo(obj,x,y)

// ###########################################################
// function hideObject(objID)
// This function receives an object ID, creates the
// appropriate object reference based on browser type, and sets
// the object's visibility attribute to "hidden".

function hideObject(objID) {

	objRef = findDOM(objID,1);
	objRef.visibility = 'hidden';
}
// end function hideObject(objID)

// ###########################################################
// function showObject(objID)
// This function receives an object ID, creates the
// appropriate object reference based on browser type, and sets
// the object's visibility attribute to "visible".

function showObject(objID) {

	objRef = findDOM(objID,1);
	objRef.visibility = 'visible';
}
// end function showObject(objID)

// ###########################################################
// function findLeft(objectID)
// This function receives an object ID, creates the
// appropriate object reference based on browser type, and
// returns the x value of object's left side...
function findLeft(objectID) {
	var domStyle = findDOM(objectID,1);
	var dom = findDOM(objectID,0);
	if (domStyle.left) return domStyle.left;
	if (domStyle.pixelLeft) return domStyle.pixelLeft;
	if (dom.offsetLeft) return dom.offsetLeft;
	return (null);
} // end function findLeft(objectID)

// ###########################################################
// function findRight(objectID)
// This function receives an object ID, creates the
// appropriate object reference based on browser type, and
// returns the x value of object's right side...
function findRight(objectID) {
	var domStyle = findDOM(objectID,1);
	var dom = findDOM(objectID,0);
	if (dom.left) return (domStyle.left + domStyle.clip.width);
	if (domStyle.pixelLeft) return (domStyle.pixelLeft + dom.offsetWidth);
	if (dom.offsetLeft) return (dom.offsetLeft + dom.offsetWidth);
	return (null);
} 

// ###########################################################
// function findTop(objectID)
// This function receives an object ID, creates the
// appropriate object reference based on browser type, and
// returns the y value of the object's top border...
function findTop(objectID) {
	var domStyle = findDOM(objectID,1);
	var dom = findDOM(objectID,0);
	if (domStyle.top) return domStyle.top;
	if (domStyle.pixelTop) return domStyle.pixelTop;
	if (dom.offsetTop) return dom.offsetTop;
	return (null);
} // end function findTop(objectID);

// ###########################################################
// function findBottom(objectID)
// This function receives an object ID, creates the
// appropriate object reference based on browser type, and
// returns the y value of the object's bottom border...
function findBottom(objectID) {
	var domStyle = findDOM(objectID,1);
	var dom = findDOM(objectID,0);
	if (dom.top) return (domStyle.top + domStyle.clip.height);
	if (domStyle.pixelTop) return (domStyle.pixelTop + dom.offsetHeight);
	if (dom.offsetTop) return (dom.offsetTop + dom.offsetHeight);
	return (null);
} // end function findBottom(objectID);

// ###########################################################
// function popCenter(obj)
// This function receives a DHTML object and pops it up in the
// center of the window the object resides on.

function popCenter(obj) {

	// find object's dimensions...
	objWidth = findWidth(obj);
	objHeight = findHeight(obj);
	
	// determine centerpoint for object placement...
	x = Math.round((getInsideWindowWidth()-objWidth)/2);
    y = Math.round((getInsideWindowHeight()-objHeight)/2);
	
	// move object to x/y coord and display it...
    shiftTo(obj,x,y);
    showObject(obj);
	
} // end function popCenter(obj)


popWin = null;

function popWindow(src, nm, w, h, scrolling, resizing) {
	if (popWin!=null) {
    	if (!popWin.closed) {
        	loc = popWin.location + ' ';
            if (loc.indexOf(src)==-1) popWin.close();
            else {
            	popWin.focus();
                return;
            }
        }
	}
    x = Math.round((screen.availWidth-w)/2);
    y = Math.round((screen.availHeight-h)/2);
    isScroll = (scrolling) ? 'yes' : 'no';
    if (scrolling=='yes') w+=16;
    resz = (resizing) ? 'yes' : 'no';
    popWin = window.open(src,nm,'toolbar=no,location=no,directories=no,status=no,scrollbars='+isScroll+',resizable='+resz+',copyhistory=no,width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y);
} // end function popWindow()

function init() {
	hideObject('updateBox');
	getBoundaries();
	lastCommandNum = -1;
	if (lastCommand != "none" && lastCommand != "reset") {
		for (i=0;i<commandsArray.length;i++) {
			if (lastCommand == commandsArray[i]) lastCommandNum = i;
		} // for loop
	
	if (lastCommandNum!=-1) {
	btnRef = lastCommandNum + 1;
	btnStr = 'document.images.btn0'+btnRef;
	setActiveButton(btnStr,lastCommandNum);
	}
	
	} // if (lastCommand != "none")
} // end function init()


