﻿var msgBoxDEBUG = 5;
var tehForm;
// DomainRelaxing //
if ((document.domain != 'de.festo.net') && (document.domain != 'festo.com')) {
//  alert('document.domain is not relaxed yet! '+document.domain);
}
var portalPresentChecked = false;
var portalPresent = false;
var __GlobalTopmostW1ndow = null;
var top_theIFrame = '';
var top_theDiv = '';
var XDKI_BASE_URL = '';
var theOptions = '';
var __topWindow = self;
var SAPTop = null;
function getSAPTop()
{
  if (SAPTop != null) return SAPTop;
      var refDynamicTop = top;
      var testedFrame = window;
      try {
          while(testedFrame != top && testedFrame.parent != null) {
              try{
                  if(testedFrame.parent.EPCM != null) {
                      refDynamicTop = testedFrame.parent;
                  }
              } catch(ex1) {}
              testedFrame = testedFrame.parent;
          }
      } catch(ex2) {}
      SAPTop = refDynamicTop;
      return refDynamicTop;
}

// service call within same page: remote procedure call with IFrame; the IFrame will be created from scratch; Variable number of arguments
function xDKICallWithDomainRelaxing(aID,aURL,aReceiver,aSessionID,aLanguage)
{
    var i,aOldIFrame,aTempIFrame,aIFrameObj,aIFrameDoc,aIFrameForm,aOldIDiv,aTempIDiv,aIDivObj,aHTML1,aHTML2;
  globalArguments=arguments;
  if (!document.createElement) { return true } ;
  // Create IFrame always from scratch to avoid errors when calling multiple times with different fields
  aOldIFrame = xDKIElemId(aID);
  if (aOldIFrame) document.body.removeChild(aOldIFrame);
  // MSIE 5
  if (xDKIBrowser_IE5())
  {
     aOldIDiv = xDKIElemId('Div'+aID);
     if (aOldIDiv) document.body.removeChild(aOldIDiv);

     aTempIDiv = document.createElement('div');
     aTempIDiv.id = 'Div'+aID;
     aTempIDiv.style.display = "none";
     aHTML1 = '<iframe src="blank.html" id="'+aID+'" name="'+aID+'" frameBorder="0px" '+
              ' style="border:0px; background-color:white; position:absolute; left:0; top:0; width:0; height:0;">'+
              '</iframe>';
     aTempIDiv.innerHTML = aHTML1;
     aIDivObj = document.body.appendChild(aTempIDiv);

  }
  // Other Browser
  else
  {
     aTempIFrame = document.createElement('iframe');
     with (aTempIFrame) {src = "blank.html"; id = aID; name = aID; frameBorder = "0px";
                        with (style) { border = "0px"; backgroundColor = "white"; position = "absolute";
                                       left = 0; top = 0; width = 0; height = 0;  }
     }
  }
  aIFrameObj = document.body.appendChild(aTempIFrame);
}

