/* 
	Misc javascript functions available to all webpages
*/


/* Open an image in a new browser window sized to the image

Usage:
Include or copy the contents of this file into the html file 
Call the openImage fuction with the onClick event of an image or anchor
The openImage function takes 3 arguments; 
    the path to the image, the image width and height

e.g.    <img onClick="openImage('full/img.jpg', 400, 300)" src="thumbs/img.jpg">
*/
var imageWindow = null;
function openImage(imageName, width, height) {
	if (imageWindow != null) imageWindow.close();
	imageWindow = window.open(imageName, 'Images', 'width='+(width+20)+', height='+(height+20)+', left=0, right=0, toolbar=no, directories=no, location=no status=no, resizable=no, scrollbars=no');
	return false;
}



/* Debugging Console - Open a window and output Javascript debugging messages

Usage:
Call the debug() function with a string to print in the window, 
the window is opened if it is not already.
*/
var _console = null;
function debug(msg) {
	if ((_console == null) || (_console.closed)) {
		_console = window.open("", "console", "width=600,height=300,resizable");
		_console.document.open("text/plain");
	}
	_console.focus();
	_console.document.writeln(msg);
}


