/*
Language: CS Javascript
Name: popup
Description:
	Pops up a window of specified dimensions and disables href where appropriate to avoid
	double window creation. Therefore safe to use hrefs in an a tag in case of no javascript.
	In case of no dimensions specified, it uses a percentage of the screen size.
*/
var widthPercent=0.6;
var heightPercent=0.95;

function popup(url, title, w, h, scrollbars, resizable, topbar) {
	if (scrollbars == null)
		scrollbars = true;
	if (resizable == null)
		resizable = true;
	var bAgent = window.navigator.userAgent; 
	var bAppName = window.navigator.appName;
	if (!w) {
		if (document.body) {
			w=document.body.clientWidth*widthPercent;
			h=document.body.clientHeight*heightPercent;
		}
		else {
			if (window.innerWidth) {
				w=window.innerWidth*widthPercent;
				h=window.innerHeight*heightPercent;
			}
			else {
				w=600;
				h=380;
			}
		}
	}
	topbar=(topbar?"yes":"no");
	var w = window.open(url, title, 'width='+w+',height='+h+',toolbar='+topbar+',menubar='+topbar+',location='+topbar+',scrollbars='+(scrollbars?"yes":"no")+',resizable='+(resizable?"yes":"no"));
	w.focus();
	if ((bAppName.indexOf("Explorer") >= 0) && (bAgent.indexOf("Mozilla/3") >= 0) && (bAgent.indexOf("Mac") >= 0))
		return true; // do follow link
	else return false; // don't follow link
}
