
//-----------------------------------------------------------------------
// Function: openURL
//
// Params: strName - string die URL die geöffnet werden soll
//           nWidth - int die Breite
//           nHeight - int die Höhe
//
// RetValue:
//
// Description:
//
// Sample:
//
//
var myPage = null;
var oldPage = null;

function openURL(strName,nWidth,nHeight)
        {
        var strParams;

        strParams = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=no,resizable=yes,copyhistory=yes,width=";
        strParams = strParams + nWidth + ",height=" + nHeight;

        if(myPage)
                {
                oldPage = myPage;
                }
        myPage = window.open(strName,"_blank",strParams);

        if(oldPage)
                {
                oldPage.close();
                oldPage = null;
                }
        }

		
function openURLWithScrollBars(strName,nWidth,nHeight)
        {
        var strParams;

        strParams = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=";
        strParams = strParams + nWidth + ",height=" + nHeight;

        if(myPage)
                {
                oldPage = myPage;
                }
        myPage = window.open(strName,"_blank",strParams);

        if(oldPage)
                {
                oldPage.close();
                oldPage = null;
                }
        }

function openURLExtendedWithWindowName(strURL,strWindowName,nWidth,nHeight,fWithMenu,fWithStatus,fWithScrollbars)
        {
        var strParams;
        var strStatus = "yes";
        var strMenu = "yes";
        var strScrollBars = "yes";

        if(fWithMenu == false) strMenu = "no";
        if(fWithStatus == false) strStatus = "no";
        if(fWithScrollbars == false) strScrollBars = "no";

        strParams = "toolbar=no,location=no,directories=no,status=" + strStatus + ",menubar=" + strMenu + ",scrollbars=" + strScrollBars + ",resizable=yes,copyhistory=yes,width=";
        strParams = strParams + nWidth + ",height=" + nHeight;

        if(myPage)
                {
                oldPage = myPage;
                }
        myPage = window.open(strURL,strWindowName,strParams);
		myPage.opener = self; // Merken des Aufrufers
		
        if(oldPage)
                {
                oldPage.close();
                oldPage = null;
                }
        }
			
function openURLExtended(strName,nWidth,nHeight,fWithMenu,fWithStatus,fWithScrollbars)
        {
		openURLExtendedWithWindowName(strName,"_blank",nWidth,nHeight,fWithMenu,fWithStatus,fWithScrollbars);
        }

function openURLWithoutMenu(strName,nWidth,nHeight)
        {
        var strParams;

        strParams = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=";
        strParams = strParams + nWidth + ",height=" + nHeight;

        if(myPage)
                {
                oldPage = myPage;
                }
        myPage = window.open(strName,"_blank",strParams);

        if(oldPage)
                {
                oldPage.close();
                oldPage = null;
                }
        //return myPage // sonst kommt es immer zu einem "komischen" Object Fehler
        }

function openURLWithoutMenuPlusRetValue(strName,nWidth,nHeight) // Wird eigentlich nur für openDynamic Window benötigt
        {
        var strParams;

        strParams = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=";
        strParams = strParams + nWidth + ",height=" + nHeight;

        if(myPage)
                {
                oldPage = myPage;
                }
        myPage = window.open(strName,"_blank",strParams);

        if(oldPage)
                {
                oldPage.close();
                oldPage = null;
                }
        return myPage // sonst kommt es immer zu einem "komischen" Object Fehler
        }

function openURLWithoutSize(strName)
	{
    return window.open(strName,"_blank");
	}
	
/*
Wird vom CMS generiert wenn ein ZoomBild da ist. STYLE Eigenschafen stehen im Customer CSS
unter dem Eintrag "Dynamisches POPUP"
*/	
//function openURLCMSZoomWindow(strURL,nDefaultWidth = 100,nDefaultHeight = 100,strTitle = "Zoom")
function openURLCMSZoomWindow(strURL,nDefaultWidth,nDefaultHeight,strDefaultTitle)
	{
	var imageZoom = new Image();
	var strParams;
	var nWidth,nXBorder;
	var nHeight,nYBorder;
	var strTitle;
	
	// Image wird zuerst geladen damit die Größe bestimmt werden kann
	imageZoom.src = strURL;
	//nWidth = imageZoom.width;
	//nHeight = imageZoom.height;
	nWidth = (nDefaultHeight == null)?  100 : nDefaultHeight;
	nHeight = (nDefaultWidth == null)?  100 : nDefaultWidth;
	strTitle = (strDefaultTitle == null)?  "Zoom" : strDefaultTitle;
	
	nXBorder = 50;
	nYBorder = 50;
	
	nWidth = nWidth + nXBorder;
	nHeight = nHeight + nYBorder;	
	
	strPopupPath = '/online/include';
	if(window.location.host.indexOf('kirchberg.at') != -1)
		{
		strPopupPath = '/kirchberg/include';
		}
		
	if(myPage)
            {
			myPage.close();
			myPage = null;
            }
				
	strParams = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=" + nWidth +",height=" + nHeight + ",screenX=40,screenY=50,top=50,left=40";
			
	myPage = window.open(strPopupPath + "/dynpopup.php?zoomimage=" + strURL + "&title=" + strTitle,"_blank",strParams);
	myPage.focus();
	}

	