function xDKICallFrameLoaded(frameWindow)
{
    var i,aOldIFrame,aTempIFrame,aIFrameObj,aIFrameDoc,aIFrameForm,aOldIDiv,aTempIDiv,aIDivObj,aHTML1,aHTML2;
    var aID,aURL,aReceiver,aSessionID,aLanguage;
    aID=globalArguments[0];
    aURL=globalArguments[1];
    aReceiver=globalArguments[2];
    aSessionID=globalArguments[3];
    aLanguage=globalArguments[4];
    if (xDKIBrowser_IE5())
    {
        aHTML2 = '<html><head/><body><form id="form'+aID+'" method="post" action="'+xDKIParseQuery(true,aURL)+'">'+
              '<input type="hidden" name="xDKI_Receiver" value="'+aReceiver+'"/>'+
              '<input type="hidden" name="xDKI_SessionID" value="'+aSessionID+'"/>'+
              '<input type="hidden" name="xDKI_Language" value="'+aLanguage+'"/>';
     if ((globalArguments.length == 6) && (typeof(globalArguments[5]) == 'object') && (globalArguments[5].constructor.toString().search('Array') != -1))
     {
        for (i=0; i<globalArguments[5].length; i=i+2)
            if ((globalArguments[5][i]!='xDKI_Receiver')&&(globalArguments[5][i]!='xDKI_SessionID')&&(globalArguments[5][i]!='xDKI_Language'))
               aHTML2 += '<input type="hidden" name="'+globalArguments[5][i]+'" value="'+globalArguments[5][i+1]+'"/>';
     }
     else
     {
        for (i=5; i<globalArguments.length; i+=2)
            aHTML2 += '<input type="hidden" name="'+globalArguments[i]+'" value="'+globalArguments[i+1]+'"/>';
     }
     aHTML2 += '</form></body></html>';
     with (document.frames[document.frames.length-1].document)
     {
          open();
          write(aHTML2);
          close();
          getElementById('form'+aID).submit();
     }
     return true;
  }
  else
    {
     aIFrameDoc = frameWindow.document;
     if (!aIFrameDoc) return true;
     // Form to post Receiver, SessionID, Language and Arguments
     aIFrameForm = aIFrameDoc.createElement("form");
     if (!aIFrameDoc.body) aIFrameDoc.appendChild(aIFrameDoc.createElement("body"));
     aIFrameDoc.body.appendChild(aIFrameForm);
     createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,'xDKI_Receiver',aReceiver);
     createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,'xDKI_SessionID',aSessionID);
     createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,'xDKI_Language',aLanguage);
     if ((globalArguments.length == 6) && (typeof(globalArguments[5]) == 'object') && (globalArguments[5].constructor.toString().search('Array') != -1))
     {
        for (i=0; i<globalArguments[5].length; i=i+2)
            if ((globalArguments[5][i]!='xDKI_Receiver')&&(globalArguments[5][i]!='xDKI_SessionID')&&(globalArguments[5][i]!='xDKI_Language'))
               createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,globalArguments[5][i],globalArguments[5][i+1]);
     }
     else
     {
        for (i=5; i<globalArguments.length; i+=2) createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,globalArguments[i],globalArguments[i+1]);
     }
     aIFrameForm.method="post";
     aIFrameForm.action=xDKIParseQuery(true,aURL);
     aIFrameForm.submit();
     return true;
  }
globalArguments='';
}

function ReturnValueToService(aName, aValue)// changes a hidden field and submits the form
{
  with (document.forms['Form-A1'])
  {
       elements[aName].value = aValue;
       submit();
  }
}
function ChangeHiddenFields(aName, aValue)// changes a hidden field without submit
{
  with (document.forms['Form-A1'])
  {
       elements[aName].value = aValue;
  }
}

function findPosX(obj) // this functions return the absolute position of an object.
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}
function SetCurrentNode(NodeId)
{
  if (document.forms['Form-A1']) with (document.forms['Form-A1']) // otherwise error in printform, when clicking
  {
       elements['CurrentNode'].value = NodeId;
       elements['ListViewService'].value = 'ListView';
       elements['ViewPart'].value = '1';
       submit();
  }
}

