text: // IP cust --- INSERT
  
  // --- expand state management
  function minimize(updh) {
  	if (retrieveSi(srcdoc, "StatAppBrlyUsrDetail", "srefIxBrlyVExpstate") == "mind") return;
  
  	setSi(srcdoc, "StatAppBrlyUsrDetail", "srefIxBrlyVExpstate", "mind");
  
  	// change container heights
  	getRecwnd().changeHeight("Detail", 30, updh);
  	doc.getElementById("tdSide").setAttribute("height", "30");
  	doc.getElementById("Detail_side").setAttribute("height", "30");
  	doc.getElementById("Detail_cont").setAttribute("height", "30");
  
  	// change content
  	doc.getElementById("Detail_side").src = "./PnlBrlyUsrDetail_aside.html";
  	doc.getElementById("Detail_cont").src = "./PnlBrlyUsrDetail_a.html";
  };
  
  function regularize() {
  	if (retrieveSi(srcdoc, "StatAppBrlyUsrDetail", "srefIxBrlyVExpstate") == "regd") return;
  
  	setSi(srcdoc, "StatAppBrlyUsrDetail", "srefIxBrlyVExpstate", "regd");
  
  	// change content (container heights in refreshBD)
  	doc.getElementById("Detail_side").src = "./PnlBrlyUsrDetail_bside.html";
  	doc.getElementById("Detail_cont").src = "./PnlBrlyUsrDetail_b.html";
  };
  
  // --- view initialization and refresh
  function initA() {
  	if (!doc) return;
  
  	sidedoc = doc.getElementById("Detail_side").contentDocument;
  	contdoc = doc.getElementById("Detail_cont").contentDocument;
  	hdrdoc = null;
  	contcontdoc = null;
  	ftrdoc = null;
  
  	initCpt(contdoc, "Cpt", retrieveTi(srcdoc, "TagBrlyUsrDetail", "Cpt"));
  
  	refreshA();
  };
  
  function initBD(bNotD) {
  	if (!doc) return;
  
  	sidedoc = doc.getElementById("Detail_side").contentDocument;
  	contdoc = doc.getElementById("Detail_cont").contentDocument;
  	contcontdoc = contdoc.getElementById("Detail_cont").contentDocument;
  	ftrdoc = contdoc.getElementById("Detail_ftr").contentDocument;
  
  	// IP initBD --- BEGIN
  	initCpt(contcontdoc, "CptPrs", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptPrs"));
  	initCpt(contcontdoc, "CptSrf", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptSrf"));
  	initCpt(contcontdoc, "CptUsg", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptUsg"));
  	initCpt(contcontdoc, "CptSte", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptSte"));
  	refreshPup(contcontdoc, srcdoc, "PupSte", "", "FeedFPupSte", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupSte"), retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupSteActive"), false);
  	initCpt(contcontdoc, "CptLcl", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptLcl"));
  	refreshPup(contcontdoc, srcdoc, "PupLcl", "", "FeedFPupLcl", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupLcl"), retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupLclActive"), false);
  	initCpt(contcontdoc, "CptUlv", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptUlv"));
  	refreshPup(contcontdoc, srcdoc, "PupUlv", "", "FeedFPupUlv", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupUlv"), retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupUlvActive"), false);
  	initCpt(contcontdoc, "CptPwd", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptPwd"));
  	initCpt(contcontdoc, "CptFky", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptFky"));
  	initCpt(contcontdoc, "CptCmt", retrieveTi(srcdoc, "TagBrlyUsrDetail", "CptCmt"));
  	// IP initBD --- END
  
  	refreshBD(bNotD);
  };
  
  function init() {
  	var srefIxBrlyVExpstate = retrieveSi(srcdoc, "StatAppBrlyUsrDetail", "srefIxBrlyVExpstate");
  
  	if (srefIxBrlyVExpstate == "mind") {
  		initA();
  	} else if (srefIxBrlyVExpstate == "regd") {
  		initBD(true);
  	} else if (srefIxBrlyVExpstate == "detd") {
  		initBD(false);
  	};
  };
  
  function refreshA() {
  };
  
  function refreshBD(bNotD) {
  	if (!contcontdoc) return;
  
  	var height = 367; // full cont height
  
  	// IP refreshBD.vars --- BEGIN
  	var TxtPrsActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "TxtPrsActive") == "true");
  	var ButPrsViewAvail = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "ButPrsViewAvail") == "true");
  	var ButPrsViewActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "ButPrsViewActive") == "true");
  
  	var TxtSrfActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "TxtSrfActive") == "true");
  
  	var TxtUsgActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "TxtUsgActive") == "true");
  	var ButUsgViewAvail = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "ButUsgViewAvail") == "true");
  	var ButUsgViewActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "ButUsgViewActive") == "true");
  
  	var PupJstActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupJstActive") == "true");
  	var ButJstEditAvail = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "ButJstEditAvail") == "true");
  
  	var PupSteActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupSteActive") == "true");
  
  	var PupLclActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupLclActive") == "true");
  
  	var PupUlvActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "PupUlvActive") == "true");
  
  	var TxfPwdActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "TxfPwdActive") == "true");
  
  	var TxfFkyActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "TxfFkyActive") == "true");
  
  	var TxfCmtActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "TxfCmtActive") == "true");
  
  	var ButSaveActive = (retrieveSi(srcdoc, "StatShrBrlyUsrDetail", "ButSaveActive") == "true");
  	var mytd, first;
  	// IP refreshBD.vars --- END
  
  	// IP refreshBD --- BEGIN
  	if ((ButPrsViewAvail == !contcontdoc.getElementById("ButPrsView"))) {
  		mytd = contcontdoc.getElementById("rdynPrs");
  		clearElem(mytd);
  
  		first = true;
  
  		if (ButPrsViewAvail) {
  			if (first) first = false;
  			else mytd.appendChild(contcontdoc.createTextNode("\u00a0"));
  			mytd.appendChild(makeImgBut(contcontdoc, "ButPrsView", "icon/view"));
  		};
  	};
  
  	refreshTxt(contcontdoc, "TxtPrs", retrieveCi(srcdoc, "ContInfBrlyUsrDetail", "TxtPrs"));
  
  	if (ButPrsViewAvail) refreshButicon(contcontdoc, "ButPrsView", "icon/view", ButPrsViewActive, false);
  
  	refreshTxt(contcontdoc, "TxtSrf", retrieveCi(srcdoc, "ContInfBrlyUsrDetail", "TxtSrf"));
  
  	if ((ButUsgViewAvail == !contcontdoc.getElementById("ButUsgView"))) {
  		mytd = contcontdoc.getElementById("rdynUsg");
  		clearElem(mytd);
  
  		first = true;
  
  		if (ButUsgViewAvail) {
  			if (first) first = false;
  			else mytd.appendChild(contcontdoc.createTextNode("\u00a0"));
  			mytd.appendChild(makeImgBut(contcontdoc, "ButUsgView", "icon/view"));
  		};
  	};
  
  	refreshTxt(contcontdoc, "TxtUsg", retrieveCi(srcdoc, "ContInfBrlyUsrDetail", "TxtUsg"));
  
  	if (ButUsgViewAvail) refreshButicon(contcontdoc, "ButUsgView", "icon/view", ButUsgViewActive, false);
  
  	if ((ButJstEditAvail == !contcontdoc.getElementById("ButJstEdit"))) {
  		mytd = contcontdoc.getElementById("rdynJst");
  		clearElem(mytd);
  
  		first = true;
  
  		if (ButJstEditAvail) {
  			if (first) first = false;
  			else mytd.appendChild(contcontdoc.createTextNode("\u00a0"));
  			mytd.appendChild(makeImgBut(contcontdoc, "ButJstEdit", "icon/edit"));
  		};
  	};
  
  	refreshPup(contcontdoc, srcdoc, "PupJst", "s", "FeedFPupJst", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupJst"), PupJstActive, false);
  
  	contcontdoc.getElementById("PupSte").value = retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupSte");
  
  	contcontdoc.getElementById("PupLcl").value = retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupLcl");
  
  	contcontdoc.getElementById("PupUlv").value = retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "numFPupUlv");
  
  	refreshTxf(contcontdoc, "TxfPwd", "s", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "TxfPwd"), TxfPwdActive, false, true);
  
  	refreshTxft(contcontdoc, "TxfFky", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "TxfFky"), TxfFkyActive, false, true);
  
  	refreshTxft(contcontdoc, "TxfCmt", retrieveCi(srcdoc, "ContIacBrlyUsrDetail", "TxfCmt"), TxfCmtActive, false, true);
  
  	refreshButicon(ftrdoc, "ButSave", "icon/save", ButSaveActive, false);
  	// IP refreshBD --- END
  
  	getRecwnd().changeHeight("Detail", height+26, true);
  	doc.getElementById("tdSide").setAttribute("height", "" + (height+26));
  	doc.getElementById("Detail_side").setAttribute("height", "" + (height+26));
  	doc.getElementById("Detail_cont").setAttribute("height", "" + (height+26));
  	sidedoc.getElementById("tdFlex").setAttribute("height", "" + (height+26-30));
  	contdoc.getElementById("tdCont").setAttribute("height", "" + height);
  	contdoc.getElementById("Detail_cont").setAttribute("height", "" + height);
  };
  
  function refresh() {
  	var srefIxBrlyVExpstate = retrieveSi(srcdoc, "StatAppBrlyUsrDetail", "srefIxBrlyVExpstate");
  
  	if (srefIxBrlyVExpstate == "mind") {
  		refreshA();
  	} else if (srefIxBrlyVExpstate == "regd") {
  		refreshBD(true);
  	} else if (srefIxBrlyVExpstate == "detd") {
  		refreshBD(false);
  	};
  };
  
  // --- event handlers
  function handleLoad() {
  	scrJref = location.search.substr(location.search.indexOf("scrJref=")+8);
  
  	doc = document;
  	srcdoc = doc.getElementById("Detail_src").contentDocument;
  
  	var str = serializeDpchApp("DpchAppBrlyInit", scrJref);
  	sendReq(str, doc, handleDpchAppInitReply, true);
  };
  
  // --- specific event handlers for app controls
  
  function handleButMinimizeClick() {
  	minimize(true);
  };
  
  function handleButRegularizeClick() {
  	regularize(true);
  };
  
  // --- generalized event handlers for app controls
  
  // --- generalized event handlers for shared controls
  
  function handleButClick(ctlsref) {
  	var str = serializeDpchAppDo(srcdoc, "DpchAppBrlyUsrDetailDo", scrJref, ctlsref + "Click");
  	sendReq(str, doc, handleDpchAppDataDoReply);
  };
  
  function handleButCrdopenClick(ctlsref) {
  	var str = serializeDpchAppDo(srcdoc, "DpchAppBrlyUsrDetailDo", scrJref, ctlsref + "Click");
  	sendReq(str, doc, handleDpchAppDoCrdopenReply);
  };
  
  function handleButDlgopenClick(ctlsref) {
  	var str = serializeDpchAppDo(srcdoc, "DpchAppBrlyUsrDetailDo", scrJref, ctlsref + "Click");
  	sendReq(str, doc, handleDpchAppDoDlgopenReply);
  };
  
  function handlePupChange(_doc, ctlsref, size) {
  	var elem = _doc.getElementById(ctlsref);
  
  	elem.setAttribute("class", "pup" + size + "mod");
  	setCi(srcdoc, "ContIacBrlyUsrDetail", "numF" + ctlsref, elem.value);
  
  	var str = serializeDpchAppData(srcdoc, "DpchAppBrlyUsrDetailData", scrJref, "ContIacBrlyUsrDetail");
  	sendReq(str, doc, handleDpchAppDataDoReply);
  };
  
  function handleTxfKey(_doc, ctlsref, size, evt) {
  	var elem = _doc.getElementById(ctlsref);
  
  	elem.setAttribute("class", "txf" + size + "mod");
  
  	if (evt.keyCode == 13) {
  		setCi(srcdoc, "ContIacBrlyUsrDetail", ctlsref, elem.value);
  
  		var str = serializeDpchAppData(srcdoc, "DpchAppBrlyUsrDetailData", scrJref, "ContIacBrlyUsrDetail");
  		sendReq(str, doc, handleDpchAppDataDoReply);
  
  		return false;
  	};
  
  	return true;
  };
  
  function handleTxfChange(_doc, ctlsref, size) {
  	var elem = _doc.getElementById(ctlsref);
  
  	elem.setAttribute("class", "txf" + size + "mod");
  
  	setCi(srcdoc, "ContIacBrlyUsrDetail", ctlsref, elem.value);
  
  	var str = serializeDpchAppData(srcdoc, "DpchAppBrlyUsrDetailData", scrJref, "ContIacBrlyUsrDetail");
  	sendReq(str, doc, handleDpchAppDataDoReply);
  };
  
  function handleTxftKey(_doc, ctlsref, evt) {
  	var elem = _doc.getElementById(ctlsref);
  
  	elem.setAttribute("class", "txfmod");
  
  	return true;
  };
  
  function handleTxftChange(_doc, ctlsref) {
  	var elem = _doc.getElementById(ctlsref);
  
  	elem.setAttribute("class", "txfmod");
  
  	setCi(srcdoc, "ContIacBrlyUsrDetail", ctlsref, elem.value.replace(/\n/g, ";"));
  
  	var str = serializeDpchAppData(srcdoc, "DpchAppBrlyUsrDetailData", scrJref, "ContIacBrlyUsrDetail");
  	sendReq(str, doc, handleDpchAppDataDoReply);
  };
  
  // --- server interaction
  function mergeDpchEngData(dom) {
  	var mask = [];
  
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "ContIacBrlyUsrDetail", srcdoc)) mask.push("contiac");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "ContInfBrlyUsrDetail", srcdoc)) mask.push("continf");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "FeedFPupJst", srcdoc)) mask.push("feedFPupJst");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "FeedFPupLcl", srcdoc)) mask.push("feedFPupLcl");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "FeedFPupSte", srcdoc)) mask.push("feedFPupSte");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "FeedFPupUlv", srcdoc)) mask.push("feedFPupUlv");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "StatAppBrlyUsrDetail", srcdoc)) mask.push("statapp");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "StatShrBrlyUsrDetail", srcdoc)) mask.push("statshr");
  	if (updateSrcblock(dom, "DpchEngBrlyUsrDetailData", "TagBrlyUsrDetail", srcdoc)) mask.push("tag");
  
  	return mask;
  };
  
  function handleDpchEng(dom, dpch) {
  	if (dpch == "DpchEngBrlyUsrDetailData") {
  		mergeDpchEngData(dom);
  		refresh();
  	};
  };
  
  function handleDpchAppInitReply() {
  	var dom, blk;
  
  	if (doc.req.readyState == 4) {
  		dom = doc.req.responseXML;
  
  		blk = retrieveBlock(dom, "//brly:*");
  		if (blk) {
  			if (blk.nodeName == "DpchEngBrlyUsrDetailData") {
  				mergeDpchEngData(dom);
  				init();
  
  				getRecwnd().setInitdone("Detail");
  			};
  		};
  	};
  };
  
  function handleDpchAppDataDoReply() {
  	var dom, blk;
  
  	if (doc.req.readyState == 4) {
  		dom = doc.req.responseXML;
  
  		// check dispatch type
  		blk = retrieveBlock(dom, "//brly:*");
  
  		if (blk) {
  			if (blk.nodeName == "DpchEngBrlyConfirm") {
  				// do nothing
  
  			} else if (blk.nodeName == "DpchEngBrlyUsrDetailData") {
  				mergeDpchEngData(dom);
  				refresh();
  			};
  		};
  	};
  };
  
  function handleDpchAppDoCrdopenReply() {
  	var dom, blk;
  
  	var accepted, _scrJref, sref;
  
  	if (doc.req.readyState == 4) {
  		dom = doc.req.responseXML;
  
  		blk = retrieveBlock(dom, "//brly:*");
  
  		if (blk) {
  			if (blk.nodeName == "DpchEngBrlyConfirm") {
  				accepted = retrieveValue(dom, "//brly:DpchEngBrlyConfirm/brly:accepted");
  				_scrJref = retrieveValue(dom, "//brly:DpchEngBrlyConfirm/brly:scrJref");
  				sref = retrieveValue(dom, "//brly:DpchEngBrlyConfirm/brly:sref");
  
  				if (accepted == "true") window.open("/web/" + sref + "/" + sref + ".html?scrJref=" + _scrJref, "_blank");
  
  			} else if (blk.nodeName == "DpchEngBrlyAlert") {
  				getCrdwnd().showAlr(retrieveValue(dom, "//brly:DpchEngBrlyAlert/brly:scrJref"),
  						retrieveBlock(dom, "//brly:DpchEngBrlyAlert/brly:ContInfBrlyAlert"),
  						retrieveBlock(dom, "//brly:DpchEngBrlyAlert/brly:FeedFMcbAlert"));
  			};
  		};
  	};
  };
  
  function handleDpchAppDoDlgopenReply() {
  	var dom, blk;
  
  	var accepted, _scrJref, sref;
  
  	if (doc.req.readyState == 4) {
  		dom = doc.req.responseXML;
  
  		blk = retrieveBlock(dom, "//brly:*");
  
  		if (blk) {
  			if (blk.nodeName == "DpchEngBrlyConfirm") {
  				accepted = retrieveValue(dom, "//brly:DpchEngBrlyConfirm/brly:accepted");
  				_scrJref = retrieveValue(dom, "//brly:DpchEngBrlyConfirm/brly:scrJref");
  				sref = retrieveValue(dom, "//brly:DpchEngBrlyConfirm/brly:sref");
  
  				if ((accepted == "true") && (sref != "")) getCrdwnd().showDlg(sref, _scrJref);
  			};
  		};
  	};
  };
  