
/* Set Default values for document and sense if the browser will work */
var _SELF = -3141; // constant
var STAGE = 0;
var TOC = 150;
var TERTIARY = 1000;

var BGNAME = 'images/bg.gif';//>>
	setWidth(720);
	setHeight(520);
	setTop(50);

var DHTML = (document.getElementById || document.all || document.layers);

var dhtmlIsMac = (navigator.appVersion.indexOf("Mac") != -1);


var FIX = 0;//>>
	if (document.layers) FIX = -8;

if (dhtmlIsMac && document.layers) FIX +=0;
if (document.all)	FIX += 7;

if (document.getElementById) FIX -= 7;
	
// Define proper values for hide and show
if (document.layers &&  !document.getElementById)
{
	var hide = "hide";
	var show = "visible";
} else {
	var hide = "hidden";
	var show = "visible";
}


/*****************************************************************************
 * setBG(name)
 * 	name = image name of the page background (ex. 'images/bg2.gif')
 *
 *  Sets the background to the document if standard background image is used
 */
function setBG(name)
{
	BGNAME = name;
}




/*****************************************************************************
 * setWidth(value)
 * 	value = stage's width in the document assuming floating
 * 	
 *	sets and configures the stage widht on floating dhtml usage
 */
function setWidth(value)
{
	STAGEWIDTH = value;
	STAGEWIDTH /= 2;
}

/*****************************************************************************
 * setHeight(value)
 * 	value = stage's height in the document assuming floating
 *
 * 	Sets and configures the stage height on floating dhtml usage
 */	
function setHeight(value)
{
	STAGEHEIGHT = value;
	STAGEHEIGHT /=2;
}


/*****************************************************************************
 * setTop(value)
 *	value = amount of pixels on top of the screen separating the stage
 *		from the top border of the page
 *
 *	Defines the space to the top of the page from the stage
 */
function setTop(value)
{
	TOPOFFSET = value;
}


/*****************************************************************************
 * setVis(name, value)
 *	name = name of the div in the document to change the value for
 *	value = 1 - set to visible, 0 - set to invisible
 *
 *	Sets the visibility of an object based on what browser you are in (given
 *		that IE and NS have different functions
 */
function setVis(name, value)
{
	obj = getObj(name);
	switch (value)
	{
		case 0: 
			obj.visibility = hide;
			break;
		case 1:
			obj.zindex = 100;
			obj.visibility = show;
			break;
		default:
			obj.visibility = hide;
			break;
	}

}


/*****************************************************************************
 * getObj(id)
 *	id = id of the object to grab
 *
 *	Returns to the user the object that has the given ID.  This is cross browser
 *		enabled to return an object if the browser is IE4+, NS4+, and NS6.
 */
function getObj(id)
{
	if (document.getElementById)
	{
		return document.getElementById(id).style;
	}
	else if (document.all)
	{
		return document.all[id].style;
	}
	else if (document.layers)
	{
		return document.layers[id];
	}
}

/*****************************************************************************
 * setPageSize(name,value)
 * 	name = image name of the page background (ex. 'images/bg2.gif')
 *
 *  Sets the background to the document if standard background image is used
 */
//function setPageSize(avalue)
//{
		
//	temp = getObj(aname);
//	temp.height = avalue;
//}

/*****************************************************************************
 * getx(name)
 *	name = name of the stylesheet to return the x (top left) position of name
 * 
 *	Returns (cross browser enabled) the value of the top left pixel's x position
 */
function getx(name)
{
	if (!DHTML) return;
	var obj = getObj(name);
	return parseInt(obj.left);
}

/*****************************************************************************
 * gety(name)
 *	name = name of the stylesheet to return the y (top left) position of name
 * 
 *	Returns (cross browser enabled) the value of the top left pixel's y position
 */
function gety(name)
{
	if (!DHTML) return;
	var obj = getObj(name);
	return parseInt(obj.top);
}

/*****************************************************************************
 * getPagex(name)
 *	name = name of the stylesheet to return the x (top left) position of
 * 
 *	Returns (cross browser enabled) the value of the top left pixel's x position
 *		relative to the defined stage area.
 */
