var x = self.screenLeft || self.screenX;
var y = self.screenTop || self.screenY;

function onLoad()
{
	window.moveTo(0, 0);
	window.resizeTo(screen.availWidth, screen.availHeight);
	var inner = getInnerDimensions();
	var ox = 800 + (screen.availWidth - inner.width);
	var oy = 600 + (screen.availHeight - inner.height);
	ox = (ox > screen.availWidth) ? screen.availWidth : ox;
	oy = (oy > screen.availHeight) ? screen.availHeight : oy;
	window.resizeTo(ox, oy);
	if (!centerWin)
		window.moveTo(x, y);
	else
		window.moveTo((screen.availWidth - ox) / 2, (screen.availHeight - oy) / 2);
}

function getInnerDimensions()
{
	var w,h;
	if (self.innerHeight) // all except Explorer
	{
		w = self.innerWidth;
		h = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	
	//alert('width: ' + w + ', height: ' + h + ', x: ' + ox + ', y: ' + oy);
	
	return {width: w, height: h};
}

function closeSite()
{
	window.opener.focus();
	window.close();
}

function popReader(d, issue, m)
{
	if (!issue)
		issue = 'SI';
	if (!m)
		m = 'reader_vault';
	
	//alert('DATE: ' + d + '\rISSUE: ' + issue + '\rMODE: ' + m);
	
	window.open('reader.html?magID=' + issue + '&issueDate=' + d + '&mode=' + m, 'Reader', 'width=800,height=600,directories=no,location=no,status=no,scrollbars=no,resizable=yes,menubar=yes,toolbar=no');
}