// javaScript for imagomat.de

function getCanvasHeight() {
	// returns height of canvas 
	// (drawable rect of window)
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getCanvasWidth() {
	// returns width of canvas 
	// (drawable rect of window)
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth=window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}


function openWindowCentered(filePath, width, height) {
	// opens new window
	// filePath: Location of file to open in new window
	// width: The requested width of the new window
	// height: The requested height of the new window
	var optionStr = '';
	var title = ''; //The title of the window (will be overwritten by title tag of html file)
	var topPos = parseInt((getCanvasHeight() / 2) - (height / 2));
	topPos += 40; // add some space for menu, adress bar or toolbar height
				// position of window.open is related to window dimensions
				// window top-left is (0,0)
	var leftPos = parseInt((getCanvasWidth() / 2) - (width / 2));
	optionStr = "width=" + width + ",height=" + height + ",top=" + topPos + ",left=" + leftPos + ", resizable=no";
	window.open(filePath, title, optionStr);
}
