// Globale Definition (nicht aendern) ////////////////////
WinType = new Array(2);
WinType[0] = "SeeAlsoWin";
WinType[1] = "ShowPopupWin";
SecondWinSizeRel = new Array(2);
SecondWinSizeX = new Array(2);
SecondWinSizeY = new Array(2);
SecondWinPosRel = new Array(2);
SecondWinPosX = new Array(2);
SecondWinPosY = new Array(2);
SecondWinPos = new Array(2);

///////////////////////////////
// JavaScript-Parameter ///////
///////////////////////////////


// SeeAlso ////////////////////

// Fenstergroesse (SeeAlsoWin)
SecondWinSizeRel[0] = 1;  // Angabe der Fenstergroesse [0=absolut in Pixel|1=relativ zur Aufloesung in Prozent]
SecondWinSizeX[0] = 45; // Fensterbreite in Pixel oder Prozent
SecondWinSizeY[0] = 40; // Fensterhoehe in Pixel oder Prozent

// Fensterposition
SecondWinPosRel[0] = 1;  // Angabe der Fensterposition [0=absolut|1=relativ zur Aufloesung]
// wenn SecondWinPosRel = 0:
SecondWinPosX[0] = 0; // Absolute Horizontalposition in Pixel von links
SecondWinPosY[0] = 0; // Absolute Vertikalposition in Pixel von oben
// wenn SecondWinPosRel = 1:
SecondWinPos[0] = 4; // Fensterpositionen [0=zentriert|1=LiOb|2=ReOb|3=LiUn|4=ReUn]


// ShowPopup ////////////////////

// Fenstergroesse (ShowPopupWin)
SecondWinSizeRel[1] = 1;  // Angabe der Fenstergroesse [0=absolut in Pixel|1=relativ zur Aufloesung in Prozent]
SecondWinSizeX[1] = 45; // Fensterbreite in Pixel oder Prozent
SecondWinSizeY[1] = 40; // Fensterhoehe in Pixel oder Prozent

// Fensterposition
SecondWinPosRel[1] = 1;  // Angabe der Fensterposition [0=absolut|1=relativ zur Aufloesung]
// wenn SecondWinPosRel = 0:
SecondWinPosX[1] = 0; // Absolute Horizontalposition in Pixel von links
SecondWinPosY[1] = 0; // Absolute Vertikalposition in Pixel von oben
// wenn SecondWinPosRel = 1:
SecondWinPos[1] = 3; // Fensterpositionen [0=zentriert|1=LiOb|2=ReOb|3=LiUn|4=ReUn]


// ShowMore ///////////////////

// keine Parameter



///////////////////////////////
// Skripte ////////////////////
///////////////////////////////


// ShowMore ////////////////////

function ShowMoreToggle(x) {
        nextnode = document.getElementById(x);
        if (nextnode.style.display == "none") {
                nextnode.style.display = "block";
                document.images[(x)+"pm"].src = "graphics/minus.gif";
        }
        else {
                nextnode.style.display = "none";
                document.images[(x)+"pm"].src = "graphics/plus.gif";
        }
}


// SeeAlso + ShowPopup ////////////////////

function CloseSecondWin() {
	for (n=0;n<=1;n++) {
		if (WinType[n]) {
			if (!WinType[n].closed) {
				WinType[n].close();
			}
		}
	}
}

if (WinType[0]) {WinType[0]=false;}
if (WinType[1]) {WinType[1]=false;}


