var vertical_center = (screen.height / 2);
var horizontal_center = (screen.width / 2);
var infowindow;

// Opens a popup-window centered on screen.
function openLink (width,height,page,name) {
	if (window.infowindow) {window.infowindow.close(); window.infowindow = null;}
	infowindow = window.open
	    (page,name,"resizable=1,status=yes,toolbar=no,scrollbars=yes,width="+width+",height="+height+",top="+(vertical_center-height/2-30)+",left="+(horizontal_center-width/2));
	if (window.focus) window.infowindow.focus();
	return false;
}

function openLink2 (page,name) {
	width = 850;
	height = 600;
	if (window.infowindow) {window.infowindow.close(); window.infowindow = null;}
	infowindow = window.open
	    (page,name,"resizable=1,status=yes,toolbar=no,scrollbars=yes,width="+width+",height="+height+",top="+(vertical_center-height/2-30)+",left="+(horizontal_center-width/2));
	if (window.focus) window.infowindow.focus();
	return false;
}

function openLink2_noscroll (page,name) {
	width = 850;
	height = 600;
	if (window.infowindow) {window.infowindow.close(); window.infowindow = null;}
	infowindow = window.open
	    (page,name,"resizable=1,status=yes,toolbar=no,scrollbars=no,width="+width+",height="+height+",top="+(vertical_center-height/2-30)+",left="+(horizontal_center-width/2));
	if (window.focus) window.infowindow.focus();
	return false;
}

function openNewLink2 (page,name) {
	width = 850;
	height = 600;
	var win = window.open
	    (page,name,"resizable=1,status=yes,toolbar=no,scrollbars=yes,width="+width+",height="+height+",top="+(vertical_center-height/2-30)+",left="+(horizontal_center-width/2));
	win.focus();
	return false;
}

// Checks if the value is an integer.
function isInt(xvalue) {
	return !isNaN(xvalue) && (xvalue.indexOf(".") == -1);
}

// Convenience function to do a regexp-match
function strmatch(regex,streng) {
	return regex.test(streng);
}

// Find an elements actual position
function getpos (element) {
	var curleft = curtop = 0;
	if (element.offsetParent) {
		do {
			curleft += element.offsetLeft;
			curtop += element.offsetTop;
		} while (element = element.offsetParent);
	}
	return [curleft,curtop];
}

var _pageZoom = 100;
function toggleZoom() {
	_pageZoom = (_pageZoom == 100) ? 150 : 100;
	pageZoom( _pageZoom );
}

function pageZoom( percent ) {
	document.body.style.zoom = percent+'%';
}