function getPagex(name)
{
	return getx(name) - (getWidth()/2 - STAGEWIDTH + FIX);
}


/*****************************************************************************
 * getPagey(name)
 *	name = name of the stylesheet to return the y (top left) position of
 * 
 *	Returns (cross browser enabled) the value of the top left pixel's y position
 *		relative to the defined stage area.
 */
function getPagey(name)
{
	return gety(name) - TOPOFFSET;
}


/*****************************************************************************
 * setx(name, x)
 *	name = 	name of the stylesheet to set the x (top left) position
 *	x	=	value of the new absolute position
 * 
 *	sets the x value of the top left corner absolutely of [name]
 */
function setx(name, x)
{
	if (!DHTML) return;
	var obj = getObj(name);
	obj.left = x;
}


/*****************************************************************************
 * sety(name, y)
 *	name = 	name of the stylesheet to set the y (top left) position
 *	y	=	value of the new absolute position
 * 
 *	sets the y value of the top left corner absolutely of [name]
 */
function sety(name, y)
{
	if (!DHTML) return;
	var obj = getObj(name);
	obj.top = y;
}


/*****************************************************************************
 * move(name, x, y)
 *	name = 	name of the stylesheet to move relatively
 *	x	=	the x value to move
 *	y	= 	the y value to move
 * 
 *	Moves target stylesheet dX and dY no matter where it is
 */
function move(name, x, y)
{
	if (!DHTML) return;
	var obj = getObj(name);
	setx(name, x + getx(name));
	sety(name, y + gety(name));
}


/*****************************************************************************
 * setPagex(name, x)
 *	name = 	name of the stylesheet to set the x (top left) position
 *	x	=	value of the new relative position
 * 
 *	sets the x value of the top left corner relative to the stage of [name]
 */
function setPagex(name, x)
{
	setx(name, x + getWidth() / 2 - STAGEWIDTH + FIX);
}


/*****************************************************************************
 * setPagex(name, y)
 *	name = 	name of the stylesheet to set the y (top left) position
 *	y	=	value of the new relative position
 * 
 *	sets the y value of the top left corner relative to the stage of [name]
 */
function setPagey(name, y)
{
	sety(name, y + TOPOFFSET);
}

/*****************************************************************************
 * movePage(name, x, y)
 *	name = 	name of the stylesheet to move
 *	x	=	the x value to move
 *	y	=	the y value to move
 * 
 *	Moves target stylesheet dX and dY no matter where it is (wrapper for move)
 */
function movePage(name, x, y)
{
	move(name, x, y );
}	


/*****************************************************************************
 * getWidth();
 *
 * 	returns the width of the page that you are viewing (cross browser).
 */
function getWidth()
{
	if (document.all)
	   return document.body.clientWidth;
	else 
	   return window.innerWidth;
}


/*****************************************************************************
 * getHeight();
 *
 * 	returns the height of the page that you are viewing (cross browser).
 */
function getHeight()
{
	if (document.all)
		return document.body.clientHeight;
	else
		return window.innerHeight;

}

/*****************************************************************************
 * setPage(name, left, top)
 *	name = 	name of stylesheet to set
 *	left = 	x position to set to 
 *	top  =	y position to set to
 *
 * 	Sets the [name] stylesheet to the left, top position relative to the stage
 */
function setPage(name, left, top)
{

	thetop = TOPOFFSET + top;
	theleft = getWidth() / 2 - STAGEWIDTH + FIX + left;
	target = getObj(name);

	setx(name, theleft);
	sety(name, thetop);
}


/*****************************************************************************
 * Load(name, left, top, isVis)
 *	name = 	name of stylesheet to set
 *	left = 	x position to set to 
 *	top  =	y position to set to
 *	isVis =	0 is invisible, 1 is visible
 *
 * 	Sets the [name] stylesheet to the left, top position relative to the stage then 
 *		sets the proper visibility for the object.
 */
function load(name, left, top, isVis)
{
	setPage(name, left, top);
	
	setVis(name, isVis);
}
