// *****************************************************************
//  Copyright (c) 2004 ORISA Software GmbH All Rights Reserved.
// ORISA Software GmbH
// www.orisa.de
// *****************************************************************

// open new browser window
// *****************************************************************
var extWindows = new Array();

function openWindow(url, wName, settings)
{
	// init
	wWidth = settings.width? settings.width: 100;
	wHeight = settings.height? settings.height: 100;
	wStatus = settings.status? 1: 0;
	wResizable = settings.resize? 1: 0;
	wMenu = settings.menu? 1: false;
	wScroll = settings.scroll? 1: 0;
	wTool = settings.tool? 1: 0;

	// append time parameter
	if(url)
	{
		if(url.indexOf("?") > -1)
			url += "&RT=";
		else
			url += "?RT=";
		url += new Date().getTime();
	}
	var top = 0;
	if(screen.availHeight)
		top = (screen.availHeight - wHeight)/2;
	var left = 0;
	if(screen.availWidth)
		left = (screen.availWidth - wWidth)/2;

	// open window
	var win = null;
		try
		{
			win = window.open(url+="&WWIDTH="+wWidth+"&WHEIGHT="+wHeight, wName, 'toolbar=' + wTool + ',location=0,directories=0,status=' + wStatus + ',menubar=' + wMenu + ',scrollbars=' + wScroll + ',resizable=' + wResizable + ',left=' + left + ',top=' + top + ',width=' + wWidth + ',height=' + wHeight);
			win.focus();
		}
		catch(ex)
		{
			; //alert("openWindow() failed!");;
		}
	return win;
}
	
function resetAttribute(id)
{
	if(id)
		topFrame.document.forms["sessionData"].elements["RESET"].value=id; 
	else
		topFrame.document.forms["sessionData"].elements["RESET"].value="-1"; 
	submitForm();
}

// ******************************************
function submitForm()
{
	showGlasspane();
	var fData = topFrame.document.forms["sessionData"];
	var wTree = topFrame.getFrameObj("tree");
	if (wTree)
		fData.elements["SCROLL"].value = wTree.document.body.scrollTop;
	fData.elements["RT"].value = new Date().getTime();
	fData.submit();
}

// ******************************************
function paramToString(pArr)
{
	var rV = "?";

	for(var i in pArr)
	{
		if(i == "cG" || i == "sb_left" || i == "sb_right")
			continue;
		if(rV.length > 1)
			rV += "&";
		rV += i;
		rV += "=";
		
		rV += escape(pArr[i]);
	}

	rV += "&RT=" + new Date().getTime();
	
	return rV;
}

