// 
// NEW WINDOW
//

function MM_openBrWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}


// popupfester (NOCH NICHT 100%ig fertig, da Aufrufpfad relativ)
var windowName 	= "imageWindow";
var params 		= "locationbar=0,menubar=0,resizable=1,status=0,width=100,height=100";
function ZoomPic(URL) {
	window.open("bildzoom.php?bild="+ URL,windowName,params);
	}


// 
// PREALOADING
//

	
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


// 
// POP-UP
//

var imgPath = "img_popup";


var pictureWindow = false;

// Ein Bild alleine in einem Fenster anzeigen:
function openImageWindow (imageUrl)
{
	var theTitle = arguments.length > 1 ? arguments[1] : "Steinbach und Schäfer";

	// Ungefähr so groß ist der Rand innerhalb des Fensters:
	/*
	var xBorder = document.all ? 40 : 30;
	var yBorder = document.all ? 90 : 30;
	*/
	var xBorder = 5;
	var yBorder = 20;

	var params = "locationbar=0,menubar=0,resizable=1,status=0";
	params += ",width=100,height=100";

	var windowName = "imageWindow";
	if (pictureWindow && !pictureWindow.closed)
	{
//		alert ("closing pictureWindow...");	//debug
		pictureWindow.close ();
	}
	// Fenster erzeugen (öffnen)...
//	var pictureWindow = window.open (imageUrl, windowName, params);

	pictureWindow = window.open ('', windowName, params);

	// Name/Id des Bildes:
	var imageName = "theImage";
	// Name/Id des Layers:
	var layerName = "theLayer";
	// Dokument des Fensters ermitteln...
	var theDoc = pictureWindow.document;
	// ...Dokument des Fensters öffnen...
	theDoc.open ();

	theDoc.writeln ("<head>");
	theDoc.writeln ("<title>", theTitle, "</title>");

	var writeZeroBorders = function ()
	{
		for (var i = 0; i < arguments.length; ++i)
		{
			theDoc.writeln (arguments[i], " { margin:0px 0px 0px 0px; }");
			theDoc.writeln (arguments[i], " { margin-left:0px; margin-right:0px; margin-top:0px; margin-bottom:0px; }");
		}
	};
	theDoc.writeln ("<style type=\"text/css\">");
	writeZeroBorders ("div", "body", "td", "table");
	theDoc.writeln ("</style>");
	theDoc.writeln ("</head>");
	theDoc.writeln ("<body>");

//	theDoc.write ("<div name=\"" + layerName + "\" id=\"" + layerName + "\" style=\"position:absolute;top:0;left:0;width:100;height:100;z-index:1;\">");

	theDoc.write ("<img name=\"" + imageName + "\" id=\"" + imageName + "\" src=\"" + imageUrl + "\" border=0 hspace=0 vspace=0>");
//	theDoc.write ("</div>");

	// ...Script für Größenanpassung schreiben...
	theDoc.writeln ("<script language=\"JavaScript1.1\">");
	theDoc.writeln ("var thisImageName = \"" + imageName + "\";");
	theDoc.writeln ("var tries = 0;");
	theDoc.writeln ("var maxTries = 10;");
	theDoc.writeln ("var lastWidth = 0; var lastHeight = 0;");
	theDoc.writeln ("var dx = " + xBorder + "; var dy = " + yBorder + ";");

	theDoc.writeln ("function findImage ()");
	theDoc.writeln ("{");
	theDoc.writeln ("	if (document.images[thisImageName])");
	theDoc.writeln ("		return document.images[thisImageName];");
	theDoc.writeln ("	else if (document.all)");
	theDoc.writeln ("		return document.all." + imageName);
	theDoc.writeln ("	else if (document.layers)");
	theDoc.writeln ("		return document.layers[" + layerName + "]." + imageName);
	theDoc.writeln ("	else ");
	theDoc.writeln ("		return false;");
	theDoc.writeln ("}");

	theDoc.writeln ("function resizeWindowAroundImage ()");
	theDoc.writeln ("{");
	theDoc.writeln ("	var thisImage = findImage ();");
	theDoc.writeln ("	if (thisImage)");
	theDoc.writeln ("	{");
	theDoc.writeln ("		with (thisImage)");
	theDoc.writeln ("		{");
	theDoc.writeln ("			window.resizeTo (width + dx, height + dy);");
	theDoc.writeln ("			if (width == lastWidth && height == lastHeight)");
	theDoc.writeln ("				++tries;");
	theDoc.writeln ("			else");
	theDoc.writeln ("			{");
	theDoc.writeln ("				lastWidth = width;");
	theDoc.writeln ("				lastHeight = height;");
	theDoc.writeln ("				tries = 0;");
	theDoc.writeln ("				window.focus();");
	theDoc.writeln ("			}");
	theDoc.writeln ("		}");
	theDoc.writeln ("	}");
	theDoc.writeln ("	if (tries < maxTries)");
	theDoc.writeln ("		setTimeout (\"resizeWindowAroundImage ();\", 500);");
	theDoc.writeln ("	else");
	theDoc.writeln ("		window.focus();");
	theDoc.writeln ("}");
	theDoc.writeln ("setTimeout (\"resizeWindowAroundImage ();\", 100);");
	theDoc.write ("</script>");

	theDoc.writeln ("</body>");
	// ...Dokument des Fensters schließen...
	theDoc.close ();
	// ... und Fenster in den Vordergrund bringen:
	pictureWindow.focus ();
	return pictureWindow;
}



function sunds_img (anImgUrl)
{
	var imgUrl = "img_popup/" + anImgUrl;
	var theTitle = arguments.length > 1 ? arguments[1] : "Steinbach und Schäfer";

	openImageWindow (imgUrl, theTitle);

//	alert ("Bild\n\n" + anImgUrl);
}

