
var EPCM={
OTHER : 0,
MSIE : 1,
NETSCAPE: 2,
MOZILLA : 21,
OPERA : 3,
NOKIA : 4,
UP : 5,
ERICSSON: 6,
MSPIE : 7,
PALM : 8,
OTHER_PLATFORM : 0,
NT_PLATFORM : 1,
WIN_PLATFORM : 2,
MAC_PLATFORM : 3,
LINUX_PLATFORM : 4,
WAP_PLATFORM : 5,
PDA_PLATFORM : 6,
_private:{
id: "EPCM",
envRef: window,
version: null,
level: null,
instanceId: null,
prtVersion: null,
uaType: null,
uaVersion: null,
uaPlatform: null,
domainFull: document.domain,
isDynamicTop: false,
refDynamicTop: null,
compList: null,
dbgException: false,
implDB :null,
implDSM :null,
dirty: false,
uipmode: null,
uipWinFeatures: null,
uipPortalPath: null,
uipPopupComp : null,
uipPopupCompSize : null,
uipPopupMsgNN: null}
}
EPCM.init=function( cfg ){
var priv=this._private;
if( priv.version != null)return;
if (cfg.Level>=2 && (!navigator.javaEnabled())){
cfg.Level=1;}

priv.version=cfg.Version;
priv.level=cfg.Level;
priv.instanceId=cfg.InstanceId;
priv.uaType=cfg.UAType;
priv.uaVersion=cfg.UAVersion;
priv.uaPlatform=cfg.UAPlatform;
priv.prtVersion=cfg.PortalVersion;
priv.compList=new Array();
priv.implDB=(cfg.Level<2) ? this.DB1 : this.DB2;
EPCM.subscribeEvent("urn:com.sapportals.portal:user","logoff",EPCM._private.clearClientDataBag );
if(document.domain == EPCM.getRelaxedDomain()){
var WID=this.getUniqueWindowId();}

priv.isDynamicTop=cfg.DynamicTop;
this.calculateDynamicTop();
priv.uipmode=cfg.UIPMode;
priv.uipWinFeatures=cfg.UIPWinFeatures;
priv.uipPortalPath=cfg.UIPPortalPath;
priv.uipPopupComp=cfg.UIPPopupComp;
priv.uipPopupCompSize=cfg.UIPPopupCompSize;
priv.uipPopupMsgNN=cfg.UIPPopupMsgNN;
priv.dbgException=cfg.DBGException}
EPCM.getUAType=function(){
return this._private.uaType;}
EPCM.getUAVersion=function(){
return this._private.uaVersion;}
EPCM.getUAPlatform=function(){
return this._private.uaPlatform;}
EPCM.getPortalVersion=function(){
return this._private.prtVersion;}
EPCM.getVersion=function(){
return this._private.version;}
EPCM.getLevel=function(){
return this._private.level;}
EPCM.getInstanceId=function(){
return this._private.instanceId;}
EPCM.getUniqueWindowId=function(){
var winid=null;
try{
winid=this.getSAPTop().name;
if( (typeof(winid) !="string") || (winid.length == 0) || (winid.indexOf("WID") != 0)){
this.getSAPTop().name="WID"+(new Date()).getTime();}
return this.getSAPTop().name;
}catch (ex){
return null;}
}
EPCM.getSAPTop=function(){
return (this._private.isDynamicTop) ? this._private.refDynamicTop : top;}
EPCM.calculateDynamicTop=function(){
var priv=EPCM._private;
priv.refDynamicTop=window;
var testedFrame=window;
try{
while( testedFrame !=top && testedFrame.parent !=null ){
try{
if( testedFrame.parent.EPCM != null ){
priv.refDynamicTop=testedFrame.parent;}
} catch(ex1){}
testedFrame=testedFrame.parent;}
} catch(ex2){}}
EPCM.trace=function(cat,msg,paramset){}
EPCM.relaxDocumentDomain=function(){
var newDomain=this.getRelaxedDomain();
if( newDomain != document.domain ){
document.domain=newDomain;}
this.calculateDynamicTop();}
EPCM.getNotRelaxedDomain=function(){
return this._private.domainFull;}
EPCM.getRelaxedDomain=function(){
return this.getRelaxed(this._private.domainFull);}
EPCM.getRelaxed=function( input ){
if (input.search(/^\d+\.\d+\.\d+\.\d+$/) >=0 ){
return input;}
var lnDotPos=input.indexOf( "." );
return (lnDotPos >= 0) ? input.substr( lnDotPos + 1): input;}
EPCM.setDirty=function(val ){
this._private.dirty=( val == true );}
EPCM.getDirty=function( ){
return this._private.dirty;}
EPCM.isWorkProtectDirtyInquiry=function(){
return true;}
EPCM.getGlobalDirty=function( ){
var result=false;
switch(this._private.uipmode){
case "0":
case "1":
case "3":
var laEPCM=this._private.getAdjacentEPCM();
for (var idx=0; idx < laEPCM.length && !result; idx++){
result=result || laEPCM[idx].getDirty();}

var retArray=EPCM.raiseEvent("urn:com.sapportals.portal:workprotect", "inquiryProtection", null, null, true);
for (var i=0; i< retArray.length && !result; i++){
if( typeof retArray[i] == "boolean"){
result=result || retArray[i];}
}
return result;
case "2":
return false;
default:
return false;}
return result;}
EPCM.popupOnUnsavedData=function (){
var retVal;
if(EPCM.getUAType() == EPCM.MSIE ){
retVal="" + window.showModalDialog( this._private.uipPopupComp, null, this._private.uipPopupCompSize );
switch(retVal){
case "NEWWIN": return "NEWWIN";
case "DESKTOP": return "DESKTOP";
default : return "CANCEL";}
} else{
retVal=confirm(this._private.uipPopupMsgNN);
return (retVal) ? "NEWWIN" : "CANCEL";}
}
EPCM.doNavigate=function( target, mode, winfeatures, winname, history,targetTitle, context,postBody){
var isSubscribed=this.isSubscribed("urn:com.sapportals:navigation","Navigate" );
var openNewWin;
var windowId=EPCM.getUniqueWindowId();
if (mode == null || mode == 0){
if(this._private.uipmode == "3"){
if(EPCM.getGlobalDirty() ){
switch( EPCM.popupOnUnsavedData() ){
case "NEWWIN": openNewWin=true; mode=2; break;
case "DESKTOP": openNewWin=false; break;
default: return false;}
}}
else{

openNewWin=EPCM.getGlobalDirty() || (! isSubscribed);
mode=2;}
} else{

openNewWin=true;}

if(targetTitle != null && targetTitle != ""){
targetTitle=encodeURI(targetTitle);}

if(openNewWin){
if (mode == null) mode=2;
if (winfeatures == null) winfeatures=EPCM._private.uipWinFeatures;
if (winname == null) winname="";
if (isSubscribed){
EPCM.raiseEvent("urn:com.sapportals:navigation", "Navigate",{
target: target,
mode:mode,
winname: winname,
winfeatures: winfeatures,
context: context,
windowId: windowId,
postBody: postBody,
targetTitle: targetTitle} );
return false;
}else{
var qpos=target.indexOf("?");
var targetQuery="?NavigationTarget="
if(qpos < 1 ){
targetQuery += escape(target);
}else{
targetQuery += escape(target.substring(0,qpos)) + "&" + target.substr(qpos+1);}
if (context != undefined && context != null)
targetQuery += "&NavigationContext=" + escape(context);
targetQuery += "&windowId=" + windowId;
window.open( EPCM._private.uipPortalPath + targetQuery, winname, winfeatures);
return false;}
} else{

var historyModeParam="";
if(history && history != null && history != ""){
historyModeParam="&HistoryMode=" + history;}

var targetTitleParam="";
if(targetTitle && targetTitle != null && targetTitle != ""){
targetTitleParam="&TarTitle="+targetTitle;}
var contextParam="";
if(context && context != null && context != ""){
contextParam="&NavigationContext="+context;}
var windowIdQuery="";
if (windowId && windowId != null && windowId != ""){
windowIdQuery += "&windowId=" + windowId;}
var finalTarget=target + historyModeParam + targetTitleParam + contextParam + windowIdQuery;
var separ=finalTarget.indexOf("?");
var separ2=finalTarget.indexOf("&");
if(separ2 != -1 && separ == -1){
finalTarget=finalTarget.substr(0,separ2) + "?" + finalTarget.substr(separ2+1);}
EPCM.raiseEvent('urn:com.sapportals:navigation','Navigate', {target:finalTarget, postBody:postBody, Type:"InPlace"});
return false;}
}
EPCM.doRelativeNavigate=function( basenodename, levelsup, pathnameslist, mode, winfeatures, winname, history, addParams, targetTitle, context,postBody){
if(! basenodename || basenodename == null || basenodename == ""){
try{
basenodename=this.getSAPTop().gHistoryFrameworkObj.GetActiveTrackingEntryValue().URL;}
catch(e){}}

var isSubscribed=this.isSubscribed("urn:com.sapportals:navigation","RelativeNavigate" );
var openNewWin;
var windowId=EPCM.getUniqueWindowId();
if (mode == null || mode == 0){
if(this._private.uipmode == "3"){
if(EPCM.getGlobalDirty() ){
switch( EPCM.popupOnUnsavedData() ){
case "NEWWIN": openNewWin=true; break;
case "DESKTOP": openNewWin=false; break;
default: return false;}
}}
else{

openNewWin=EPCM.getGlobalDirty() || (! isSubscribed);}
} else{

openNewWin=true;}

if(targetTitle != null && targetTitle != ""){
targetTitle=encodeURI(targetTitle);}

if(openNewWin){
if (mode == null) mode=2;
if (winfeatures == null) winfeatures=EPCM._private.uipWinFeatures;
if (winname == null) winname="";
if (context == null) context="";
if (isSubscribed ){
EPCM.raiseEvent("urn:com.sapportals:navigation", "RelativeNavigate",{
basenodename: basenodename,
levelsup: levelsup,
pathnameslist: pathnameslist,
mode: mode,
winfeatures: winfeatures,
winname: winname,
windowId: windowId,
history: history,
addParams: addParams,
targetTitle: targetTitle,
context: context,
postBody: postBody} );
return false;
}else{
var targetQuery="";
if(basenodename != "undefined" && basenodename != null){
targetQuery += "?RelativeNavBase=" +escape(basenodename);}
else{

return false;}
if(levelsup != "undefined" && levelsup != null){
targetQuery += "&RelativeLevelsup=" + escape(levelsup);}
if(pathnameslist != "undefined" && pathnameslist != null){
targetQuery += "&RelativePathlist=" + escape(pathnameslist);}
if(context && context != null && context != ""){
targetQuery += "&NavigationContext="+context;}
targetQuery += "&windowId=" + windowId;
if(addParams != "undefined" && addParams != null){
targetQuery += "&" + escape(addParams);}
window.open( EPCM._private.uipPortalPath + targetQuery, winname, winfeatures);
return false;}
} else{

EPCM.raiseEvent("urn:com.sapportals:navigation", "RelativeNavigate",{
basenodename: basenodename,
levelsup: levelsup,
pathnameslist: pathnameslist,
mode: mode,
winfeatures: winfeatures,
winname: winname,
windowId:windowId,
history: history,
addParams: addParams,
targetTitle: targetTitle,
context: context,
postBody:postBody} );
return false;}
}
EPCM.doObjBasedNavigate=function( systemAlias, businessObjName, objValue, operation ){
EPCM.raiseEvent('urn:com.sapportals:navigation','ObjBasedNavigate',{
systemAlias: systemAlias,
businessObjName: businessObjName,
objValue: objValue,
operation: operation} );}
EPCM._private.cookieParam=function( name, value ){
return (value != null)? name + "=" + value + ";": "";}
EPCM._private.setCookie=function(name, value, expires, path, domain, secure){
if((name != null) && (name != "")){
if (value == null) value="";
document.cookie=this.cookieParam( name, escape( value)) +
this.cookieParam( "expires", expires)+
this.cookieParam( "path", path)+
this.cookieParam( "domain", domain)+((secure == true)? "secure": "" );}
}
EPCM._private.getCookieArray=function(){
var laResult= new Array();
if (document.cookie != ""){
var laCookieList=document.cookie.split( "; " );
for (var i=0; i < laCookieList.length; i++){
var lsNameValue=laCookieList[i].split( "=" );
switch (lsNameValue.length){
case 1: laResult[unescape( lsNameValue[0] )]="";
break;
case 2: laResult[unescape( lsNameValue[0] )]=unescape( lsNameValue[1] );
break;
default: break;}
}}
return laResult;}
EPCM._private.getCookie=function(name){
var lsCookie=this.getCookieArray()[name];
if(lsCookie == "deleted")lsCookie=null;
return lsCookie;}
EPCM._private.deleteCookie=function( name, path, domain ){
var loPast=new Date();
loPast.setYear( 1971 );
this.setCookie( name, "deleted", loPast.toGMTString(), path, domain );}
EPCM.storeClientData=function(pUrn, pName, pValue){
EPCM._private.implDB.storeClientData(pUrn, pName, pValue);}
EPCM.loadClientData=function(pUrn, pName){
return EPCM._private.implDB.loadClientData(pUrn, pName);}
EPCM.deleteClientData=function(pUrn, pName){
EPCM._private.implDB.deleteClientData(pUrn, pName);}
EPCM._private.clearClientDataBag=function(){
EPCM._private.implDB.clearClientDataBag();}
EPCM._private.printClientDataBag=function(){
EPCM._private.implDB.printClientDataBag();}
EPCM.DB1=new Object;
EPCM.DB1.MCOOKIE_PREFIX="SAPPORTALSDB";
EPCM.DB1.MCOOKIE_PARTS=10;
EPCM.DB1.MCOOKIE_SPLIT=4000;
EPCM.DB1.MSG_TOTAL_LIMIT_EXCEEDED="Error: Client Databag (Total data limit exceeded)";
EPCM.DB1.MSG_LIMIT_EXCEEDED="Error: Client Databag (Single data limit exceeded)";
EPCM.DB1.MSG_WRONG_TYPE="Error: Client Databag (Unsupported data type)";
EPCM.DB1.getHashName=function(pUrn, pName){
return "" + pUrn + "&" + pName;}

