// functions.js

function printThis() {
	window.print();
}

function popup(URL, properties) {
	day = new Date();
	id = day.getTime();
	defaults = {
		'toolbar' : 0,
		'scrollbars' : 1,
		'location' : 0,
		'statusbar' : 0,
		'menubar' : 0,
		'resizable' : 0,
		/*'width' : 640,
		'height' : 480,*/
		'left' : 320,
		'top' : 272
	};
	if (properties) {
		for (var prop in defaults) {
			if (properties[prop] == undefined)
				properties[prop] = defaults[prop];
		}
	} else {
		properties = defaults;
	}

	var argstring = '';
	for (var prop in properties) {
		if (prop == 'centered') continue;
		if (prop == 'id') {
			id = properties[prop];
			continue;
		}
		if (argstring.length > 0) argstring += ',';
		argstring += prop + '=' + properties[prop];
	}
	var myWin;
	eval("myWin = window.open(URL, '" + id + "', '"+argstring+"');");

	if (properties['centered'] == 'true') {
		var screenW = 1024, screenH = 768;
		if (screen.availWidth && screen.availHeight) {
			screenW = screen.availWidth;
			screenH = screen.availHeight;
		} else if (screen.width && screen.height) {
			screenW = screen.width;
			screenH = screen.height;
		}

		var winWidth = 0, winHeight = 0;
		if (myWin.outerWidth && myWin.outerHeight) {
			winWidth = myWin.outerWidth;
			winHeight = myWin.outerHeight;
		} else if (myWin.width && myWin.height) {
			winWidth = myWin.width;
			winHeight = myWin.height;
		}
		var screenLeft = (screenW - winWidth) / 2;
		var screenTop = (screenH - winHeight) / 2;
		if (myWin.domain == 'www.theckd.org')
			myWin.moveTo(screenLeft, screenTop);
	}

	return false;
}
