﻿// POPUP STANDARD open a promo window - opens at top left of screen
// to use: <a href="http://www.suncorp.com.au" target="_blank" onclick="open_window(this.href);return false;">Suncorp</a>
function open_window(url) {
	w = window.open(url, "_blank", "width=640,height=450,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,screenX=0,screenY=0,left=0,top=0");
	w.opener = this;
	w.focus();
}
// EXTERNAL STANDARD open an external window at 640 x 450 - opens at top left of screen
// to use: <a href="http://www.suncorp.com.au" target="_blank" onclick="open_external(this.href);return false;">Suncorp</a>
function open_external(url) {
	w = window.open(url, "_blank", "width=640,height=450,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,screenX=0,screenY=0,left=0,top=0");
	w.opener = this;
	w.focus();
}
// APPLICATION STANDARD open an application in a full screen size window
function open_application(url) {
	var sw=screen.availWidth - 12;
	var sh=screen.availHeight - 53;
	w = window.open(url, "_blank", "width=" + sw + ",height=" + sh + ",toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,screenX=0,screenY=0,left=0,top=0");
	w.opener = this;
	w.focus();
}
// to load a different page in the parent window
function load_opener(url) {
	if (window.parent.name && window.opener) {
		window.parent.opener.location = url;
		window.parent.opener.focus();
	} else {
		document.location = url;
	}
}
// to close any window neatly
// to use: <a href="javascript:close_window();">Suncorp</a>
function close_window() {
	if (window.opener) {
		window.opener.focus();
	}
	window.close();
}
// check font size & fix if too small
function emsTweak() {
	if ((document.createElement) && (document.createTextNode)) {
		document.writeln('<div id="emsTest" style="position:absolute; visibility:hidden; font-family:arial,helvetica,sans-serif">&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br /></div>');
		var scaling=100;
		if ((navigator.platform=="Win32") && (navigator.appName=="Microsoft Internet Explorer")) scaling=105;
		var h=999;
		if (document.getElementById('emsTest').clientHeight) h=parseInt(document.getElementById('emsTest').clientHeight);
		else if (document.getElementById('emsTest').offsetHeight) h=parseInt(document.getElementById('emsTest').offsetHeight);
		if (h<85) document.body.style.fontSize=Math.round(scaling*85/h)+"%";
	}
}