EPCM.DB1.getMultiCookieDomain=function(){
return (document.domain.indexOf(".")<0) ? null : document.domain;}
EPCM.DB1.setMultiCookie=function(parts){
for(var i=0; i< this.MCOOKIE_PARTS; i++){
var lsName="" + this.MCOOKIE_PREFIX + i;
if (i < parts.length){
EPCM._private.setCookie(lsName, parts[i], null, "/", this.getMultiCookieDomain() );}
else{

EPCM._private.deleteCookie(lsName, "/", this.getMultiCookieDomain() );}
}
}
EPCM.DB1.getMultiCookie=function(){
var laCookies=EPCM._private.getCookieArray();
var lsResult="";
for(var i=0; i< this.MCOOKIE_PARTS; i++){
var lsName="" + this.MCOOKIE_PREFIX + i;
var lsCookie=laCookies[lsName];
if (lsCookie != null && lsCookie != "" && lsCookie !="deleted"){
var lsSepar=(lsResult.length>0)? "; " : "";
lsResult += lsSepar+lsCookie;}
}
return lsResult;}
EPCM.DB1.clearMultiCookie=function(){
for(var i=0; i< this.MCOOKIE_PARTS; i++){
var lsName="" + this.MCOOKIE_PREFIX + i;
EPCM._private.deleteCookie(lsName, "/", this.getMultiCookieDomain());}
}
EPCM.DB1.serializeData=function( dataList ){
var lsString="";
var lsSepar;
for( var key in dataList ){
lsSepar=(lsString.length >0)? "; " : "";
if (dataList[key]!=null){
lsString += lsSepar + escape(key) + "=" + escape(dataList[key])}
}
return lsString;}
EPCM.DB1.serializeDataParts=function( dataList ){
var lsSepar="; "
var lsSeparEsc=escape(lsSepar);
var laParts=new Array();
var laPartsEsc=new Array()
var lsElem;
var lsElemEsc;
var isDistributed;
for( var key in dataList ){
if(dataList[key]==null){
continue;}
lsElem=escape(key) + "=" + escape(dataList[key]);
lsElemEsc=escape(lsElem);
xlen=lsElemEsc.length;
isDistributed=false;
for(var i=0; i<laPartsEsc.length;i++){
if (( laPartsEsc[i].length + xlen)< this.MCOOKIE_SPLIT){
laParts[i] += ((laParts[i].length>0) ? lsSepar : "")+ lsElem;
laPartsEsc[i] += ((laPartsEsc[i].length>0) ? lsSeparEsc : "")+ lsElemEsc;
isDistributed=true;
break;}
}
if (! isDistributed){
if (xlen < this.MCOOKIE_SPLIT){
laParts[i]=lsElem;
laPartsEsc[i]=lsElemEsc;
}else{
alert(this.MSG_LIMIT_EXCEEDED);}
}}
if (laParts.length > this.MCOOKIE_PARTS){
alert(this.MSG_TOTAL_LIMIT_EXCEEDED);
laParts.length=this.MCOOKIE_PARTS;}
return laParts;}
EPCM.DB1.deserializeData=function( data ){
var laResult=new Array();
if(data!=null && data != ""){
var laDataList=data.split( "; " );
for (var i=0; i < laDataList.length; i++){
var lsNameValue=laDataList[i].split( "=" );
switch (lsNameValue.length){
case 1:
laResult[unescape( lsNameValue[0] )]="";
break;
case 2:
laResult[unescape( lsNameValue[0] )]=unescape( lsNameValue[1] );
break;
default:
break;}
}}
return laResult;}