// update container frames
// ******************************************
function handleAttribute(param)
{
	/*
	if (typeof(simpleTrace)=="function")
		simpleTrace("handleAttribute", param);
	*/
	//alert("handleAttribute\n\n"+dump(param));
	var fObj = null;
	var fV = topFrame.document.forms["sessionData"].elements;
	var params = paramToString(param);
	// expand group status -> navigateTop/ container
	// 20061010; tsc; #39693: fix for Safari
	var expandGroup = true;
	if (fV["GID"])
		expandGroup = (fV["GID"].value!="");
		
		
	//interactiveInspect('topFrame.getFrameObj);	
	
	// all frames loaded ?
	// 20061017; tsc; #39693: removed 'topFrame.getFrameObj("container")!=null  && ': container does not need to be loaded, because none of its methods is called; it will be reloaded in any case
	// 20061204; tsc: added check for f_application, because it has to be already loaded when switchActiveGraphic() is called
	if(topFrame.getFrameObj("views")!=null  && topFrame.getFrameObj("navigateTop")!=null  && topFrame.getFrameObj("navigateBottom")!=null  && topFrame.getFrameObj("status")!=null && topFrame.getFrameObj("application")!=null /*&& topFrame.getFrameObj("OWFdyn")!=null*/) 
	{
		// update view-tab 
		topFrame.getFrameObj("views").updateView(param["nV"],param["cG"],param["MV"],(param["status"]==1? fV["CONF"].value==1?2:1:0));

		// update status-tab
		topFrame.getFrameObj("status").updateView(param["sb_left"], ((param["MV"]=="1" || param["MV"]==1)?param["sb_right"]:""), param["status"], param["progress"]);

		// update navigate frames
		if(fV["BACK"] != param["bId"] || fV["NEXT"] != param["nId"])
		{
			topFrame.getFrameObj("navigateTop").updateView(param["bId"],param["nId"],param["MV"],param["nV"],expandGroup);
			topFrame.getFrameObj("navigateBottom").updateView(param["bId"],param["nId"],param["MV"],param["nV"]);
		}
		
		switchTree(param["nV"] != VIEW_OVERVIEW);
		switchActiveGraphic(param["nV"] != VIEW_OVERVIEW);

		if(param["nV"] == VIEW_OVERVIEW)
			topFrame.setUrl("container", "overview" + fV["PQ"].value + ".jsp" + params);
		else
		if(param["nV"] == "AG") // aktive Grafik
		{
			topFrame.setUrl("container", "activeGraphics.jsp" + params);
			topFrame.setUrl("OWFdyn","getActiveGraphicsData.jsp" + params + "&forceAllDOs=true");
		}
		else
			// change to configuration
			topFrame.setUrl("container", "attribute.jsp" + params + "&EXPGROUP=" + expandGroup);
			
			
		fV["VIEW"].value = param["nV"];
		
		// 20060203; tsc; #35530; if for any reason the view changed, update buttons (different buttons for config view and overview)
		if (topFrame.getFrameObj("head").currentView!=param["nV"])
			topFrame.getFrameObj("head").updateView(param["nV"]);
		
		topFrame.setUrl("discount", "discount.jsp?RT=" + new Date().getTime());
		
		// reload OWFdyn frame
		if(param["nV"] != "AG") // aktive Grafik
			topFrame.setUrl("OWFdyn","getActiveGraphicsData.jsp?RT=" + new Date().getTime());

		/* attribut (if attribute id was changed or the frame is empty)
		if(fV["ID"] != param["ID"])
		{
			//topFrame.setUrl("attribute", "attribute.jsp" + params); // + "&W=" + topFrame.getFrameHeight("attribute"));
			topFrame.setUrl("container", "attribute.jsp" + params); // + "&W=" + topFrame.getFrameHeight("attribute"));
		}*/

		// values
		//topFrame.setUrl("values","values.jsp" + params);
		// customizedpages?
		/*if("_ui1" == cCO.ui)
		{
			topFrame.setUrl("tkCode", "customizedpages/tkCode.jsp?RT=" + new Date().getTime());
		}*/

		// update form
		fV["ID"].value = param["ID"];
		fV["BACK"].value = param["bId"];
		fV["NEXT"].value = param["nId"];
		fV["CONF"].value = param["status"];
		fV["VIEW"].value = param["nV"];
		fV["GROUP"].value = param["cG"];
		
		// reset values
		fV["IDVAL"].value = "";
		fV["COUNT"].value = "";
		fV["NEXTATT"].value = "";
		fV["NEXTIDX"].value = "0"; // default value
		fV["EVALNEXT"].value = "";
		fV["SAVE"].value = 0;
		fV["RESET"].value = 0;
		
	}
	else
	{
		setTimeout("handleAttribute({ID:'" + param["ID"] + "',bId:'" + param["bId"] + "',nId:'" + param["nId"] + "',sb_left:'" + param["sb_left"] + "',sb_right:'" + param["sb_right"] + "',status:'" + param["status"] + "',NEXTIDX:'" + param["NEXTIDX"] + "',nV:'" + param["nV"] + "',scroll:'" + param["scroll"] + "',cG:'" + param["cG"] + "',MV:'" + param["MV"] + "'})",100);
	}
}


// change view between configuration view und overview
// ******************************************
function changeView(nextView)
{
	var fV = topFrame.document.forms["sessionData"].elements;
	var currentView = fV["VIEW"].value;
	if (typeof(nextView)!="string" || nextView=="")
	{
		if (currentView==VIEW_CONFIGURATION)
			nextView = VIEW_OVERVIEW;
		else
			nextView = VIEW_CONFIGURATION;
	}
	
	fV["VIEW"].value = nextView;
	switchTree(nextView!=VIEW_OVERVIEW);
	switchActiveGraphic(nextView!=VIEW_OVERVIEW);
	
	if (nextView == VIEW_OVERVIEW)
	{
		topFrame.setUrl("container", "overview" + fV["PQ"].value + ".jsp?CONF=" + fV["CONF"].value + "&RT=" + new Date().getTime());
		topFrame.getFrameObj("views").updateView(fV["VIEW"].value, fV["GROUP"].value);
		topFrame.getFrameObj("navigateTop").updateView(null,null);
		// 20070122; tsc; navigateBottom needs to know the current view
		topFrame.getFrameObj("navigateBottom").updateView(null, null, null, fV["VIEW"].value);		
	}
	else
		submitForm();
	
	//20050822 slz; button-frame has to be reloaded
	topFrame.getFrameObj("head").updateView(fV["VIEW"].value);
}