function adjustHeightPropertySearch(PropertySearchHeight)
{
    PSIFrame=document.getElementById('ListViewTable');
    if (PropertySearchHeight == 0) PropertySearchHeight = 580;
    if (PSIFrame) PSIFrame.style.height=(PropertySearchHeight+20);
    adjustHeightinPortal();
}
// Test if Portal is present. If so include festo_portal.js else include portal_emu.js //
function checkPortalPresent() {
  if ( portalPresentChecked ) {
      return portalPresent;
  }
  portalPresentChecked = 1;
  var myParent, mySaveParent;
  try
  {
    myParent = window.self;
    mySaveParent = null;
  }
  catch(e)
  {
    myParent=null;
  }
  var i = 0;
  while ((myParent != mySaveParent) && ( i < 50 ) && (mySaveParent != top)) {
    try {
      var isolatedWorkArea = myParent.document.getElementById('isolatedWorkArea');
      var innerPage = myParent.document.getElementById('divChangeContent');
      innerPage = null;
      if ( (isolatedWorkArea != null) || ( innerPage != null ) ) {
        document.write('<script type="text\/javascript" language="JavaScript" src="javascript\/xdki_portal.js"><\/script>');
        document.write('<script type="text\/javascript" language="JavaScript" src="javascript\/epcfproxy.js"><\/script>');
        portalPresent = true;
        return portalPresent;
      }
      mySaveParent = myParent;
    } catch (err) {}
    myParent = myParent.parent;
    i++;
  }
  portalPresent = false;
  document.write('<script type="text\/javascript" language="JavaScript" src="javascript\/portal_emu.js"><\/script>');
  return portalPresent;
}
function callServiceWithWaitMessage(ElementID,Target,Options,xPos,yPos,Message,MessageWidth,MessageHeight,aRelative,aURL)
{
    function hideWaitDiv()
    {
        try
        { 
          var aEl = findElementById(ElementID)
      aEl.removeChild(WaitDiv);
          aEl.visibility="visible";
      }catch(e){ }    
    }
  if (pnf == "true") {
    TryLoadingStyleSheet();
  }
  var docwin = findElementsFrameById(ElementID);
  if (!docwin) docwin = self;
    var WaitDiv = docwin.document.createElement("DIV");
    var WaitImage=docwin.document.createElement("IMG");
    WaitImage.src=getxDKILocation()+"images/wait_mov.gif";
    var br=docwin.document.createElement("BR");
    var WaitTable;
    var WaitTCell;
    var WaitTRow;
    if (isNaN(parseInt(MessageHeight)))     
     MessageHeight=140
    else
     MessageHeight=parseInt(MessageHeight);    
     
    if (isNaN(parseInt(MessageHeight)))
    MessageWidth=300
  else          
    MessageWidth=parseInt(MessageWidth);     
  try {
    try { 
      findElementById(ElementID).appendChild(WaitDiv);
    } catch (err) { }  
      
      WaitDiv.id="WaitIFrame";
    if ((aRelative == undefined) || (aRelative == false) ) {
        WaitDiv.style.position="absolute";   
        WaitDiv.style.left=xPos-300;
        WaitDiv.style.top=yPos+5;
        WaitDiv.style.zIndex=0;
    }
      WaitDiv.className="allbordergreybg";
      WaitDiv.style.padding="0px";
      WaitDiv.align="center";
      WaitDiv.vAlign="middle";
      WaitDiv.style.height=MessageHeight+2+"px";
      WaitDiv.style.width=MessageWidth+2+"px";
      WaitTable=docwin.document.createElement("TABLE");
    if (pnf == "true") {
      WaitTable.className="festoreset";
    }
      WaitTable.style.height="100%";
      WaitTable.style.padding="20px";
      WaitTRow=WaitTable.insertRow(-1);
      WaitTCell=WaitTRow.insertCell(-1);
    if (pnf == "true") {
      WaitTRow.className="festoreset";
      WaitTCell.className="festoreset";
    }
      WaitTCell.align="center";
      WaitTCell.vAlign="middle";
    if (pnf == "true") {
        WaitTCell.innerHTML="<h2 class=\"festoreset\">"+Message+"</h2>";
    } else {
        WaitTCell.innerHTML="<h1>"+Message+"</h1>";
    }
      WaitTRow=WaitTable.insertRow(-1);   
      WaitTCell=WaitTRow.insertCell(-1);
    if (pnf == "true") {
      WaitTRow.classNname="festoreset";
      WaitTCell.className="festoreset";
    }
      WaitTCell.align="center";
      WaitTCell.vAlign="middle";
      WaitTCell.appendChild(WaitImage);
      WaitDiv.appendChild(WaitTable);
    } catch (err) {
  }
  try {
      if (window.frameElement)
      {
          adjustHeightinPortal();
      }
  } catch (e) {}
  var aElement = findElementById(Target);
  if (!aRelative) {
    try {
      if (aElement.onload == undefined) {
          try
          {
          aElement.attachEvent('onload',hideWaitDiv);//for IE
           } catch(e) { // FF
              try {     
                aElement.onload=hideWaitDiv; //for Firefox
              } catch (err) { }
          }  
      }
    } catch (e) {};
  }
    callService(ElementID,Target,Options,aURL);
    try
    {
        callServiceWithWaitMessageCallBack();
    }
    catch(e)
    {
      // Dummy....
    }
}
function callServiceBlankTarget(ElementID,Options)
{
    var MyArray;
    var OptionsArray=new Array;
    var ValuesArray=new Array;
    // Allow Options to be an array
    if (isArray(Options)) {
        MyArray = Options;
    } else {
        MyArray = Options.split(",");
    }
    
    var Counter;
    Counter=0
    for (i=0; i<MyArray.length; i++)
    {
        if (i%2==0)
        {
            OptionsArray[Counter]=MyArray[i];
        }
        if (i%2==1)
        {
            ValuesArray[Counter]=MyArray[i];
            Counter++;
        }
    }
    var aForm=document.createElement("FORM");
    if (document.getElementById(ElementID))
    document.getElementById(ElementID).appendChild(aForm);
    else
    document.body.appendChild(aForm);
  aForm.target="_blank";
    var ArrayOfHiddenFields=new Array;
    var OptionsCount=OptionsArray.length;
    for (i=0; i<OptionsCount; i++)
    {
        var hiddenField=document.createElement("INPUT");
        hiddenField.type="hidden";
        hiddenField.name=OptionsArray[i];
        hiddenField.value=ValuesArray[i];
        aForm.appendChild(hiddenField);
    }
    aForm.method="post";
    try {
    aForm.setAttribute('target','_blank');
  } catch (e) {};
    aForm.action="xDKI.asp";
    aForm.submit();
    if (document.getElementById(ElementID))
    document.getElementById(ElementID).removeChild(aForm);
    else
    document.body.removeChild(aForm);
}
function callServiceFormAvailable(ElementID,Target,Options,aDocument)
{
    var MyArray;
    var OptionsArray=new Array;
    var ValuesArray=new Array;
  
    // Allow Options to be an array
    try {    
    MyArray = Options.split(",");
  } catch (err) {
        MyArray = Options;
  }
    
    var Counter;
    Counter=0
    for (i=0; i<MyArray.length; i++)
    {
        if (i%2==0)
        {
            OptionsArray[Counter]=MyArray[i];
        }
        if (i%2==1)
        {
            ValuesArray[Counter]=MyArray[i];
            Counter++;
        }
    }
    var aForm=ElementID;
    var ArrayOfHiddenFields=new Array;
    var OptionsCount=OptionsArray.length;
  try {
    for (var i=0; i<OptionsCount; i++)
    {
      try {
        // IE:
        aForm.insertAdjacentHTML('beforeEnd','<input name="'+OptionsArray[i]+'" value="'+ValuesArray[i]+'" type="hidden"/>');
      } catch (err) {
        // ALL others:
        var hiddenField=aDocument.createElement("INPUT");
        hiddenField.type="hidden";
        hiddenField.name=OptionsArray[i];
        hiddenField.value=ValuesArray[i];
        try {
          aForm.appendChild(hiddenField);
        } catch (err) {  }
      }
    }
  } catch (err) { alert('callServiceFormAvailable Error: '+err) };
    aForm.method="post";
  aForm.target= Target;
    try {
      aForm.setAttribute('target',Target);
  } catch (e) {};
  aForm.action="xDKI.asp";
  tehForm = aForm;
  window.setTimeout("tehForm.submit()",0);
}