EPCM.DB1.storeClientData=function(pUrn, pName, pValue){
var lsType=typeof pValue;
if (pValue != null){
if (lsType == "number" || lsType == "string" || lsType =="boolean"){
pValue="" + pValue;}
else{
alert(this.MSG_WRONG_TYPE);
return;}
}
var lsDatabag=this.getMultiCookie();
var loArray=this.deserializeData(lsDatabag);
var xName=this.getHashName(pUrn,pName);
loArray[xName]=pValue;
var lsDatabagParts=this.serializeDataParts(loArray);
this.setMultiCookie(lsDatabagParts);}
EPCM.DB1.loadClientData=function(pUrn, pName){
var lsDatabag=this.getMultiCookie();
var loArray=this.deserializeData(lsDatabag);
var xName=this.getHashName(pUrn,pName);
return loArray[xName];}
EPCM.DB1.deleteClientData=function(pUrn, pName){
this.storeClientData(pUrn,pName,null);}
EPCM.DB1.clearClientDataBag=function(){
this.clearMultiCookie();}
EPCM.DB1.printClientDataBag=function(){
var lsDatabag=this.getMultiCookie();
var loArray=this.deserializeData(lsDatabag);
var result="";
for(var key in loArray){
result += key + "=" + loArray[key] + "\n";}
alert("DataBag content:\n" + result)}
EPCM.DB2=new Object;
EPCM.DB2.storeClientData=function(pUrn, pName, pValue){
var loApplet=EPCM._private.getApplet();
var xUrn="" + pUrn;
var xName="" + pName;
if (pValue == null){
loApplet.getDataBag().removeObject(xUrn, xName);}
else{
var lsType=typeof pValue;
if (lsType == "number"){
loApplet.getDataBag().putNumber (xUrn, xName, pValue);}
else if (lsType == "string"){
loApplet.getDataBag().putString (xUrn, xName, pValue);}
else if (lsType == "boolean"){
loApplet.getDataBag().putBoolean(xUrn, xName, pValue);}
else{
loApplet.getDataBag().putObject (xUrn, xName, pValue);}
}}
EPCM.DB2.loadClientData=function(pUrn, pName){
var loApplet=EPCM._private.getApplet();
var xUrn="" + pUrn;
var xName="" + pName;
var lsType=loApplet.getDataBag().getObjectType(xUrn, xName);
var loResult=loApplet.getDataBag().getObject (xUrn, xName);
var Result=null;
if (lsType == "class java.lang.Double" ){
Result=parseFloat(loResult);}
else if (lsType == "class java.lang.Boolean"){
Result=loResult == "true";}
else if (lsType == "class java.lang.String"){
Result="" + loResult;}
else{
Result=loResult;}
return Result;}
EPCM.DB2.deleteClientData=function(pUrn, pName){
var loApplet=EPCM._private.getApplet();
var xUrn="" + pUrn;
var xName="" + pName;
loApplet.getDataBag().removeObject(xUrn, xName);}
EPCM.DB2.clearClientDataBag=function(){
var loApplet=EPCM._private.getApplet();
loApplet.getDataBag().removeAllObjects();}
EPCM.DB2.printClientDataBag=function(){
var loApplet=EPCM._private.getApplet();
loApplet.getDataBag().showContent(null);}
EPCM._private.getHTTP=function(pathURL, queryParam){
if(EPCM.getLevel()<2)return null;
var loApplet=this.getApplet();
var lsType=loApplet.getDataChannel().getHTTP(new String(pathURL), new String(queryParam));
return lsType;}
EPCM._private.postHTTP=function(pathURL, queryParam){
if(EPCM.getLevel()<2)return null;
var loApplet=this.getApplet();
var lsType=loApplet.getDataChannel().postHTTP(new String(pathURL), new String(queryParam));
return lsType;}
EPCM.EventObject=function(eventNamespace, eventName, dataObject, sourceId ){
this.eventNamespace=eventNamespace;
this.eventName=eventName;
this.dataObject=dataObject;
this.sourceId=sourceId;}
EPCM._private.eGlobHistory=new Array();
EPCM._private.eLocHistory=new Array();
EPCM._private.getEvtGlobTable=function(){
var topEPCM=this.getTopmostEPCM();
return topEPCM._private.eGlobHistory;}
EPCM._private.getEvtLocTable=function(){
return this.eLocHistory;}
EPCM._private.optimizeEvtGlobTable=function(){
var topEPCM=this.getTopmostEPCM();
var oldTab=topEPCM._private.eGlobHistory;
var newTab=new Array();
var activeKeys="";
var allEPCM=this.getAdjacentEPCM();
for (var i=0; i< allEPCM.length; i++){
activeKeys += allEPCM[i].getInstanceId() + ", ";}
for(var tabKey in oldTab){
if( activeKeys.indexOf(oldTab[tabKey]) >=0){
newTab[tabKey]=oldTab[tabKey];}
}
topEPCM._private.eGlobHistory=newTab;}
EPCM.subscribeEvent=function( nameSpace, eventName, handlerRef, methodName ){
function FunctionListener( fref){
this.fref=fref;
this.call=function(data){ return this.fref( data );}
}
function MethodListener( oref, mname){
this.oref=oref;
this.method=mname;
this.call=function(data){ return this.oref[this.method]( data );}
}
function FrameMethodListener(fname, mname){
this.frame=fname
this.method=mname;
this.call=function(data){ return window.frames[this.frame][this.method]( data );}
}
function isFrameMethodDuplicity(olist, fname, mname){
for(var i=0; i< olist.length; i++){
var xobj=olist[i];
if(xobj.frame != null && xobj.method != null
&& xobj.frame == fname && xobj.method == mname ){
return true}
}
return false;}

var lsEvtId=nameSpace + "&" + eventName;
var loSys=this._private;
if (loSys.eList == null) loSys.eList=new Array();
if (loSys.eList[lsEvtId] == null) loSys.eList[lsEvtId]=new Array();
var laListener=loSys.eList[lsEvtId];
var eListener=null;
if(("function" == typeof handlerRef) && (arguments.length == 3)){
eListener=new FunctionListener( handlerRef );}
else if(("object" == typeof handlerRef) && (arguments.length == 4)){
for(var i=0; i<frames.length;i++){
if (handlerRef == frames[i]){
if (isFrameMethodDuplicity(laListener,frames[i].name, methodName )) return;
eListener=new FrameMethodListener(frames[i].name, methodName);
break;}
}
if (eListener == null){
eListener=new MethodListener( handlerRef, methodName );}
} else{
var polluter=caller;
alert( "EPCM ERROR\n" +
"\tIllegal argument type in method EPCM.subscribeEvent()" +
"\tThe function was called from " + polluter.toString() );}

laListener[laListener.length]=eListener;}
EPCM.subscribeEventReliable=function( nameSpace, eventName, handlerRef, methodName ){
function FunctionListener( fref){
this.fref=fref;
this.call=function(data){ return this.fref( data );}
}
function MethodListener( oref, mname){
this.oref=oref;
this.method=mname;
this.call=function(data){ return this.oref[this.method]( data );}
}
function FrameMethodListener(fname, mname){
this.frame=fname
this.method=mname;
this.call=function(data){ return window.frames[this.frame][this.method]( data );}
}
function isFrameMethodDuplicity(olist, fname, mname){
for(var i=0; i< olist.length; i++){
var xobj=olist[i];
if(xobj.frame != null && xobj.method != null
&& xobj.frame == fname && xobj.method == mname ){
return true}
}
return false;}

var lsEvtId=nameSpace + "&" + eventName;
var loSys=this._private;
if (loSys.eList == null) loSys.eList=new Array();
if (loSys.eList[lsEvtId] == null) loSys.eList[lsEvtId]=new Array();
var laListener=loSys.eList[lsEvtId];
var eListener=null;
if(("function" == typeof handlerRef) && (arguments.length == 3)){
eListener=new FunctionListener( handlerRef );}
else if(("object" == typeof handlerRef) && (arguments.length == 4)){
for(var i=0; i<frames.length;i++){
if (handlerRef == frames[i]){
if (isFrameMethodDuplicity(laListener,frames[i].name, methodName )) return;
eListener=new FrameMethodListener(frames[i].name, methodName);
break;}
}
if (eListener == null){
eListener=new MethodListener( handlerRef, methodName );}
} else{
var polluter=caller;
alert( "EPCM ERROR\n" +
"\tIllegal argument type in method EPCM.subscribeEventReliable()" +
"\tThe function was called from " + polluter.toString() );}

laListener[laListener.length]=eListener;
var subscriberKey=nameSpace + "&" + eventName;
var subscriberKeyPrefix=nameSpace + "&";
this._private.optimizeEvtGlobTable();
var decodeTab=new Array();
var allEPCM=this._private.getAdjacentEPCM();
for (var i=0; i< allEPCM.length; i++){
decodeTab[allEPCM[i].getInstanceId()]=allEPCM[i];}

var globTab=this._private.getEvtGlobTable();
for(var globTabKey in globTab){
if(eventName == "*"){
if (globTabKey.indexOf(subscriberKeyPrefix) != 0) continue;
}else{
if (globTabKey != subscriberKey) continue;}

var senderEPCM=decodeTab[globTab[globTabKey]];
if (senderEPCM != null){
var locTabEntry=senderEPCM._private.getEvtLocTable()[globTabKey];
if (locTabEntry !=null){
var locEventObject=locTabEntry;
try{

eListener.call( locEventObject );}
catch( e){
if (EPCM._private.dbgException){
if(!confirm("Exception in EPCM.raiseEvent occured.\nContinue ?")) throw(e);}
}}

}
}}
EPCM.raiseEvent=function( nameSpace, eventName, dataObject, sourceId, returnResult){
var lsEvtId=nameSpace + "&" + eventName;
var lsEvtAll=nameSpace + "&*";
var loEvtObj=new EPCM.EventObject( nameSpace, eventName, dataObject, sourceId );
var laEPCM=this._private.getAdjacentEPCM();
var laResult=null;
var lbCollect=(returnResult == true);
if (lbCollect){
laResult=new Array();}

for (var idx=0; idx < laEPCM.length; idx++){
if (laEPCM[idx]._private.eList == null) continue;
var laListener=laEPCM[idx]._private.eList[lsEvtId];
if(laListener != null){
this.eventDistribute( laListener, loEvtObj, laResult );}

laListener=laEPCM[idx]._private.eList[lsEvtAll];
if(laListener != null){
this.eventDistribute( laListener, loEvtObj, laResult );}

}
this._private.getEvtLocTable()[lsEvtId]= new EPCM.EventObject( nameSpace,
eventName,
dataObject,
sourceId );
this._private.getEvtGlobTable()[lsEvtId]= this.getInstanceId();
if (lbCollect){
return laResult;}
else{
return;}
}
EPCM.raiseEventLocal=function( nameSpace, eventName, dataObject, sourceId, returnResult){
var lsEvtId=nameSpace + "&" + eventName;
var lsEvtAll=nameSpace + "&*";
var loEvtObj=new EPCM.EventObject( nameSpace, eventName, dataObject, sourceId );
var leList=this._private.eList;
var laResult=null;
var lbCollect=(returnResult == true);
if (lbCollect){
laResult=new Array();}
if(leList!= null){

var laListener=leList[lsEvtId];
if(laListener != null){
this.eventDistribute( laListener, loEvtObj, laResult );}

laListener=leList[lsEvtAll];
if(laListener != null){
this.eventDistribute( laListener, loEvtObj, laResult );}

}
if (lbCollect){
return laResult;}
else{
return;}
}
EPCM.isSubscribed=function( eventSpace, eventName){
var isSubscribed=false;
var lsEvtId=eventSpace + '&' + eventName;
var lsEvtAll=eventSpace +'&*';
var laEPCM=this._private.getAdjacentEPCM();
for (var idx=0; idx < laEPCM.length; idx++){
if (laEPCM[idx]._private.eList == null) continue;
var laListener=laEPCM[idx]._private.eList[lsEvtId];
if(laListener != null){
isSubscribed=true;
break;}
laListener=laEPCM[idx]._private.eList[lsEvtAll];
if(laListener != null){
isSubscribed=true;
break;}
}
return isSubscribed;}
EPCM.eventDistribute=function( consumers, eventObject, resultArray){
var isRetValCollect=(resultArray != null);
var eListener
var retVal;
for (var idx in consumers){

eListener=consumers[idx];
retVal=null;
try{

retVal=eListener.call( eventObject );}
catch( e){
if (EPCM._private.dbgException){
if(!confirm("Exception in event distribution occured.\nContinue ?")) throw(e);}
}
if(isRetValCollect && retVal != null){
resultArray[resultArray.length++]=retVal;}
}
}
EPCM.DSM=new Object();
EPCM.DSM.init=function( cfg ){
EPCM._private.implDSM=EPCM.DSM3;
EPCM.subscribeEvent("urn:com.sapportals.portal:browser","preunload",function(){ EPCM.DSM.terminateAll(false);}
);
EPCM.subscribeEvent("urn:com.sapportals.portal:user", "logoff",function(){ EPCM.DSM.terminateAll(true);}
);
EPCM._private.implDSM.init( cfg );
EPCM._private.implDSM.initDebugger();
EPCM.subscribeEvent("urn:com.sapportals.portal.dsm:Notification", "InitDebugger",function(){ EPCM.DSM.initDebugger();} );}
EPCM.DSM.initDebugger=function(){
EPCM._private.implDSM.initDebugger();}
EPCM.DSM.processSession=function( si,frameRef ){
EPCM._private.implDSM.log("Client: SessionInfo Received and Processed \r\n" + this.formatSession(si), true );
this.popupReceipt(si);
if(si.lastSessCmd=="USR_OPEN" || si.lastSessCmd == null || si.lastSessCmd == ""){
EPCM._private.implDSM.registerSession(si);
this.notifyMonitor(si);}
if(si.lastSessCmd=="SRV_ERROR" || si.lastSessCmd=="SRV_CLOSE"){
EPCM._private.implDSM.removeSessionByGUSID(si.GUSID)
this.notifyMonitor(si);
if(si.redirectURL!=null && si.redirectURL!="" ){
if(frameRef!=null && si.redirectURL.indexOf("!")>0 && si.redirectURL.indexOf("~")>0 ){
frameRef.location.href=si.redirectURL;}
else{

location.href=si.redirectURL;}
}}
}
EPCM.DSM.notifyMonitor=function(si){
EPCM.raiseEvent("urn:com.sapportals.portal.dsm:Notification","ReceiveSessInfo", si);}
EPCM.DSM.notifyMonitorKey=function(skey){
EPCM.raiseEvent("urn:com.sapportals.portal.dsm:Notification","ReceiveSessInfoKey", skey);}
EPCM.DSM.registerSession=function(si){
EPCM._private.implDSM.log("Client: SessionInfo Registered \r\n" + this.formatSession(si), true );
EPCM._private.implDSM.registerSession(si);}
EPCM.DSM.registerSessionKey=function(skey){
EPCM._private.implDSM.log("Client: SessionInfoKey Registered \r\n" + skey, true );
this.popupReceiptKey(skey);
EPCM._private.implDSM.registerSessionKey(skey);
this.notifyMonitorKey(skey);}
EPCM.DSM.removeSessionByGUSID=function (GUSID){
EPCM._private.implDSM.removeSessionByGUSID(GUSID);}
EPCM.DSM.removeSessionKey=function (skey){
EPCM._private.implDSM.removeSessionKey(skey);}
EPCM.DSM.terminateAll=function(isLogoff){
EPCM._private.implDSM.terminateAll(isLogoff);}
EPCM.DSM.terminateByGUSID=function(GUSID,isLogoff){
EPCM._private.implDSM.terminateByGUSID(GUSID,isLogoff);}
EPCM.DSM.terminateByKey=function(skey,isLogoff){
EPCM._private.implDSM.terminateByKey(skey,isLogoff);}
EPCM.DSM.getAllToArray=function(){
return EPCM._private.implDSM.getAllToArray();}
EPCM.DSM.getAllKeysToArray=function(){
return EPCM._private.implDSM.getAllKeysToArray();}
EPCM.DSM.getSize=function(){
return EPCM._private.implDSM.getSize();}
EPCM.DSM.getKeysSize=function(){
return EPCM._private.implDSM.getKeysSize();}
EPCM.DSM.log=function( logString, isDebugControlled ){
var isDC=( isDebugControlled != null)? isDebugControlled : true;
return EPCM._private.implDSM.log( logString, isDC );}
EPCM.DSM.popupReceipt=function(si){
if (EPCM._private.implDSM.PopupReceipt){
alert("Session Info Object Received:" + "\n\n" + this.formatSession(si));}
}
EPCM.DSM.popupReceiptKey=function(skey){
if (EPCM._private.implDSM.PopupReceipt){
alert("Session Info Key Received:" + "\n\n" + skey );}
}
EPCM.DSM.formatSession=function( si ){
var result="";
for(var item in si ){
result += item + "=" + si[ item]+ "\r\n";}
return result;}
EPCM.DSM3=new Object();
EPCM.DSM3.SessStore=new Array();
EPCM.DSM3.KeyStore=new Array();
EPCM.DSM3.TermString ="";
EPCM.DSM3.SerPropString ="";
EPCM.DSM3.SerKeyString ="";
EPCM.DSM3.SERKEY_SEPAR ="&";
EPCM.DSM3.SERPROP_SEPAR ="#";
EPCM.DSM3.SSIPAIR_SEPAR ="&";
EPCM.DSM3.SSIKEYVAL_SEPAR="=";
EPCM.DSM3.LogoffStarted=false;
EPCM.DSM3.PendingUnload=false;
EPCM.DSM3.TerminatorUrl=null;
EPCM.DSM3.FormName="";
EPCM.DSM3.Debug=false;
EPCM.DSM3.PopupReceipt=false;
EPCM.DSM3.WinForced=false;
EPCM.DSM3.WinParamsHidden="height=100,width=200,resizable,left=20042,screenX=20042,top=0,screenY=0";
EPCM.DSM3.WinParamsDebug="height=400,width=600,resizable,menubar,scrolbars";
EPCM.DSM3.EmptyAutoScript="javascript:document.write('<html><body>Closing sessions ...</body></html>');document.close();setTimeout('window.close()',15000)"
EPCM.DSM3.EmptyUrlFrame="";
EPCM.DSM3.EmptyUrlWindow=""
EPCM.DSM3.TargetNameIframe ="DsmTargetIframe";
EPCM.DSM3.TargetNameWindow ="DmsTargetWindow";
EPCM.DSM3.KeepAliveActive=false;
EPCM.DSM3.KeepAliveDelta=60 * 13 * 1000;
EPCM.DSM3.KeepAliveStopAfter=60 * 60 * 12 * 1000;
EPCM.DSM3.KeepAliveTimer=null;
EPCM.DSM3.KeepAliveInitStamp=null;
EPCM.DSM3.KeepAliveCookieName="DSMKeepAliveStamp"
EPCM.DSM3.init=function( cfg ){
this.TerminatorUrl=cfg.TerminatorURL;
this.FormName=cfg.DSMFormGuid;
var smartEmptyUrl=(EPCM.getUAType() == EPCM.MSIE) ? this.EmptyAutoScript : "about:blank"
this.EmptyUrlWindow=(window.location.protocol == "http:") ? smartEmptyUrl : cfg.WinEmptyUrl;
this.EmptyUrlFrame=(window.location.protocol == "http:") ? "about:blank" : cfg.WinEmptyUrl;
this.WindowForced=cfg.TargetForceWindow
this.KeepAliveActive=cfg.KeepAliveActive;
this.KeepAliveDelta=cfg.KeepAliveDelta * 1000;
this.KeepAliveStopAfter=cfg.KeepAliveStopAfter * 1000;
this.keepAliveInitTimer();}
EPCM.DSM3.initDebugger=function(){
if (EPCM.getLevel() == 1){
var lbDsmDebug=EPCM.loadClientData("urn:com.sapportals.portal:dsm", "debug");
this.Debug=(lbDsmDebug != null && lbDsmDebug.indexOf("X") >=0 );
this.PopupReceipt=(lbDsmDebug != null && lbDsmDebug.indexOf("P") >=0 );}
}
EPCM.DSM3.registerSession=function(si){
var loSi=this.copySessInfo(si);
this.SessStore[loSi.GUSID]=loSi;
this.SerPropString=this.computeSerPropString();
this.keepAliveNewDataArrived();}
EPCM.DSM3.registerSessionKey=function(skey){
var loKey=new String(skey)
this.KeyStore[loKey]=loKey;
this.SerKeyString=this.computeSerKeyString();
this.keepAliveNewDataArrived();}
EPCM.DSM3.removeSessionByGUSID=function (GUSID){
this.SessStore[GUSID]=null;
this.SerPropString=this.computeSerPropString();}
EPCM.DSM3.removeSessionKey=function (skey){
this.KeyStore[skey]=null;
this.SerKeyString=this.computeSerKeyString();}
EPCM.DSM3.terminateAll=function(isLogoff){
if(!isLogoff){
this.PendingUnload=true;}
var rootInfo, rootFrame, root, slaves;
if(isLogoff){
rootInfo=this.getTopInfo();
root=rootInfo.xNode;
rootFrame=rootInfo.xFrame;
if(root.DSM3.LogoffStarted){
return;
}else{
root.DSM3.LogoffStarted=true;
slaves=this.getChildrenNodes(rootFrame);
for(var idx=0; idx < slaves.length; idx ++){
this.mergeData(root,slaves[idx]);}
root.DSM3.keepAliveDeleteCookie();
root.DSM3.sendToTerminator(true,true);
root.DSM3.clearData();
return;}
}else{
root=EPCM;
slaves=this.getChildrenNodes(window)
for(var idx=0; idx < slaves.length; idx ++){
this.mergeData(root,slaves[idx]);}
this.sendToTerminator(false,false);}
this.clearData();}
EPCM.DSM3.terminateByGUSID=function(GUSID,isLogoff){
if (this.SessStore[GUSID] == null)return;
this.SerPropString=this.computeSerPropString(this.SessStore[GUSID]);
this.SerKeyString="";
this.sendToTerminator(isLogoff);
this.removeSessionByGUSID(GUSID);
this.recomputeData();}
EPCM.DSM3.terminateByKey=function(skey,isLogoff){
if (this.KeyStore[skey] == null)return;
this.SerPropString="";
this.SerKeyString=this.computeSerKeyString(skey);;this.sendToTerminator(isLogoff);
this.removeSessionKey(skey);
this.recomputeData();}
EPCM.DSM3.getAllToArray=function(){
loArr=new Array();
for(var elem in this.SessStore){
if (this.SessStore[elem] != null){
loArr[elem]=this.copySessInfo(this.SessStore[elem]);}
}
return loArr;}
EPCM.DSM3.getAllKeysToArray=function(){
loArr=new Array();
for(var elem in this.KeyStore){
if (this.KeyStore[elem] != null){
loArr[elem]=new String(elem);}
}
return loArr;}
EPCM.DSM3.getSize=function(){
var cnt=0;
for(var idx in this.SessStore){
if (this.SessStore[idx] != null) cnt++;}
return cnt;}
EPCM.DSM3.getKeysSize=function(){
var cnt=0;
for(var idx in this.KeyStore){
if (this.KeyStore[idx] != null) cnt++;}
return cnt;}
EPCM.DSM3.copySessInfo=function(si){
var loSi=new Object();
loSi.protocolVersion=((si.protocolVersion)? new String(si.protocolVersion) : "");
loSi.GUSID=((si.GUSID) ? new String(si.GUSID) : "");
loSi.sessUrl=((si.sessUrl) ? new String(si.sessUrl) : "");
loSi.lastSessCmd=((si.lastSessCmd) ? new String(si.lastSessCmd) : "");
loSi.redirectURL=((si.redirectURL) ? new String(si.redirectURL) : "");
loSi.dTimeout=((si.dTimeout) ? new String(si.dTimeout) : "");
loSi.label=((si.label) ? new String(si.label) : "");
loSi.logoffUrl=((si.logoffUrl) ? new String(si.logoffUrl) : "");
return loSi;}
EPCM.DSM3.serializeSession=function(si){
var collector="";
var separ,propval,propkey;
for(var i in si){
separ=(collector.length>0) ? this.SSIPAIR_SEPAR : "";
propkey=i;
propval=si[i];
collector += separ + encodeURIComponent(propkey) + this.SSIKEYVAL_SEPAR + encodeURIComponent(propval);}
return collector;}
EPCM.DSM3.computeSerPropString=function( sessInfo ){
var collector="";
if (sessInfo == null){
var separ="";
for(var i in this.SessStore){
if(this.SessStore[i] == null) continue;
separ=(collector.length>0) ? this.SERPROP_SEPAR : "";
collector += separ + this.serializeSession(this.SessStore[i]);}
}else{
collector += this.serializeSession(sessInfo);}
return collector;}
EPCM.DSM3.computeSerKeyString=function( skey ){
var collector="";
if (skey == null){
var separ="";
for(var i in this.KeyStore){
if(this.KeyStore[i] == null) continue;
separ=(collector.length>0) ? this.SERKEY_SEPAR : "";
collector += separ + encodeURIComponent(this.KeyStore[i]);}
}else{
collector += encodeURIComponent(skey);}
return collector;}
EPCM.DSM3.recomputeData=function(){
this.SerPropString=this.computeSerPropString();
this.SerKeyString=this.computeSerKeyString();}
EPCM.DSM3.mergeData=function(master, slave){
if(slave.DSM3.SerPropString.length >0){
master.DSM3.SerPropString += this.SERPROP_SEPAR + slave.DSM3.SerPropString;}
if(slave.DSM3.SerKeyString.length > 0){
master.DSM3.SerKeyString += this.SERKEY_SEPAR + slave.DSM3.SerKeyString;}
slave.DSM3.clearData();}
EPCM.DSM3.clearData=function(){
this.SerPropString="";
this.SessStore=new Array();
this.SerKeyString="";
this.KeyStore=new Array();}
EPCM.DSM3.isDataToSend=function(){
return((this.SerPropString != null && this.SerPropString != "")
|| (this.SerKeyString != null && this.SerKeyString != "") );}
EPCM.DSM3.sendToTerminator=function(isLogoff, forceSendWithNoData){
if (!(this.isDataToSend() || forceSendWithNoData )) return;
var myForm=document.forms[this.FormName];
myForm.TermString.value="";
myForm.SerPropString.value=this.SerPropString;
myForm.SerKeyString.value=this.SerKeyString;
myForm.LogoffMode.value=(isLogoff == true) ? "true" : "false";
myForm.Autoclose.value=""
myForm.LogTerm.value=(this.Debug) ? "true": "false";
myForm.method="POST";
myForm.action=this.TerminatorUrl;
var toNewWindow=true;
try{
toNewWindow= this.WinForced
|| this.Debug
|| isLogoff
|| (EPCM.getUAType() != EPCM.MSIE)
|| (top.EPCM.DSM3 == this)
|| (top.EPCM.DSM3.PendingUnload);
}catch(e){
toNewWindow=true;}
if( ! toNewWindow ){
try{
var frameElement=top.document.getElementById(this.TargetNameIframe);
if (frameElement != null){
if(frameElement.targetlock == true){
toNewWindow=true;}
else{

frameElement.targetlock=true;
myForm.target=this.TargetNameIframe;}
} else{

var iFrame=top.document.createElement("DIV");
iFrame.innerHTML="<IFRAME id=\""+this.TargetNameIframe+"\" name=\""+this.TargetNameIframe +"\""
+ " style =\"display:none\" src=\"" + this.EmptyUrlFrame +"\""
+ " targetlock=\"true\""
+ " onload=\"top.document.getElementById('"+ this.TargetNameIframe+"').targetlock=false;\""
+ "></IFRAME>";
top.document.body.appendChild( iFrame );
myForm.target=this.TargetNameIframe;}
}catch(e){
toNewWindow=true;}
}
if (toNewWindow){
if(isLogoff){
try{
top.isLogoffFinalAllowed=false;
}catch(ex){}}

var myTarget=this.TargetNameWindow + this.FormName;
var myWinParams=(this.Debug) ? this.WinParamsDebug : this.WinParamsHidden;
myForm.target=myTarget;
myForm.Autoclose.value=(this.Debug) ? "" : "1000";
window.open(this.EmptyUrlWindow, myTarget, myWinParams);
window.focus();}

myForm.submit();}
EPCM.DSM3.log=function( logString, isDebugControlled ){
if (logString == null) return;
if (isDebugControlled && (! this.Debug )) return;
(new Image).src=this.TerminatorUrl + "?LogString=" + encodeURIComponent(logString);}
EPCM.DSM3.keepAliveSetCookie=function(val ){
EPCM._private.setCookie(this.KeepAliveCookieName, val, null, "/", EPCM.getRelaxedDomain() );}
EPCM.DSM3.keepAliveGetCookie=function (){
return EPCM._private.getCookie(this.KeepAliveCookieName);}
EPCM.DSM3.keepAliveDeleteCookie=function (){
return EPCM._private.deleteCookie(this.KeepAliveCookieName,"/", EPCM.getRelaxedDomain() );}
EPCM.DSM3.keepAliveInitTimer=function(){
if (! this.KeepAliveActive)return;
var now=(new Date).getTime();
this.KeepAliveInitStamp=now;
var cookie=this.keepAliveGetCookie();
if(cookie != null){
this.keepAliveSetCookie(now);}
if (this.KeepAliveTimer != null){
clearTimeout(this.KeepAliveTimer);}
this.KeepAliveTimer=setTimeout("EPCM.DSM3.keepAliveProcess()", this.KeepAliveDelta);}
EPCM.DSM3.keepAliveNewDataArrived=function(){
if (! this.KeepAliveActive)return;
var cookie=this.keepAliveGetCookie();
if( cookie == null ){
this.keepAliveSetCookie(this.KeepAliveInitStamp);}
}
EPCM.DSM3.keepAliveProcess=function(){
if (! this.KeepAliveActive)return;
var now=(new Date).getTime();
var instance=EPCM.getInstanceId();
var cookie=this.keepAliveGetCookie();
if(cookie != null){
var cookieInt=parseInt(cookie);
if(now > (0 + cookieInt + this.KeepAliveDelta - 1)){
(new Image).src=this.TerminatorUrl + "?KeepAlive="+ now + "&Id=" + instance;
this.keepAliveSetCookie(now);}
}
if( now < (this.KeepAliveInitStamp + this.KeepAliveStopAfter)){
this.KeepAliveTimer=setTimeout("EPCM.DSM3.keepAliveProcess()", this.KeepAliveDelta);}
else{
if (this.KeepAliveTimer != null){
clearTimeout(this.KeepAliveTimer);}
}}
EPCM.DSM3.isValidNode=function(object){
var result=false;
try{
result=( object != null
&& object.DSM != null
&& object.DSM3 != null );
}catch(ex){}
return result;}
EPCM.DSM3.getTopInfo=function(){
var result={"xNode": EPCM, "xFrame":window };
var ldFrame=window;
try{
while (ldFrame.parent != ldFrame){
ldFrame=ldFrame.parent;
if (this.isValidNode(ldFrame.EPCM)){
result={ "xNode": ldFrame.EPCM, "xFrame": ldFrame}
}}
} catch (ex){
}
return result;}
EPCM.DSM3.getChildrenNodes=function(rootFrame){
return this.searchForChildren(rootFrame, null, false);}
EPCM.DSM3.searchForChildren=function(rootFrame, nodelist, addRootNode){
if (nodelist == null) nodelist=new Array();
if (addRootNode && rootFrame.EPCM != null && this.isValidNode(rootFrame.EPCM)){
nodelist[nodelist.length]=rootFrame.EPCM;}
for (var idx=0; idx < rootFrame.frames.length; idx++){
try{
this.searchForChildren( rootFrame.frames[idx], nodelist, true );}
catch (ex){
}}
return nodelist;}
EPCM._private.getApplet=function(){
loApplet=document.applets["_EPCMfactory_"];
if (loApplet == null){
alert( "EPCM ERROR\n" +
"\tApplet _EPCMfactory_ not available" );}
return loApplet;}
EPCM._private.getAdjacentEPCM=function(){

var ldTopFrame=this.getTopmostFrame();
return this.getChildrenEPCM( ldTopFrame );}
EPCM._private.getTopmostFrame=function(){
var ldFrame=window;
var saptop=null;
try{
saptop=EPCM.getSAPTop();
}catch(ex){}
try{

while ((ldFrame.parent != ldFrame) && (ldFrame != saptop)){
ldFrame=ldFrame.parent;}
} catch (ex){
 }
return ldFrame;}
EPCM._private.getTopmostEPCM=function(){
var result=EPCM;
var ldFrame=window;
try{

while (ldFrame.parent != ldFrame){
ldFrame=ldFrame.parent;
if (ldFrame.EPCM != null){
result=ldFrame.EPCM;}
}}
catch (ex){

}
return result;}
EPCM._private.getChildrenEPCM=function( froot, paList){
if (paList == null) paList=new Array();
if (froot.EPCM != null) paList[paList.length]=froot.EPCM;
for (var idx=0; idx < froot.frames.length; idx++){
try{
this.getChildrenEPCM( froot.frames[idx], paList );}
catch (ex){

}}
return paList;}
EPCM._private.handleBrowserEvent=function(evt){
var browserNS="urn:com.sapportals.portal:browser";
if (evt == null) evt=window.event;
if(evt.type == "unload" || evt.type == "load"){
EPCM.raiseEventLocal( browserNS, "pre" + evt.type, evt );}

EPCM.raiseEventLocal( browserNS, evt.type, evt );}
EPCM._private.getContainerElement=function( wnd){
var myParent=wnd.parent;
if (wnd != myParent){

var parentFrames=myParent.frames;
for (var idx=0; idx < parentFrames.length; idx++){
if (parentFrames[idx] == wnd){

var eFrames=myParent.document.getElementsByTagName( "IFRAME" );
if (eFrames.length < idx) return null;
return eFrames[idx];
}}
}
return null;}
window.onload=EPCM._private.handleBrowserEvent;
window.onunload=EPCM._private.handleBrowserEvent;
window.onresize=EPCM._private.handleBrowserEvent;
EPCM._private.pokeObject=function(fRef, fNames, fValue){
fRef[fNames[0]]=(fValue != null)? new Object(fValue): new Object();
for (var i=1; i<fNames.length; i++){
fRef[fNames[i]]=fRef[fNames[0]];}
return fRef[fNames[0]];}
EPCM._private.pokeFunction=function(fRef, fNames, fFunc){
var func=fFunc.toString();
var args=func.match(/\(\s*(.*)\)\s*/)[1];
var argStr=args.replace(/(\w+)/g, '"$1"');
if (argStr.length > 0) argStr += ", ";
var bodyStr=func.match(/\{((.|\n)*)\}[\s\n]*$/)[1];
eval("fRef[fNames[0]] = new Function(" + argStr + "bodyStr)");
for (var i=1; i<fNames.length; i++){
fRef[fNames[i]]=fRef[fNames[0]];}
return fRef[fNames[0]];}

