var documentWrite = document.write;
var documentWriteLn = document.writeln;
var embedSrc;

function captureWrites ( )
{
	embedSrc = '';
	document.write = function ( string ) { embedSrc += string; };
	document.writeln = function ( string ) { embedSrc += string + "\n"; };
}

function releaseWrites ( )
{
	document.write = documentWrite;
	document.writeln = documentWriteLn;
	document.write ( embedSrc );
	embedSrc = '';
}

// Used by scaling movies.

function getMovieContainerDimensions ( )
{
	var dimensions = new Object ( );
	
	if ( window.innerWidth )
	{
		dimensions.width = window.innerWidth;
		dimensions.height = window.innerHeight;
	}
	else if ( document.all )
	{
		dimensions.width = document.body.clientWidth;
		dimensions.height = document.body.clientHeight;
	}
	
 	return dimensions;
}

function positioner ( xOffset, yOffset )
{
	this.left = 0;
	this.top = 0;
	this.width = screen.availWidth;
	this.height = screen.availHeight;

	this.features += ",left=" + this.left + ",top=" + this.top +",screenx=" + this.left + ",screeny=" + this.top + ",width=" + this.width + ",height=" + this.height;
}

function popPositioner ( xOffset, yOffset )
{
	this.left = (screen.availWidth - this.width) / 2;
	this.top = (screen.availHeight - this.height) / 2;

	this.features += ",left=" + this.left + ",top=" + this.top +",screenx=" + this.left + ",screeny=" + this.top;
}


function compareScreenToDimensions ( desiredWidth, desiredHeight )
{
	var cmp = 0;
	
	if ( desiredWidth > screen.availWidth || desiredHeight > screen.availHeight )
	{
		cmp = -1;
	}
	
	if ( desiredWidth < screen.availWidth && desiredHeight < screen.availHeight )
	{
		cmp = 1;
	}

	return cmp;
}

// http://www.quirksmode.org/
//
// Use with care as focus ( ) in a tabbed browser will not bring the tab to 
// the forefront.
//

var externalWindow = null;

function getExternalUrl ( url ) 
{
	if ( externalWindow != null && ! externalWindow.closed && externalWindow.location ) 
	{
		externalWindow.close ( );
	}
	
	externalWindow = window.open ( url, 'external' );
	
	if ( ! externalWindow.opener )
	{
		externalWindow.opener = self;
	}
}