/*
wird am Ende (nach body) vom Dynamischen Fenster aufgerufen.
*/
function onDynPopupLoaded()
	{
	var nWidth,nXBorder;
	var nHeight,nYBorder;
	var imageZoom;

	nXBorder = 62;
	nYBorder = 82;
	
	imageZoom = document.images[0];

	nWidth = imageZoom.width;
	nHeight = imageZoom.height;

	nWidth = nWidth + nXBorder;
	nHeight = nHeight + nYBorder;	
	
	window.resizeTo(nWidth,nHeight);
	}	
	
/*
In das mit about:blank erzeugte Fenster wird eine Tabelle mit Bild geschrieben.
- eigentlich obsolet - da jetzt alles über popup_zoom gemacht wird
*/	
function writeCodeToCMSZoomPopup(wndPage,strURL)
	{
    //wndPage.document.writeln("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");

    wndPage.document.writeln("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
    wndPage.document.writeln("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//DE\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
    wndPage.document.writeln("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
    wndPage.document.writeln("<head>");
    wndPage.document.writeln("<title>Zoom</title>");
    wndPage.document.writeln("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />");
    wndPage.document.writeln("<script language=\"JavaScript\" src=\"/online/include/wnd_handling.js\" type=\"text/javascript\"></script>");
	wndPage.document.writeln("<link rel=\"stylesheet\" href=\"/online/customer.css\" type=\"text/css\">");
    wndPage.document.writeln("</head>");
    wndPage.document.writeln("<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" class=\"cmsdynpopup_body\">");
    wndPage.document.writeln("<table width=\"100%\" border=\"0\" align=\"center\" valign=\"middle\" cellpadding=\"0\" cellspacing=\"0\" class=\"cmsdynpopup_table\">");
    wndPage.document.writeln("  <tr class=\"cmsdynpopup_cellpicture\">");
    wndPage.document.writeln("    <td align=\"center\" valign=\"middle\"><img src=\""+ strURL +"\" / name=\"zoomimage\" id=\"zoomimage\"></td>");
    wndPage.document.writeln("  </tr>");
    wndPage.document.writeln("  <tr class=\"cmsdynpopup_cellclose\">");
    wndPage.document.writeln("    <td align=\"right\">[<a href=\"javascript:window.close()\" class=\"cmsdynpopup_cellclose\">schlie&szlig;en");
    wndPage.document.writeln("        / close</a>]</td>");
    wndPage.document.writeln("  </tr>");
    wndPage.document.writeln("</table>");
    wndPage.document.writeln("</body>");
    wndPage.document.writeln("<script language=\"JavaScript\">");
    wndPage.document.writeln("<!--");
    wndPage.document.writeln("onDynPopupLoaded();");
    wndPage.document.writeln("//-->");
    wndPage.document.writeln("</script>");
    wndPage.document.writeln("</html>");
	
	alert("9999");
	}
	
/**
Function: openDynamicWindow

Params: strGrafFile - Name von GIF oder JPG File
        nWidth - int die Breite
        nHeight - int die Höhe

Description: VORAUSSETZUNG ist dass in diesem Folder ein File mit dem Namen popup.html existiert
             der Inhalt von popup.html wird dann dynamisch erzeugt
Sample:

*/
function openDynamicWindow(strGrafFile,nWidth,nHeight)
        {
        var myPage = openURLWithoutMenuPlusRetValue("popup.html",nWidth,nHeight);

        if(myPage)
                {
                myPage.document.write("<html>");
                myPage.document.write("<head>");
                myPage.document.write("<title></title>");
                myPage.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
                myPage.document.write("</head>");

                myPage.document.write("<body bgcolor=\"#FFFFFF\">");
                myPage.document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"100%\">");
                myPage.document.write("  <tr align=\"center\" valign=\"middle\">");
                myPage.document.write("    <td><img src=\"" + strGrafFile + "\"></td>");
                myPage.document.write("  </tr>");
                myPage.document.write("</table>");
                myPage.document.write("</body>");
                myPage.document.write("</html>");
                }
        }