/***************************************************
*	JavaScript - Pop-Up-Fensterfunktion	v1.8.0420	*
*	Copyright (c) 2001 - 2008 by Jörg Schuchardt		*
***************************************************/

var winObj;

function openPicWin(url, picWidth, picHeight, winWidth, winHeight, config) {
	if (openPicWin.arguments.length < 3 || isNaN(picWidth) || isNaN(picHeight))	return false;

	if (winObj && winObj.closed == false)	winObj.close();

	if (!winWidth || isNaN(winWidth))	winWidth  = Math.min(picWidth, screen.availWidth - 10);
	if (!winHeight || isNaN(winHeight))	winHeight = Math.min(picHeight, screen.availHeight - 10);

	var overflow = (picWidth > winWidth || picHeight > winHeight),
	data = "left=" + Math.floor((screen.availWidth - winWidth) / 8);
	data+= ", top=" + Math.floor((screen.availHeight - winHeight) / 2);
	data+= ", width=" + (winWidth > screen.availWidth - 10 ? screen.availWidth - 10 : winWidth);
	data+= ", height=" + (winHeight > screen.availHeight - 10 ? screen.availHeight - 10 : winHeight);
	data+= ", " + (config ? config : "scrollbars=" + (overflow ? "yes" : "no") + ", resizable=no");

	winObj = window.open("", "picWin", data);
	winObj.document.open();
	winObj.document.write('<html>');
	winObj.document.write('<head>');
	winObj.document.write('<scr' + 'ipt>');
	winObj.document.write('if (document.layers) document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP); document.onmousedown = md; document.onmouseup = mu; document.oncontextmenu = cm; window.onblur = self.close;');
	winObj.document.write('function md(evt) { if (evt&&evt.which == 3) return false; return true; } function mu(evt) { ' + (overflow ? "if (evt&&evt.which == 3) self.close(); return false;" :  "self.close();") + ' } function cm(evt) { return false; }');
	winObj.document.write('</scr' + 'ipt>');
	winObj.document.write('</head>');
	winObj.document.write('<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">');
	winObj.document.write('<div onclick="self.close();" oncontextmenu="self.close();" style="position: absolute; top: 0px; left: 0px; width: ' + picWidth + 'px; height: ' + picHeight + 'px; background: white url(' + url + ') no-repeat;"></div>');
	winObj.document.write('</body>');
	winObj.document.write('</html>');
	winObj.document.close();
	winObj.focus();

	return winObj;
}

function openWindow(url, posX, posY, width, height, config) {
	if (openWindow.arguments.length < 5 || isNaN(posX) || isNaN(posY) || isNaN(width) || isNaN(height))	return false;
	if (winObj && winObj.closed == false)	winObj.close();

	var data = "left=" + posX;
	data += ", top=" + posY;
	data += ", width=" + width;
	data += ", height=" + height;
	data += ", " + (config ? config : "scrollbars=no, resizable=no");

	winObj = window.open(url, "popWin", data);
	if (parseInt(navigator.appVersion) >= 4)	winObj.focus();

	return winObj;
}
