/* ************************************************************************************* */
/* windowing utilities */
/* ************************************************************************************* */

function showPicture(sTitle, sUrl)
{
	var wnd = window.open('', 'Picture', 'menubar=no,toolbar=no,personalbar=no,locationbar=no,statusbar=no,resizable=yes,scrollbars=no,width=560,height=360');
	with(wnd.document){
		close();
		open();
		writeln("<html><head>");
		writeln("<link rel=\"StyleSheet\" href=\"peisker.css\" type=\"text/css\" media=\"screen\" />");
		writeln("<title>" + sTitle + "</title>");
		writeln("</head>");
		writeln("<body bgcolor=\"white\" topmargin=\"5\" bottommargin=\"0\" leftmargin=\"0\" rightmargin=\"0\">");
		writeln("<p>");
		writeln("&nbsp;&nbsp;");
		writeln("<a href=\"javascript:sizeToFit();\">Size To Fit</a>");
		writeln("&nbsp;&nbsp;");
		writeln("<a href=\"javascript:self.close();\">Close</a>");
		writeln("<hr/>");
		writeln("</p>");
		writeln("<center>");
		writeln("<img name='piggy' id='piggy' src='" + sUrl + "' alt='" + sTitle + "' border=0 />");
		writeln("</center>");
		writeln("</body>");
		writeln("<script language='javascript'>");
		writeln("function sizeToFit()");
		writeln("{");
		writeln(" var w = self.document.piggy.width + 50;");
		writeln(" var h = self.document.piggy.height + 100;");
		writeln(" if(w > screen.width) w = screen.width;");
		writeln(" if(h > screen.height) h = screen.height;");
		writeln(" var x = (screen.width - w) / 2;");
		writeln(" var y = (screen.height - h) / 2;");
		writeln(" self.moveTo(x, y);");
		writeln(" self.resizeTo(w, h);");
		writeln("}");
		writeln("");
		writeln("setTimeout(\"sizeToFit();\", 1500);");
		writeln("</script>");
		writeln("</html>");
	}
	wnd.focus();
}

var hlp = null;
function showPopup(strTitle, strHTML, fButtons, fShake, fTimeout)
{
	if (strTitle != "" && strTitle != null && strHTML != "" && strHTML != null)
	{
		hlp = window.open('', 'Hilfe', 'menubar=no,toolbar=no,personalbar=no,locationbar=no,statusbar=no,resizable=yes,scrollbars=yes,width=300,height=150');
		with(hlp.document)
		{
			close();
			open();
			writeln("<html><head>");
			writeln("<link rel=StyleSheet href='peisker.css' type='text/css' media=screen>");
			writeln("<title>" + strTitle + "</title>");
			writeln("</head>");
			writeln("<body bgcolor=white><p>");
			if(fButtons == true)
			{
				strHTML += "<br><br>";
				strHTML += "<a href='Javascript:self.print();'>Print</a>";
				strHTML += "&nbsp;&nbsp;";
				strHTML += "<a href='Javascript:self.close();'>Close</a>";
			}
			writeln(strHTML);
			writeln("</p></body>");
			writeln("</html>");
		}
		hlp.focus();
		if(fShake == true)
		{
			shaker(hlp, 5);
		}
		if(fTimeout == true)
		{
			setTimeout('hlp.close();', 3500);
			setTimeout('hlp.focus();', 5);
		}
		
	}
}

function shaker(wnd, cIterations)
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		var shakeX = 7, shakeY = 7;
		with(wnd)
		{	
			resizeBy(-shakeX, -shakeY);
			for(i = 1; i <= cIterations; i++)
			{
				moveBy(0, shakeY);
				moveBy(shakeX, 0);
				moveBy(0, -shakeY);
				moveBy(-shakeX, 0);
			}
			resizeBy(shakeX, shakeY);
		}
	}
}
