window.onerror = handleError;

function handleError(message , file, line)
{
	 alert("Error: " + message + "\nin " + file + " in line " + line);
	 return true;
}
var POPUP_TOOLBAR 				= 1;
var POPUP_LOCATION				= 2;
var POPUP_DIRECTORIES 			= 4;
var POPUP_STATUS 				= 8;
var POPUP_SCROLLBARS 			= 16;
var POPUP_RESIZABLE 			= 32;
var POPUP_COPYHISTORY 			= 64;
var POPUP_MENUBAR 				= 128;

var POPUP_ALL_OPTIONS			= (POPUP_MENUBAR|POPUP_TOOLBAR|POPUP_LOCATION|POPUP_DIRECTORIES|POPUP_STATUS|POPUP_SCROLLBARS|POPUP_RESIZABLE|POPUP_COPYHISTORY);

function popup(url, width, height, options)
{
	xOff = (screen.width - width)/2;
	yOff = (screen.height - height)/2;

	if (! options) {
		options = 0;
	}

	var optstr = "";
	optstr += "menubar="		+ (options & POPUP_MENUBAR		? "yes" : "no") + ",";
	optstr += "toolbar="		+ (options & POPUP_TOOLBAR		? "yes" : "no") + ",";
	optstr += "location="		+ (options & POPUP_LOCATION		? "yes" : "no") + ",";
	optstr += "directories="	+ (options & POPUP_DIRECTORIES	? "yes" : "no") + ",";
	optstr += "status="			+ (options & POPUP_STATUS		? "yes" : "no") + ",";
	optstr += "scrollbars="		+ (options & POPUP_SCROLLBARS	? "yes" : "no") + ",";
	optstr += "resizable="		+ (options & POPUP_RESIZABLE	? "yes" : "no") + ",";
	optstr += "copyhistory="	+ (options & POPUP_COPYHISTORY	? "yes" : "no") + ",";

	window.open(url, '', optstr + ',width=' + width + ',height=' + height + ',left=' + xOff + ',top=' + yOff);
}
