// Opens a Window and then Maximizes it to screen resolution
// This over-rides further <A HREF="ptxUrl" onClick="openWindowMax('ptxUrl')>

function openWindowMax(ptxUrl) {
	twin = window.open(ptxUrl, "MaxPage", "width=600, height=400, toolbar=0, scrollbars=1, status=1, resizable=1");
	twin.focus();
	// self.moveTo(0,0);
	//self.resizeTo(screen.availWidth, screen.availHeight);
	var offset = (navigator.userAgent.indexOf("Mac")      != -1 ||
				  navigator.userAgent.indexOf("Gecko")    != -1 ||
				  navigator.userAgent.indexOf("Netscape") != -1    ) ? 0 : 4;
				  
	twin.moveTo(-offset, -offset);
	twin.resizeTo(screen.availWidth + (2 * offset), screen.availHeight + (2 * offset));
	return false;
}

// Center a window and open it up to the width and height specified in this function
function OpenWindowCentred(ptxUrl) {
	var width  = 500;
	var height = 500;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top  = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "resizeable=1,scrollbars=1,menubar=0,toolbar=0";
	windowFeatures += ",height=" + height + ",width=" + width;
	windowFeatures += ",top=" + top;
	windowFeatures += ",left=" + left;
	windowFeatures += ",screenX=" + left;
	windowFeatures += ",screenY=" + top;
	var newWind = window.open(ptxUrl, "newWindow", windowFeatures);
	
	return false;	
}

// Same as above except the spelling is different for Centered
function OpenWindowCentered(ptxUrl) {
	var width  = 500;
	var height = 500;
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top  = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "resizeable=1,scrollbars=1,menubar=0,toolbar=0";
	windowFeatures += ",height=" + height + ",width=" + width;
	windowFeatures += ",top=" + top;
	windowFeatures += ",left=" + left;
	windowFeatures += ",screenX=" + left;
	windowFeatures += ",screenY=" + top;
	var newWind = window.open(ptxUrl, "newWindow", windowFeatures);
	
	return false;	
}

// Open a window centered on the screen taking into account the width, and height attributes.
// Also testing at 800x600 with pinWidth, pinHeight large enought reveals it goes over the edges of the screen!
// vinBorder re-set to 0
function OpenWinCentered(ptxUrl, pinWidth, pinHeight) {
	var vinBorder = 10;
	var width  = pinWidth;
	var height = pinHeight;
	if (width > screen.availWidth) {
		width=screen.availWidth - vinBorder;
	}
	if (height > screen.availHeight) {
		height = screen.availHeight - vinBorder;
	}
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top  = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "resizeable=1,scrollbars=1,menubar=0,toolbar=0";
	windowFeatures += ",height=" + height + ",width=" + width;
	windowFeatures += ",top=" + top;
	windowFeatures += ",left=" + left;
	windowFeatures += ",screenX=" + left;
	windowFeatures += ",screenY=" + top;
	var newWind = window.open(ptxUrl, "newPicWin", windowFeatures);
	
	return false;	
}

// Open  Window Pic Centered, with a 10 size border
// Not tested
// Not completed: Needs pinBorder to be added to the scheme
// Also testing at 800x600 might reveal it goes over the edges of the screen!
function OpenPicWinCentered(ptxUrl, pinWidth, pinHeight, pinBorder) {
	var vinBorder = 10;
	var width  = pinWidth  + vinBorder;
	var height = pinHeight + vinBorder;
	if (width > screen.availWidth) {
		width=screen.availWidth - vinBorder;
	}
	if (height > screen.availHeight) {
		height = screen.availHeight - vinBorder;
	}
	var left = parseInt((screen.availWidth/2) - (width/2));
	var top  = parseInt((screen.availHeight/2) - (height/2));
	var windowFeatures = "resizeable=1,scrollbars=1,menubar=0,toolbar=0";
	windowFeatures += ",height=" + height + ",width=" + width;
	windowFeatures += ",top=" + top;
	windowFeatures += ",left=" + left;
	windowFeatures += ",screenX=" + left;
	windowFeatures += ",screenY=" + top;
	var newWind = window.open(ptxUrl, "newPicWin", windowFeatures);
	
	return false;	
}