
var objForm = null;
var objWindowCF = null;
var objID = null;
var sImgSrc = "";
var bCalWinOpen = false;

function openCalWinOpen (vsTitle, vsFile, vnWidth, vnHeight, oFrm, vnObjID, vsImgSrc)
{
	objForm = oFrm;
	objID = vnObjID;
	sImgSrc = vsImgSrc

	if (bCalWinOpen) {
		fCloseCalWindow(false);
	}

    var windowOptions  = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=yes,width=" + vnWidth + ",height=" + vnHeight + ",left=500,top=30,screenX=500,screenY=30";
	objWindowCF = this.open('about:blank',vsTitle,windowOptions);
	objWindowCF.callingForm = this;
    bCalWinOpen = true;

	lsHtmlBody  = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n";
    lsHtmlBody += "<html>\n";
    lsHtmlBody += "<head>\n";
	lsHtmlBody += "<title>" + vsTitle + "</title>\n";
	lsHtmlBody += "<script type=\"text/javascript\">\n";
	lsHtmlBody += "var bUpdate=false;\n";
	lsHtmlBody += "var sFile=\"\";\n";
	lsHtmlBody += "var nHeight=\"\";\n";
	lsHtmlBody += "var nWidth=\"\";\n";
	lsHtmlBody += "var bRun=true;\n";
	lsHtmlBody += "function closeCfWindow () { if (bRun) { bRun=!bRun; callingForm.fCloseCalWindow(sFile, nHeight, nWidth, bUpdate); }};\n";
	lsHtmlBody += "window.onunload=closeCfWindow;\n";
	lsHtmlBody += "</script>\n";
	lsHtmlBody += "</head>\n";
	lsHtmlBody += "<frameset rows=\"100%\">\n";
	lsHtmlBody += "<frame src=\"" + vsFile + "\" name=\"main\">\n";
	lsHtmlBody += "<noframes>\n";
	lsHtmlBody += "<body>\n";
    lsHtmlBody += "<p>Der Browser stellt keine Frames dar.</p>\n";
	lsHtmlBody += "</body>\n";
  	lsHtmlBody += "</noframes>\n";
	lsHtmlBody += "</frameset>\n";
	lsHtmlBody += "</html>\n";

	objWindowCF.callingForm = this;
	objWindowCF.document.open();
	objWindowCF.document.write(lsHtmlBody);
	objWindowCF.document.close();
	objWindowCF.callingForm = this;
	objWindowCF.focus();
}

function fCloseCalWindow(sFile, nHeight, nWidth, bUpdate) 
{
    if (bCalWinOpen) 
    {
		bCalWinOpen = false;
		objWindowCF.close();
		if (bUpdate) { relodeObj (sFile, nHeight, nWidth); }
    }
}

function relodeObj (sFile, nHeight, nWidth)
{
	var sRdo = Math.random()*100000000000000000;
	sRdo = "?rdo="+sRdo;

	if (sFile == '') { sImgSrc = "/images/epk.gif"; nWidth = 0; nHeight = 0; }
	else { sImgSrc += sFile; }

	document.getElementById(objID).src = sImgSrc + sRdo;
	document.getElementById(objID).width = nWidth;
	document.getElementById(objID).height = nHeight;
}