function switchTree(visible)
{
	var fApp = topFrame.getFrameObj("application");
	if (fApp)
	{
		if (visible && fApp.leftPane.style.visibility == "hidden")
		{
			fApp.leftPane.style.visibility = "";
			fApp.splitterTreeMain.element.style.visibility = "";
			if (topFrame.getFrameObj("activeGraphics") && fApp.activeGraphicPanePosition=="RIGHT")
				fApp.rightPane.style.width = fApp.frameElement.offsetWidth - (fApp.leftPane.offsetWidth + fApp.splitterTreeMain.thickness) - (fApp.activeGraphicPane.offsetWidth + fApp.splitterActiveGraphic.thickness);
			else
				fApp.rightPane.style.width = fApp.frameElement.offsetWidth - (fApp.leftPane.offsetWidth + fApp.splitterTreeMain.thickness);
			fApp.rightPane.style.left = fApp.leftPane.offsetWidth + fApp.splitterTreeMain.thickness;
			if (topFrame.getFrameObj("activeGraphics") && fApp.activeGraphicPanePosition=="LEFT_BOTTOM" || fApp.activeGraphicPanePosition=="LEFT_TOP")
				topFrame.getFrameObj("activeGraphics").frameElement.style.display = "";
		}
		else
		if (!visible && fApp.leftPane.style.visibility != "hidden")
		{
			fApp.rightPane.style.width = fApp.rightPane.offsetWidth + fApp.leftPane.offsetWidth + fApp.splitterTreeMain.thickness;
			fApp.rightPane.style.left = 0;
			fApp.leftPane.style.visibility = "hidden";
			fApp.splitterTreeMain.element.style.visibility = "hidden";
			if (topFrame.getFrameObj("activeGraphics") && fApp.activeGraphicPanePosition=="LEFT_BOTTOM" || fApp.activeGraphicPanePosition=="LEFT_TOP")
				topFrame.getFrameObj("activeGraphics").frameElement.style.display = "none";
		}
	}
}

function switchActiveGraphic(visible)
{
	var fGr = topFrame.getFrameObj("application");
	if (fGr.activeGraphicPanePosition=="LEFT_BOTTOM" || fGr.activeGraphicPanePosition=="LEFT_TOP")
		return; // hier hängt Verhalten vom Verhalten des Baumes ab, daher erfolgt Behandlung in switchTree
		
	var _activeGraphicPane = null;
	if (topFrame.getFrameObj("activeGraphics")!=null)
		_activeGraphicPane = topFrame.getFrameObj("activeGraphics").frameElement;
	
	if (fGr && _activeGraphicPane!=null)
	{
		if (visible && _activeGraphicPane.style.display == "none")
		{
			switch (fGr.activeGraphicPanePosition)
			{
				/*
				* TOP und BOTTOM: sind außerhalb des per Reiter umgeschalteten Bereichs, sollten also nicht verschwinden
				case "TOP":
					_activeGraphicPane.style.display = "";
					if (fGr.rightPane && fGr.rightPane.style)
					{
						fGr.rightPane.style.height = (fGr.rightPane.offsetHeight / 2);
						fGr.rightPane.style.top = (fGr.rightPane.offsetHeight / 2) + "px";
					}
					break;
				case "BOTTOM":
					_activeGraphicPane.style.display = "";
					if (fGr.rightPane && fGr.rightPane.style)
						fGr.rightPane.style.height = (fGr.rightPane.offsetHeight * 2)
					break;
				*/
				case "RIGHT_TOP":
				case "RIGHT_BOTTOM":
					if (fGr.rightPane && typeof(fGr.rightPane.switchActiveGraphic)=="function")
						fGr.rightPane.switchActiveGraphic(true);
					break;
			}
		}
		else
		if (!visible && _activeGraphicPane.style.display != "none")
		{
			switch (fGr.activeGraphicPanePosition)
			{
				/*
				* TOP und BOTTOM: sind außerhalb des per Reiter umgeschalteten Bereichs, sollten also nicht verschwinden
				case "TOP":
					_activeGraphicPane.style.display = "";
					if (fGr.rightPane && fGr.rightPane.style)
					{
						fGr.rightPane.style.height = (fGr.rightPane.offsetHeight * 2);
						fGr.rightPane.style.top = "0px";
					}
					break;
				case "BOTTOM":
					_activeGraphicPane.style.display = "";
					if (fGr.rightPane && fGr.rightPane.style)
						fGr.rightPane.style.height = (fGr.rightPane.offsetHeight * 2)
					break;
				*/
				case "RIGHT_TOP":
				case "RIGHT_BOTTOM":
					if (fGr.rightPane && typeof(fGr.rightPane.switchActiveGraphic)=="function")
						fGr.rightPane.switchActiveGraphic(false);
					break;
			}
		}
	}
}