function callService(ElementID,Target,Options,aURL)
{
  if (!aURL) aURL = '';
    var MyArray;
    var OptionsArray=new Array;
    var ValuesArray=new Array;
    // Allow Options to be an array
    if (isArray(Options)) {
        MyArray = Options;
    } else {
        MyArray = Options.split(",");
    }
    
    var Counter;
    Counter=0
    for (i=0; i<MyArray.length; i++)
    {
        if (i%2==0)
        {
            OptionsArray[Counter]=MyArray[i];
        }
        if (i%2==1)
        {
            ValuesArray[Counter]=MyArray[i];
            Counter++;
        }
    }
    var aForm=document.createElement("FORM");
  try {
    ElementID.appendChild(aForm);
  } catch (err) {
      if (document.getElementById(ElementID))
        document.getElementById(ElementID).appendChild(aForm);
      else
        document.body.appendChild(aForm);
  }
    var ArrayOfHiddenFields=new Array;
    var OptionsCount=OptionsArray.length;
    for (i=0; i<OptionsCount; i++)
    {
        var hiddenField=document.createElement("INPUT");
        hiddenField.type="hidden";
        hiddenField.name=OptionsArray[i];
        hiddenField.value=ValuesArray[i];
        aForm.appendChild(hiddenField);
    }
    aForm.method="post";
    try {
      aForm.setAttribute('target',Target);
  } catch (e) {};
    aForm.action=aURL+"xDKI.asp";
    aForm.submit(); 
  
  try {
      if (!(document.getElementsByName(Target).item(0))&& (!(document.getElementById(Target))));
      {
          newWindow=window.open("",Target);
          newWindow.focus();
      }
    if (document.getElementById(ElementID))
      document.getElementById(ElementID).removeChild(aForm);
    else
      document.body.removeChild(aForm);
  } catch (e) { 
    // this does happen in IE/ //
  };
  
}
function globalSearchElement(IFrame,ElementId) //this function searchs for this element in all IFrames and returns the IFrame
{
     var i;
     var result;
     result="";
    if ((IFrame.document.getElementsByName(ElementId).length > 0)||(IFrame.document.getElementById(ElementId)))
    {
        result=IFrame;
    }
    else
    {
      for(i=0;i<IFrame.length;i++)
       {
           try
           {
              if ((IFrame.frames[i].document.getElementsByName(ElementId).length > 0)||(IFrame.frames[i].document.getElementById(ElementId))||(IFrame.frames[i].name==ElementId)||(IFrame.frames[i].id==ElementId))
             {
                     result=IFrame.frames[i];
                     break;
                 } else {
                     result = globalSearchElement(IFrame.frames[i],ElementId)
                     if (result!="")break;
                 }
             }
             catch(e){}
       }
    }
     return result;
}
function openSmallWindow(xSize,ySize,WindowURL)
{
  var delClassAdviceWindow;
  delClassAdviceWindow=window.open(WindowURL,"newWindow", "width="+xSize+",height="+ySize+",left=0,top=0,status=no,toolbar=no,location=no");
  return delClassAdviceWindow;
}
  
