/*
Function attempts to open a popup window for a given URL. If it fails, it returns true.
It should be called in the OnClick of a <A> hyperlink. The HREF attribute should be set to the same URL.
If the popup fails, it will still navigate to the page.

Example:
<a href="http://www.moneysupermarket.com" onclick="return safePopup('http://www.moneysupermarket.com');">link</a>

If the onclick returns true, the popup failed and the browser will go on to execute the href.
If the onclick returns false, the popup succeeded and the browser will stop executing the hyperlink.
*/
function safePopup(url,target,params){
	
	//remove any custom attached events.
	if(window.event) event.cancelBubble = true
	
	if(!target){
		target="_blank";
	}
	if(!params){
		params = "toolbar=1,scrollbars=1,location=1,status=1,menubar=1,resizable=1,left=1,top=1";
	}
	retval = window.open(url,target,params);
	if(!retval){
		//popup failed, but return true causes href to be navigated to
		return true;
	} else {
		//popup successful, don't navigate to href.
		return false;
	}
}


//calculate size to create popup windows
//open at set width and height, unless this doesn't fit on the screen.

var screenWidth = screen.width;
var screenHeight = screen.height;

var popupWidth = 900;
var popupHeight = 774;

//if either dimension doesn't fit, set to 98% of screen size
if(popupWidth > screenWidth){
	popupWidth = screenWidth * 0.98;
}
if(popupHeight > screenHeight){
	popupHeight = screenHeight * 0.98;
}