﻿
//==== fnOpenWindow function ========================
// purpose:
//	this function opens a new window
//
// parameters:
//	{
//		strLocation //string - the location of the new window
//	}
//
// returns:	nothing
//
//	author: bryan costanich b@wowzer.net
function fnOpenWindow(strLocation, strWindowName, lngWidth, lngHeight)
{
	//if (windowWidth == null) windowWidth = screen.width/1.5; 
	//if (windowHeight == null)windowHeight = screen.height/2; 
	
	//check to see if the width is empty
	if (lngWidth == null)
		{ lngWidth = '300'; }
	
	//if the height is empty
	if (lngHeight == null) { lngHeight = '100'; }

	//center the window
	topOf = ((screen.height - lngHeight)/2)-70;
	leftOf = ((screen.width - lngWidth)/2);
	
	//if the strWindowName is empty, use default
	if (strWindowName == null) { strWindowName = 'new'; }
	
	//open the window
	window.open(strLocation, strWindowName, 'left=' + leftOf + ', top=' + topOf + ', directories=no,location=no,resizable=yes,scrollbars=yes,status=no,toolbar=no, width=' + lngWidth + ', height=' + lngHeight);
}
//==========================================

//---- fnGetAbsoluteTop function -----------------------------
// Gets real Top value with respect to client area by starting
// at the element and adding up all the offsets of each parent
// element until it gets to the body
function fnGetAbsoluteTop(elem)
{
	var topPosition = 0;
	while (elem)
	{
		if (elem.tagName == 'BODY') { break;	}
		topPosition += elem.offsetTop;
		elem = elem.offsetParent;
	}
	return topPosition;
}
//----------------------------------------------------------------

// Get real Left value with respect to client area
function fnGetAbsoluteLeft(elem)
{
	var leftPosition = 0;
			
	while (elem)
	{
		if (elem.tagName == 'BODY') { break; }
		leftPosition += elem.offsetLeft;
		elem = elem.offsetParent;
	}
	return leftPosition;
}

//---- fnGetAbsoluteBottom function -----------------------
function fnGetAbsoluteBottom(elem)
{
	var bottomPosition = 0;
	var elemHeight = elem.offsetHeight
	while (elem)
	{
		if (elem.tagName == 'BODY') { break; }
		bottomPosition += elem.offsetTop;
		elem = elem.offsetParent;
	}
	bottomPosition = eval(bottomPosition + elemHeight);
	return bottomPosition;
}
//---------------------------------------------------------------	

//---- fnGetAbsoluteRight function -----------------------
function fnGetAbsoluteRight(elem)
{
	var rightPosition = 0;
	var elemWidth = elem.offsetWidth
	while (elem)
	{
		if (elem.tagName == 'BODY') { break; }
		rightPosition += elem.offsetLeft;
		elem = elem.offsetParent;
	}
	rightPosition = eval(rightPosition + elemWidth);
	return rightPosition;
}
//---------------------------------------------------------------	