function ShowSecondWin(a,b){ // wenn Anzeige in Zweitfenster (a -> HTML-Datei, b -> Fenster-Typ)
	var Type = b;
//	a = "/"+a;
//	if (opener) { // wenn Link in Zweitfenster
//		window.location.href = a;
//	}
//	else { // wenn Link in Hauptfenster
		if (WinType[Type]) { // wenn Zweitfenster vorhanden ist oder war
			if (!WinType[Type].closed) { // wenn Zweitfenster vorhanden ist
				WinType[Type].location.href = a;
				WinType[Type].focus();
			}
			else { // wenn Zweitfenster vorhanden war
//				alert("ShowSecondWin\na="+a+", Type="+Type); // Debugfenster
				WinOpen(a,Type);
//				WinType[Type].location.href = a; // auskommentiert 2012-06-01 - HR - TeamOne
			}
		}
		else { // wenn noch kein Zweitfenster vorhanden
//			alert("ShowSecondWin\na="+a+", Type="+Type); // Debugfenster
			WinOpen(a,Type);
//			WinType[Type].location.href = a; // auskommentiert 2012-06-01 - HR - TeamOne
		}
//	}
}


function ShowContentWin(a){ // fuer Anzeige in Hauptfenster

		if (opener) // wenn Link in Popup
		{
			if(opener.name.indexOf("WWHFrame")>-1) { // wenn aufrufenden Seite das Hauptfenster ist
//				alert(opener.name) // Debugfenster
				opener.WWHFrame.WWHContentFrame.WWHDocumentFrame.location.href = a; 
				opener.WWHFrame.WWHContentFrame.WWHDocumentFrame.focus();
			}
			else if (opener.name=="ShowPopupWin" || opener.name=="SeeAlsoWin"){ // wenn aufrufenden Seite ein Popup ist
//			    alert(opener.name) // Debugfenster
				opener.opener.WWHFrame.WWHContentFrame.WWHDocumentFrame.location.href = a; //vorher: opener.WWHFrame etc.
				opener.opener.WWHFrame.WWHContentFrame.WWHDocumentFrame.focus(); 
			}
		}else { // wenn Link in Hauptfenster
			document.location.href = a;
		}
}


function WinOpen(a,b) {  // Fenster oeffnen (a -> HTML-Datei, b -> Fenster-Typ)
	var sw = screen.availWidth;
	var sh = screen.availHeight;
	var SX, SY, PX, PY;
	if (SecondWinSizeRel[b]==0) {
		SX = SecondWinSizeX[b] - 10;
		SY = SecondWinSizeY[b] - 32;
	}
	if (SecondWinSizeRel[b]==1) {
		SX = sw * SecondWinSizeX[b] / 100 - 10;
		SY = sh * SecondWinSizeY[b] / 100 - 32;
	}
	if (SecondWinPosRel[b]==0) {
		if (SecondWinPosX[b]>=sw || SecondWinPosY[b]>=sh) { // wenn ausserhalb von Bildschirm, auf Relativangabe setzen
			alert("Window position out of visible screen area.\nWindow position corrected.");
			SecondWinPosRel[b]=1;
		}
	}
	if (SecondWinPosRel[b]==1) {
		if (SecondWinPos[b]==0) {
			PX = (sw - SX) / 2; PY = (sh - SY) / 2;
		}
		if (SecondWinPos[b]==1) {
			PX = 0; PY = 0;
		}
		if (SecondWinPos[b]==2) {
			PX = sw - SX - 10; PY = 0;
		}
		if (SecondWinPos[b]==3) {
			PX = 0; PY = sh - SY - 32;
		}
		if (SecondWinPos[b]==4) {
			PX = sw - SX - 10; PY = sh - SY - 32;
		}
	}
//	alert("WinOpen\nsw="+sw+", sh="+sh+", SX="+SX+", SY="+SY+", PX="+PX+", PY="+PY+", b="+b); // Debugfenster
    if (b==0) {
		WinType[0] = window.open(a,"SeeAlsoWin","width="+SX+",height="+SY+",left="+PX+",top="+PY+",resizable=yes,scrollbars=yes,status=no");
	}
	else {
		WinType[1] = window.open(a,"ShowPopupWin","width="+SX+",height="+SY+",left="+PX+",top="+PY+",resizable=yes,scrollbars=yes,status=no");
	}
}
