////////////////////////////////////////////////////////////////////////
//
function closeTheWindow(){
	if (lastWindowOpened != ""){
		if (eval("self." + lastWindowOpened)){
			if (!(eval("self." + lastWindowOpened + ".closed"))){
				eval ("self." + lastWindowOpened + ".close()");
			}
		}
	}
}


////////////////////////////////////////////////////////////////////////
// open new window and write HTML or to open an existing URL
// paramters: 
// winName = window name displayed in toolbar
// showMode = display image (mode = 1) or URL (mode=2)
// iX = x position of window, 0 for automatic
// iY = y position of window, 0 for automatic
// iWidth = window width in pixels, 0 for automatic
// iHeight = window height in pixels, 0 for automatic
// winTools = yes or no for each bar, separated by "*": scrollbars*toolbar*status
// paramStr = parameters dependent on mode
//   in the case of mode = 1:
//     pass parameters in string, separated by "*"
//     image-file*author*resolution
//   in the case of mode = 2: URL string

function openTheWindow(winName,showMode,iX,iY,iWidth,iHeight,winTools,paramStr)
{

var windowName = "";
var windowLook = "";
var windowDimension = "";
var windowURL = "";

if (showMode == 1) { var doHTML = ""; }

// browser dependent varibale
var NN = document.layers;

if (NN)
	{
	var yStr = "screenY=";
	var xStr = "screenX=";
	}
else
	{
	var yStr = "top=";
	var xStr = "left=";
	}

var defaultWSpace =  ((NN ? outerWidth  : screen.availWidth) / 5);
var defaultHSpace =  ((NN ? outerHeight  : screen.availHeight) / 5);
var defaultWidth  = ((NN ? outerWidth  : screen.availWidth) - defaultWSpace - defaultWSpace);
var defaultHeight = ((NN ? outerHeight : screen.availHeight) - defaultHSpace - defaultHSpace);


// define the tollbars that can be switched on or off
var toolsArray = ["scrollbars","toolbar","status","resizable"];

// set window name
thisWindowName= (((winName=="") || (winName.indexOf(" ")>=0)) ? "kora" : winName);

// set window URL
windowURL = (showMode == 2 ? paramStr : "");

// set window dimension
windowDimension = (iX == 0 ? (xStr+defaultWSpace+",") : (xStr+iX+","));  
windowDimension += (iY == 0 ? (yStr+defaultHSpace+",") : (yStr+iY+","));  
windowDimension += (iWidth == 0 ? ("width="+defaultWidth+",") : ("width="+iWidth+","));  
windowDimension += (iHeight == 0 ? ("height="+defaultHeight+",") : ("height="+iHeight+","));  

// set toolbars
tmpArray = winTools.split("*");

for (var i=0; i<tmpArray.length; i++)
	{
	 windowLook += (tmpArray[i]=="yes" ? (toolsArray[i] + "=yes") :  ( toolsArray[i] + "=no")) ;
	if (i < (tmpArray.length-1)) windowLook+=",";
	}




OpenThisWindow = true;
	if (eval("self." + thisWindowName)){
		// If this window object exists check to see if it's closed.
		// If it isn't bring it into focus.
		if (!(eval("self." + thisWindowName + ".closed"))){
			eval ("self." + thisWindowName + ".focus()");
			OpenThisWindow = false;
		}
	}
if (OpenThisWindow)
	{
	eval (thisWindowName + " = window.open(\""+windowURL+"\",\"" + thisWindowName + "\",\"" + windowDimension + windowLook +"\")");
	}

lastWindowOpened = thisWindowName;


if (showMode == 1 && OpenThisWindow)
	{
	copyRightPath="http://www.kora.ch/ge/copyright.htm";
	var tmpArray = paramStr.split("*");
	var content = "<html><head><link rel=stylesheet type=text/css href=\"";
	if (tmpArray[0].indexOf("../") > -1) content += tmpArray[0].substr(0,tmpArray[0].lastIndexOf("../")+3)
	content += "our_style.css\"></head>";
	content += "<body bgcolor=black>";
	content += "<cite>Photography:&nbsp;";
	content += ( tmpArray[1] + "&nbsp;<a href=\"" + copyRightPath + "\" target=_copyright>&copy;&nbsp;Copyright 2000</A>&nbsp;</cite>Resolution&nbsp;");
	content += ( tmpArray[2]+ "<br><br>");
	eval(thisWindowName + ".document").write(content);
	content = ( "<img border=\"0\" src=\"" + tmpArray[0] + "\" alt=\"Photography:&nbsp;" + tmpArray[1] + "\">");

	content += "<br></body></html>";
	eval(thisWindowName + ".document").write(content);	
	if (NN){eval(thisWindowName + ".document").write(content);}
	}

}