function isFunction(a)
{
    return typeof a == 'function';
}
function isObject(a)
{
    return (typeof a == 'object' && !!a) || isFunction(a);
}
function isArray(a)
{
    return isObject(a) && a.constructor == Array;
}
// works like getEelementById() but also in all IFrames on the page //
// pity that it does not work on IE...... //
function findElementById(aId) {
  var ares = findFrameAndElementById(aId);
  var ret;
  try { ret = ares[1] } catch (e) { ret = 0 }
  return ret;
}
function findElementsFrameById(aId) {
  var ares = findFrameAndElementById(aId);
  var ret;
  try { ret = ares[0] } catch (e) { ret = 0 }
  return ret;
}
function globalFunctionsSearchTop() {
  // iterate through parents until error occurs //
  var aParent = self;
  var aSaveParent = self;
  var sDummy;
  while ((aParent != top) && (aParent != undefined)) {  
    aParent = aParent.parent;
    try {
      sDummy = aParent.title;
      // it has already caused an exception if we have no permissions //
      aSaveParent = aParent; // the last one we have a MessageBox.
    } catch (err) {
      // that did not do it ;-) //
    }
  }
  return aSaveParent;
}
function findFrameAndElementById(aId) {
  function lookForElement(_aWindow,aId,aIt) {
    if (aIt.length > 20) { 
//      xDKIDS('Break drawn');
      return;                                                   // the 'break' for browsers performing badly
    }
//    try { xDKIDS('Document.Domain: '+document.domain); xDKIDS('Lei le '+aIt+'   >'+_aWindow.location+'<  '+aId); } catch (e) {};
    var aThisIsIt = null;
    try {
      aThisIsIt = _aWindow.contentDocument.getElementById(aId);  // its an IFrame
    } catch (err) { 
//      xDKIDS('  =  '+err);
      try {
        aThisIsIt = _aWindow.document.getElementById(aId);      // its a 'normal' window / frame
      } catch (err) {  
//      xDKIDS('  -  '+err); 
        try {
          aThisIsIt = _aWindow.getElementById(aId);      // its a document (?)
        } catch (err) {  
//          xDKIDS(' +-  '+err); 
        }
      }
    }
    if ((aThisIsIt != null) && (aThisIsIt != undefined)) { 
//      xDKIDS('Found '+aThisIsIt);
      return [_aWindow,aThisIsIt];                                        // we found it => return the Element
    }
    var aElements;
    try {
      if (_aWindow.document.frames) {
        aElements = _aWindow.document.frames;
      } else {
        aElements = _aWindow.frames; 
      }
    } catch (err) {
      aElements = _aWindow.frames;
    }
//    xDKIDS('  Found '+aElements.length);
    aIt += '['+aElements.length+']'; 
    for (var i = 0; i<aElements.length ; i++)    {
      try {
        aThisIsIt = lookForElement(aElements[i],aId,aIt+'/'+i);
      } catch (e) { }
      if (aThisIsIt != undefined) {
        return aThisIsIt;    
      }
    }     
    return aThisIsIt;
  }
//  xDKIDS('Start with '+aId);
  try {
    return lookForElement(top,aId,'root');
  } catch (e) {  
    // maybe we ran into the 'we run in an iframe without permissions' bug? //
    var aTop = globalFunctionsSearchTop();
    try {
      return lookForElement(aTop,aId,'root');
    } catch (err) { 
      alert('All safety lines did break, and I have no idea how to search our page for your requested element... '+err);
    }
  } 
}
/////////////////////////////////////////////////////////////
function getxDKILocation() {
  if (XDKI_BASE_URL == '') {
    var scripts = document.getElementsByTagName('SCRIPT');
//    for each (var aLink in document.getElementsByTagName('SCRIPT')) {
    for (var i=0; i++; i<script.length) {
      if (aLink.src.indexOf('/javascript/MessageBox.js') > 0) {
        alert('Found xDKI will be at: '+aLink.src.replace(/javascript\/MessageBox.js/gi,""));
        return aLink.src.replace(/javascript\/MessageBox.js/gi,"");
      }
    }
    if (pnf=="false") {
      return window.location.protocol+'//'+window.location.host+'/xdki/';
    } else {
      return window.location.protocol+'//'+window.location.host+document.location.pathname.replace(/xDKI.asp/gi,"");
    }
  } else {
    return XDKI_BASE_URL+'/';
  }
}
function deletePx(aString) {
  return parseInt(aString.replace(/px/g,""));  
}
function xDKIToPortalLang()
{
    var ProtalLanguage;
    var path;
    var pathArray;
    var i;
    ProtalLanguage='';
    path=document.location.pathname;
    pathArray=path.split("/");
    for (i=0;i<pathArray.length;i++)
    {
     if (pathArray[i].toLowerCase()=='cat')
     { 
         ProtalLanguage=pathArray[i+1];
         break;
     }
    }
    
  return(ProtalLanguage);
}
// pseudo-GUID
function generateGuid()
{
  var result, i, j;
  result = '';
  for(j=0; j<32; j++)
  {
    if( j == 8 || j == 12|| j == 16|| j == 20)
      result = result + '_';
    i = Math.floor(Math.random()*16).toString(16).toUpperCase();
    result = result + i;
  }
  return result
}
// Contacts the server and asks for tha current nodeId //
// result is a nodeName[0], Camos[1], and FullScreen[2] //
function getIsComplexConfig(aNodeId, aSessionId) {
  var response = new Array(3 + 5); // 3 values and 5 strings //
  var xmlHttp = null;
  // Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
  if (typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
  }
  if (!xmlHttp) {
    // Internet Explorer 6 und älter
    try {
      xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xmlHttp  = null;
      }
    }
  }
  if (xmlHttp) {
    xmlHttp.open('GET', 'xdki.asp?xR=DKI3DatCamosV1&xS='+aSessionId+'&NodeId='+aNodeId, 0);
    xmlHttp.send(null);
    // To Do: Check for Session Timeout //
    try {       
      try { 
        var docNode = xmlHttp.responseXML.getElementsByTagName('name');
      } catch (e) { /* session timeout */  document.open(); document.write(xmlHttp.responseText); document.close(); response[0] = -1; return response }
      response[0] = docNode[0].firstChild.nodeValue;
      try {
        docNode = xmlHttp.responseXML.documentElement.getElementsByTagName('Camos');
        if (docNode[0].firstChild != null) {
          if (docNode[0].firstChild.nodeValue != undefined) {
            response[1] = 'X';
          }
        } else { response[1] = ''; }
      } catch (e) { alert('Error in getIsComplexConfig (response 1)'+e) }
      try {
        docNode = xmlHttp.responseXML.documentElement.getElementsByTagName('Complex');
        if (docNode[0].firstChild != null) {
          if (docNode[0].firstChild.nodeValue != undefined) {
            response[2] = 'F';
          }
        } else { response[2] = ''; }
      } catch (e) { alert('Error in getIsComplexConfig (response 2)'+e) }
      try {
        var docNode = xmlHttp.responseXML.getElementsByTagName('String');
        for (var i=0;i<docNode.length;i++) {
          var x = 3;
          switch (docNode[i].attributes.getNamedItem("Name").value) {
            case '~Close':
              x = 3;
            break;
            case '~Ja':
              x = 4;
            break;
            case '~Nein':
              x = 5;
            break;
            case '~CancelConfiguration':
              x = 6;
            break;
            case '~ReallyCancelConfiguration':
              x = 7;
            break;
          }
          response[x] = docNode[i].attributes.getNamedItem("Value").value;
        }
      } catch (e) { alert('Error in getIsComplexConfig (locale)'+e) }
    } catch (e) { alert('Error in getIsComplexConfig'+e) }
  }
  return  response;
}
function execCamosLink(aNodeId, axS, axL, aPartNo, AlternateLink, AlwaysFullScreen) {
  var aValues = getIsComplexConfig(aNodeId,axS);
  if (aValues[0] == -1) { return; }
  if (aValues[1] != '') {
    if ( (aValues[2] == 'F') || ( AlwaysFullScreen == true ) ) { 
      var aCamosFS = new __topWindow.camosFS(axS, axL, aValues[0], window, aValues[3],aValues[4],aValues[5],aValues[6],aValues[7]);
      return;
    }
  }
  AlternateLink();
  return;
}
function messageBoxSearchTop() {
  // iterate through parents until error occurs //
  var aParent = __topWindow;
  var aSaveParent = __topWindow;
  var sDummy;
  while ((aParent != top) && (aParent != undefined)) {  
    aParent = aParent.parent;
    try {
      sDummy = aParent.__festoMsgBoxGiveMeA('Try');
      if (sDummy == 'Succeeded') {
        if (msgBoxDEBUG > 5) { alert('found a working copy of messagebox in parent'); }
      }
      aSaveParent = aParent; // the last one we have a MessageBox.
    } catch (err) {
      // that did not do it ;-) //
    }
  }
  return aSaveParent;
}
__topWindow = messageBoxSearchTop();