// navigate 
// ******************************************
function changeAttribute(goBack)
{
	var fV = topFrame.document.forms["sessionData"].elements;
	// view?
	if(goBack)
		fV["ID"].value = fV["BACK"].value;
	else
		fV["ID"].value = fV["NEXT"].value;
	submitForm();
}

// 
// *****************************************************************
function handleAction(cName, optParam)
{
	switch (cName)
	{
		case "B_PRINT":
			showWindow('printPage.jsp?RT=' + new Date().getTime(),cName,{width:800, height:600, resize:true, menu:true, scroll:true});
			break; 
		case "B_MAIL":
			showWindow('mailframe.jsp?BODY=modul&RT=' + new Date().getTime(), cName, {width:500, height:500});
			break; 
		case "B_OFFER":
			showWindow('offer.jsp?RT=' + new Date().getTime(), 'B_OFFER', {width:400, height:120});
			break; 
		case "B_OFFER_DOC":
			showWindow('generateOffer.jsp?RT=' + new Date().getTime()+optParam, 'B_OFFER_DOC', {width:820, height:620, resize:true});
			break; 
		case "B_UPLOAD": 
			showWindow('upload.jsp?RT=' + new Date().getTime(), cName, {width:400, height:130, resize: false});			
			break; 
		case "B_ADDRESS": 
			showWindow('addressForm.jsp?RT=' + new Date().getTime(), cName, {width:470, height:360, resize: false});			
			break; 
		case "B_TEST_COMPARE": 
			showWindow('testCompare.jsp?RT=' + new Date().getTime(), cName, {width:640, height:480, resize: true, menu:true, scroll:true});
			break; 
		case "B_SAVE":
			alert(functionTxt["B_SAVE"]);
			// 20051212; tsc; save using jsp; see #33547
			setUrl("dyn", 'save.jsp?RT=' + new Date().getTime());
			break; 
		case "B_INFO":
			showWindow('fs_userinfo.html?RT=' + new Date().getTime(), cName, {width:400, height:590, resize: false});
			break; 
		case "B_NEW":
			restart(-1,"RESET=TRUE");
			break;
		case "B_DOCUMENT": 
			showWindow(escape(optParam), cName, {width:800, height:600, resize: true, menu:true, scroll:true});			
			break; 
		case "B_DOCUMENT_LIST": 
			showWindow('documents.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:200, height:15, resize: false, scroll:true});
			break; 
		case "B_CHARACTERISTICS": 
			showWindow('characteristics.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:250, height:50, resize: false, scroll:true});
			break; 
		case "B_ALTERNATIVES": 
			showWindow('alternatives.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:450, height:50, resize: false, scroll:true});
			break; 
		case "CONFLICT": 
			showWindow('conflicts.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "CONFLICT_PACKAGES": 
			showWindow('packageConflicts.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "B_MODULE_INFO": 
			showWindow('moduleInfo.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "SHOW_LOAD_ERRORS": 
			showWindow('loadErrors.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "SET_BY_RULE": 
			showWindow('setByRule.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "REQUIRES": 
			showWindow('requirements.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "EXTERNALPRICES": 
			showWindow('upload_externalprices.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:250, height:150, resize: false, scroll:true});
			break; 
		case "COMPARE_MODULES": 
			showWindow('compareModules.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:500, height:150, resize: false, scroll:true});
			break; 
		case "ADD_CUSTOM_MODULE": 
			showWindow('addCustomModule.jsp?'+((optParam!=null && typeof(optParam)!="undefined")?'CID='+escape(optParam)+"&":'')+'RT=' + new Date().getTime(), cName, {width:200, height:150, resize: false, scroll:true});
			break; 
		// case "B_OFFER_SHORT"?
	}
	return false; 
}
function showWindow(url, wKey, settings)
{
	switch(wKey)
	{
		case "ADD_CUSTOM_MODULE": 
		case "COMPARE_MODULES":
		case "EXTERNALPRICES":
		case "REQUIRES":
		case "CONFLICT":
		case "CONFLICT_PACKAGES":
		case "SHOW_LOAD_ERRORS":
		case "SET_BY_RULE":
		case "B_ALTERNATIVES": 
		case "B_CHARACTERISTICS": 
		case "B_MODULE_INFO":
		case "B_DOCUMENT_LIST":
		case "B_UPLOAD":
		case "B_ADDRESS":
		case "B_MAIL":
		case "B_OFFER":
			showGlasspane();

			var cWidth = settings.width? settings.width: 100;
			var cHeight = settings.height? settings.height: 100;
			var wInfo = getFrameInfo(self);
			var cTop = (wInfo.offsetHeight - cHeight)/2;
			var cLeft = (wInfo.offsetWidth - cWidth)/2;
			
			var obj = topFrame.document.getElementById("f_dyn");
			with (obj.style)
			{
				top = cTop;
				left = cLeft;
				zIndex = 30001;
				width = cWidth + "px";
				height = cHeight + "px";
				borderTopColor = "#89A0C6";
				borderLeftColor = "#89A0C6";
				display = "block";
				visibility = "visible";
			}
			obj.src = url;
			break;
		case "B_TEST_COMPARE":
		case "B_DOCUMENT":
		case "B_PRINT":
		case "B_INFO":
		case "B_OFFER_DOC":
		case "ADDWIN":
			/* "ADDWIN" is used by user defined links! */
			if(wKey == "ADDWIN" && settings)
			{
				if(settings.height)
					settings.height += 20;
				if(settings.width)
					settings.width += 20;
			}
			// real window
			var w = extWindows[wKey];	
			if (w && !w.closed)
				w.close();	
			extWindows[wKey] = openWindow(url, wKey, settings);
			break;
	}
}

function hideWindow()
{
	var obj = topFrame.document.getElementById("f_dyn");
	if (obj!=null && typeof(obj)=="object")
	{
		obj.src = "empty.html";
		// 20061017; tsc; #39693: safari 1.2.3 crashes (really!) when hiding the dialog frame via display="none"; so we use visibility="hidden" instead.
		obj.style.visibility = "hidden";
	}
	hideGlasspane();
}

// 
// *****************************************************************
function removeWindows()
{
	var w = null;
	for(var i in extWindows)
	{
		w = extWindows[i];

		if (w && !w.closed)
			w.close();
	}
}
// *****************************************************************
function refresh() 
{
	// cause view refresh
	topFrame.document.forms["sessionData"].elements["VIEW"].value = VIEW_CONFIGURATION;

	// switch to overview
	topFrame.setUrl("tree", "tree.jsp?VIEW=" + VIEW_OVERVIEW + "&RT="+ new Date().getTime());
}

// add/ update field value in specified form
// *****************************************************************
function addEntryToForm(id, value)
{
	var form = topFrame.document.forms["sessionData"];
	var entry = form.elements[id];
	if(typeof entry == "undefined" && value != null)
	{
		entry = topFrame.document.createElement('INPUT');
		entry.type = "hidden";
		entry.name = id;
		// 20061017; tsc; #39693: added id
		entry.id = id;
		form.appendChild(entry);
		/*
		20061017; tsc; nachdem id oben angef?gt wurde, funktioniert jetzt auch form.entryName; workaround kann also raus
		// workaround: nach appendChild wird das entry nicht gefunden mit form.entryName
		form.elements[id] = entry;
		*/
	}
	if(entry)
		entry.value = value;
}

// remove field from specified form
// *****************************************************************
function removeFieldFromForm(id)
{
	var form = topFrame.document.forms["sessionData"];
	var entry = form.elements[id];
	if(typeof entry != "undefined" && entry != null)
	{
		form.removeChild(entry);
	}
}

/* ************************************************************ */
	//  click tree
	// ******************************************
	function notifyView(cId)
	{
		if(cId)
		{
			// register only
			topFrame.document.forms["sessionData"].elements["TREE_ID"].value = cId;
		}
	}
	
	function checkView(cId)
	{
		if(cId)
		{
			// update + submit form
			topFrame.document.forms["sessionData"].elements["ID"].value = cId;
			if (topFrame.document.forms["sessionData"].elements["VIEW"].value==VIEW_OVERVIEW)
				topFrame.document.forms["sessionData"].elements["VIEW"].value = VIEW_CONFIGURATION;
			topFrame.submitForm();
		}
	}
	
	// toggle group in tree
	// ******************************************
	function toggle(id)
	{
		var trContent = document.getElementById("c_" + id);
		var tButton = document.getElementById("t_" + id);
		if (trContent!=null)
		{
			if (trContent.className)
			{
				// open group
				trContent.className = "";
				tButton.src=imgT.src;
				if(ttCloseGroup)
					tButton.title=ttCloseGroup;
				topFrame.addEntryToForm("HIDE_" + id,"")
			}
			else
			{
				trContent.className = "noContent";
				tButton.src=imgTC.src;
				if(ttOpenGroup)
					tButton.title=ttOpenGroup;
				topFrame.addEntryToForm("HIDE_" + id,"true");
			}
		}
	}

	function resizeTreeWidth()
	{
		var fWidth = getFrameInfo(self).offsetWidth;
		if(fWidth > 80)
		{
			var wTitle = (fWidth - 65) + "px";
			var wContainer = (fWidth - 20) + "px";
			var divs = document.getElementsByTagName("DIV");
			for (i=0; i<divs.length; i++)
			{
				cDiv = divs[i];
				if(cDiv.className=="groupTitle")
					cDiv.style.width=wTitle;
				else if(cDiv.className=="group_container")
					cDiv.style.width=wContainer;
			}
		}
	}

	//
	function expandGroupAttribute(gId, cId)
	{
		if(gId == null)
			// reset
			topFrame.addEntryToForm("GID","");
		else
		{
			topFrame.addEntryToForm("GID", gId);
			topFrame.addEntryToForm("ID", cId);
		}
		submitForm();
	}
	//
	function getAbsoluteOffset(win, element, jPos, withParentFrames, alerts)
	{
		// offset inside the frame
		while (element)
		{
			//if (alerts)
			//	alert("adding offset from element: "+element.tagName+": "+element.id+", "+element.name+" (top: "+element.offsetTop+", left: "+element.offsetLeft+")");
			jPos.top  += element.offsetTop;
			jPos.left += element.offsetLeft + 1;
			if (element.style && element.style.position=="absolute" || element.style.position=="fixed")
				element = null;
			else
				element = element.offsetParent;
		}
		if(withParentFrames)
		{
			// offset caused by parent frames
			element = win;
			while(element && element.name && element.name != topFrame.name)
			{
				os = element.parent.document.getElementById(element.name);
				if(os)
				{
					var osPos = {top:os.offsetTop, left:os.offsetLeft};
					if (os.offsetParent && os.offsetParent!=element.parent) // 20070122; tsc; IFrames can be inside normal elements, too; so we need to add those elements' positions
						osPos = getAbsoluteOffset(element, os.offsetParent, osPos, false, alerts);
			//if (alerts)
			//	alert("adding offset from window-element: "+os.tagName+": "+os.id+", "+os.name+" (top: "+osPos.top+", left: "+osPos.left+") (from parentElement "+os.offsetParent.tagName+"'"+os.offsetParent.id+"': top: "+(osPos.top-os.offsetTop)+", left: "+(osPos.left-os.offsetLeft)+")");
					jPos.top += osPos.top;
					jPos.left += osPos.left + 1;
				}
				jPos.top   -= element.document.body.scrollTop;
				jPos.left  -= element.document.body.scrollLeft;
				element = element.parent;
			}
		}
		return jPos;
	}
	
	// scrollable table:
	function resizeContainer(dWidth, dHeight, dPadding)
	{
		var obj = document.getElementById("scrollContainer");
		var fInfo = getFrameInfo(self);
		if(obj)
		{
			if(dHeight)
			{
				// 20050830; tsc; "-3" = fix for broken vertical scrollbar in result list when resizing
				maxH= fInfo.offsetHeight-dHeight - 3;
				cH = document.getElementById("tableContent").offsetHeight;
				if(maxH > 0)
					obj.style.height=((cH+5)<maxH?cH+5:maxH)+ "px";
			}
			obj.style.overflow="auto";
			if(dWidth && dWidth < document.body.clientWidth)
			{
				//obj.style.width=(fInfo.offsetWidth-dWidth)+ "px";
				//alert("resizing to "+(document.body.clientWidth));
				obj.style.width=(document.body.clientWidth)+ "px";
			}

			var tbl = document.getElementById("tableContent");
			var tblHead = document.getElementById("tableHeader");
			if (tbl && tblHead)
			{
				if (obj.offsetHeight<obj.scrollHeight)
				{
					tblHead.rows[0].cells[tblHead.rows[0].cells.length-1].style.paddingRight = "24px";
					if (tblHead.rows.length>1)
						tblHead.rows[1].cells[tblHead.rows[1].cells.length-1].style.paddingRight = "24px";
				}
				else
				{
					tblHead.rows[0].cells[tblHead.rows[0].cells.length-1].style.paddingRight = (dPadding+2)+"px";
					if (tblHead.rows.length>1)
						tblHead.rows[1].cells[tblHead.rows[1].cells.length-1].style.paddingRight = (dPadding+2)+"px";
				}
			}
			setTimeout("adjustHeadWidth(" + dPadding + ");",4);
		}
	}

	function adjustHeadWidth(dPadding)
	{
		var tbl = document.getElementById("tableContent");
		var cells = tbl.rows[0].cells;
		for (var i = 0; i < cells.length; i++)
		{
			var newWidth = cells[i].offsetWidth-dPadding;
			if (newWidth<0)
				newWidth = 0;
			if(document.getElementById("hd" + i) != null)
				document.getElementById("hd" + i).style.width = newWidth;
		}
	}
	// end scrollable table
	
	
/* ---------------------------------------------------------------------------------- */
/*
	20071213; tsc; #43918
	creates a copy of the originalFunction including new code at the specified position.
	typical usage: myFunction = injectIntoFunction(myFunction, "\n x += 6;", "var x = document.body.scrollHeight;", false);
	params:
		originalFunction: 	the reference to the function
		newCode:			the code to inject
		position:			can be "POS_BEGIN", "POS_END", or any part of the code (newCode will be injected after or instead of that marker)
							NOTE: only the first occurrence will be used!
		replaceMarker:		if true, the marker-Code will be replaced with the new code
							if false, the new code will be injected after the marker code
*/
function injectIntoFunction(originalFunction, newCode, position, replaceMarker)
{
	var originalCode = originalFunction.toString();
	var modifiedCode = null;
	var marker = null;
	if (position=="POS_BEGIN")
		marker = "{";
	else
	if (position=="POS_END")
		marker = "}";
	else
		marker = position;

	// special case: look for last occurrence of marker and inject code before that
	if (position=="POS_END")
	{
		markerPos = originalCode.lastIndexOf(marker);
		if (markerPos>-1)
			modifiedCode = originalCode.substring(0, markerPos-1) + newCode + originalCode.substring(markerPos); 
	}
	else
	if (marker!=null)
	{
		var markerPos = originalCode.indexOf(marker);
		if (markerPos>-1)
		{
			var startPos = markerPos + marker.length;
			if (replaceMarker && position!="POS_BEGIN" && position!="POS_END")
				startPos = markerPos;
				
			modifiedCode = originalCode.substring(0, startPos) + newCode + originalCode.substring(markerPos+marker.length);
		}
	}
	//alert (modifiedCode);
	
	if (modifiedCode!=null)
	{
		var openingBracketPos = modifiedCode.indexOf("(");
		var closingBracketPos = modifiedCode.indexOf(")", openingBracketPos);
		var params = modifiedCode.substring(openingBracketPos+1, closingBracketPos);
		var body = modifiedCode.substring(modifiedCode.indexOf("{")+1,modifiedCode.lastIndexOf("}"));
		return new Function(params, body);
	}
	return originalFunction;
}
	
