/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: JTricks.com :: http://www.jtricks.com/
Further adapted by DAR. */

var timer;

function move_box( box, anchorID, leftOffset, topOffset )
	// Default values for leftOffset and topOffset are correct ones for a centrally-placed popup.
{
	if ( ! leftOffset )
		leftOffset = 227;
	if ( ! topOffset )
		topOffset = 46;
	var obj = document.getElementById( anchorID );
	var cleft = 0;
	var ctop = 0;
	while (obj.offsetParent) {
		cleft += obj.offsetLeft;
		ctop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	cleft += leftOffset;
	ctop += topOffset;
	box.style.left = cleft + 'px';
	if (document.body.currentStyle &&
		document.body.currentStyle['marginTop']) {
		ctop += parseInt(
		document.body.currentStyle['marginTop']);
	}
	box.style.top = ctop + 'px';
}

function show_box( contentID, closeLinkID, anchorID, leftOffset, topOffset, nofade )
	// Deals with display and placement of popup, associating function with close button, and dimming
	// of rest of page. Note that the popup window html exists already - is only invisible.
{
	var boxdiv = document.getElementById( contentID );
	boxdiv.style.display = 'block';
	boxdiv.style.position = 'fixed';
	if ( ! anchorID )
		anchorID = "bodywrap";
	move_box( boxdiv, anchorID, leftOffset, topOffset );

	// Add close button on bottom-right:
	var closelink = document.getElementById( closeLinkID );
	closelink.onclick = function() {
		document.getElementById( contentID ).style.display = "none";
		document.getElementById( anchorID ).style.opacity = "1";
		document.getElementById( anchorID ).style.filter = "";
	};
	if ( ! nofade ) {
		document.getElementById( anchorID ).style.opacity = "0.5";
		document.getElementById( anchorID ).style.filter = "alpha(opacity=50)";
	}
	
	/*if ( duration > 0 ) {
		clearTimeout( timer );
		timer = setTimeout( function autoClose() {
			document.getElementById( contentID ).style.display = "none";
			document.getElementById( "bodywrap" ).style.opacity = "1";
			document.getElementById( "bodywrap" ).style.filter = "";
						}, (duration * 1000) );
	}*/

	return false;
}

