// $Id: window-management.js,v 1.3.2.1 2007/08/14 12:33:26 dano Exp $
// Standard Window Management Scripts

function open_window (url, width, height, centered, window_name, feature_string) {
	// Javascript function to open a new window
	// Required arguments are: url, width, height
	// Optional arguments are: centered, window name, feature string
	// Set window name to blank string if no window name passed
	if (!window_name) {
		window_name = '';
	}
	// Set feature string to blank string if no feature string passed
	if (!feature_string) {
		feature_string = '';
	}
	// Otherwise add a comma to the beginning
	else {
		feature_string = ',' + feature_string;
	}
	// Set starting position co-ordinates
	var x = 0;
	var y = 0;
	// Get co-ordinates of center of screen if required
	if(centered) {
		x = Math.round((screen.availWidth - width) / 2);
		y = Math.round((screen.availHeight - height) / 2);
	}
	// Build feature string
	feature_string = 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height + feature_string;
	// Open new window
	window.open(url, window_name, feature_string);
	return true;
}

function open_image_window (image_path, title) {
	// Replaces perlPopUp
	var url = 'http://--VHOST-NAME--/cgi-bin/popup-image.pl';
	url = url + '?-image=' + image_path + '&-title=' + title;
	open_window(url, 400, 400, 1, 'imageWin', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');
	return true;
}

function open_outbound_window(url) {
	open_window(url,800,600,1,'outboundWin','toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1');
}
