// functions called from ahp_assistant.vbb


// executable code from here




// *****************************************************************************
//
// use new event handling mode for mouse events?
// prevents tooltips in IE from flickering, but cannot be considered stable

var bUseNewEventHandling = true;

// tested in:
// 
// Firefox 3.0
// >> behaves fine, just like the classic event handler
//
// Internet Explorer 7.0.5730.13
// >> prevents flickering, but doesn't work properly when page is scaled,
//    otherwise behaves fine
//
// Opera 9.24
// >> flickers, just like the classic event handler
//
// Safari 3.0.4
// >> behaves fine, just like the classic event handler
//
// *****************************************************************************




var iStaticFieldNr=-1; // static variable

var gsLanguage = 'english';
var gsRoot = '';
var gbPartserver = 0;
var gbPartcommunity

var sCookieWritingNotAllowed = 'Your data security policy declines cookie access within IFrames from the domain: '+document.URL.substr(0,25)+'\nA new popup window is up to open to write the cookie for the domain.';
var sAddAccessoriesMessage = '';
var sAddAccessoriesQuestion = '';

var gsEnterUserdataFunction = '';
var gsOrderCadDataFunction = '';
var gsFlashSuffix = '';
var gsUserDataRequired = '';
var gsEnterUserdataFunction = '';
var gsOrderCadDataFunction = '';
var gsFlashSuffix = '';
var gsUserDataRequired = 'Please fill out all fields marked with the "*" sign.';


// var PARTserverLink;

// var cssLocation = gsRoot + '/guide/css/main.css';
// var sUrl = document.URL;
// 
// // very fallback (to include the CSS dynamically)
// if ( sUrl.search('.partserver.de') ){
//   gsRoot = '../ahp/23d-libs';
//   gbPartserver = 1;
//   cssLocation = gsRoot + '/guide/css/main_partserver.css';
// }
// 
// 
// document.getElementsByTagName("body")[0].onLoad=getCss(cssLocation);


// methodes definitions from here

// function getCss( cssPath ){
//   
//   // CSS für IEs nachladen
//   if(document.createStyleSheet) document.createStyleSheet(cssPath);
//     // CSS für Mozilla, Netscape, Opera nachladen
//   else{
//     var objStyle = document.createElement('style');
//     var objText = document.createTextNode('@import url('+ cssPath + ') screen;');
//     objStyle.appendChild(objText);
//     document.getElementsByTagName("body")[0].appendChild(objStyle);
//     
//     alert('append css node');
//   }
// }


function $(id, bShown){
  if (typeof bShown=='undefined'){
    bShown=true;
  }
  var ele = document.getElementById(id); 
  if (bShown){
    try{
      ele.style.visibility = 'visible';
      ele.style.display = '';
//       if(ele.getAttribute('hiddenByHideDiv')=='true') // if this item was hidden by hidediv function
//       {
//         modifyAttribute(ele,'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
//         ele.style.display='block'; // reset display property
//       }
    }catch (e){
//       to be deleted
//       alert('element not found: '+id);
    }
  }
  return ele;
}

function setLanguage(slang){
  gsLanguage = slang;
}
function setRoot(sRoot){
  gsRoot = sRoot;
}
function setgbPartserver(iPs){
  gbPartserver = iPs;
}
function setgbPartcommunity(iPs){
  gbPartcommunity = iPs;
}
function convertHTML(sTxt){
  var ele = $('HTMLConverter');
  ele.innerHTML = sTxt;
  var retVal = ele.innerHTML;
  return retVal.replace(/\&amp\;apos\;/g, '\'');
//   return ele.innerHTML;
}

function setCookieNotAllowedMessage(sMessage){
  sCookieWritingNotAllowed = sMessage;
}

function setAddAccessoriesMessage(sMessage){
  sAddAccessoriesMessage = sMessage;
}
  
function setAddAccessoriesQuestion(sMessage){
  sAddAccessoriesQuestion = sMessage;
}


// function initializeParams(obj){
//   gsRoot = obj.root;
//   gsLanguage = obj.language;
//   gbPartserver = obj.partserver;
//   var PARTserverLink = '&root=' +gsRoot+ '&partserver=' +gbPartserver+ '&language=' +gsLanguage+ '&cleanup=flash,navigationarea,foldersandtooltips,projecthead,basket_summary,basket_options,basket_export&hide=tablesandvalueranges,tab_valueranges';
// }

// function setRoot(sRoot){
//   gsRoot = sRoot;
// }
// 
// function setPartserver(bVal){
//   gbPartserver = bVal;
// }
// 
// function setLanguage(sLang){
//   gsLanguage = sLang;
// }

// function setRoot(sRoot){
//   gsRoot = sRoot;
// }


function modifyAttribute(oElement,sKey,sValue)
{
  // modifies an attribute of an element, takes a key/value pair
  var oAttribute=document.createAttribute(sKey);
  oAttribute.nodeValue=sValue;
  oElement.setAttributeNode(oAttribute);
}

function CreateImageDOM(sImage,sHeight,sWidth,sClass){
  if(sImage!=''&&sImage!='&nbsp;'){
    var imgTag=document.createElement('img');
      modifyAttribute(imgTag,'src',sImage);
  }else{
    var imgTag=document.createElement('div');
    imgTag.innerHTML='&nbsp;';
  }

  if(typeof sHeight!='undefined' || sHeight!='' ){
      modifyAttribute(imgTag,'height',sHeight);
  }
  if(typeof sWidth!='undefined' || sWidth!=''){
      modifyAttribute(imgTag,'width',sWidth);
  }
  if(typeof sClass!='undefined' || sClass!=''){
      modifyAttribute(imgTag,'class',sClass);
  }

  return imgTag;
}

function CreateInputDOM(sCaption, id, sClass){
  var inputTag=document.createElement('input');

    modifyAttribute(inputTag,'id',id);
    modifyAttribute(inputTag,'type','text');
    modifyAttribute(inputTag,'value',sCaption);
    
    if (typeof sClass!='undefined'){
      modifyAttribute(inputTag, 'class', sClass);
    }
  return inputTag;
}

function CreateButtonDOMJS(sCaption,sUrl){
  sCaption = convertHTML(sCaption);
  var btn=document.createElement('input');
    modifyAttribute(btn,'type','button');
    modifyAttribute(btn,'value',sCaption);
    modifyAttribute(btn,'class','inputbutton');
    btn.onmousedown=function(){modifyAttribute(btn,'class','inputbuttonactive');}
    btn.onmouseup=function(){modifyAttribute(btn,'class','inputbutton');}
    btn.onmouseout=function(){modifyAttribute(btn,'class','inputbutton');}

  if(typeof sUrl!='undefined'){
    btn.onclick=function(){eval(sUrl);}
  }
  return btn;
}

function CreateButtonDOM(sCaption,sUrl){
  sCaption = convertHTML(sCaption);
  var btn=document.createElement('input');
    modifyAttribute(btn,'type','button');
    modifyAttribute(btn,'value',sCaption);
    modifyAttribute(btn,'class','inputbutton');
    btn.onmousedown=function(){modifyAttribute(btn,'class','inputbuttonactive');}
    btn.onmouseup=function(){modifyAttribute(btn,'class','inputbutton');}
    btn.onmouseout=function(){modifyAttribute(btn,'class','inputbutton');}

  if(typeof sUrl!='undefined'){
    btn.onclick=function(){eval(getLoadLink(sUrl));}
  }
  return btn;
}

function CreateTextDOM(sCaption, sClass){
  sCaption = convertHTML(sCaption);
  var div=document.createElement('div');
  div.innerHTML=sCaption;
  if (typeof sClass!='undefined'){
    modifyAttribute(div, 'class', sClass);
  }
  return div;
}

function CreateTextAreaDOM(sContent){
  sContent = convertHTML(sContent);
  var ele = document.createElement('textarea');
  ele.innerHTML = sContent;
  return ele;
}

function CreateComboDOM(sCsv){
  var comboTag=document.createElement('select');
  var arr=sCsv.split('@@');
  for(i=1;i<arr.length;i++){
    var opt=document.createElement('option');
    opt.innerHTML=convertHTML( arr[i] );
    opt.value=arr[i];

    if(i==1){
      modifyAttribute(opt,'selected','selected');
    }
    comboTag.appendChild(opt);
  }
  return comboTag;
}

function CreateAnchorDOM(sUrl,sCaption){
  sCaption = convertHTML(sCaption);
  var anchorTag=document.createElement('a');
      modifyAttribute(anchorTag,'href',sUrl);
    anchorTag.innerHTML=sCaption;
  return anchorTag;
}

function getLoadLink(sUrl){
  return 'AjaxRequest(\''+sUrl+'\');';
}

function getStaticLink(sUrl){
  return 'LoadLink(\''+sUrl+'\');';

}
// cleanupDiv('$NAME.');
function cleanupDiv(sName){
  try{
    removeOnLoadAttribute();
    var what=$(sName);
    if(what){
      what.innerHTML = '';
      
    }
  }catch(e){
//     try{
    var oNode=$(sName);
    while(oNode.hasChildNodes()){
      oNode.removeChild(oNode.lastChild);
    }
//     }catch(e){
//       alert('cleanupDiv::'+e.toString());
//     }
  }
  if (what){
    what.style.visibility = 'hidden';
  }
}

function hideDiv(sName){
//   alert('hidediv');
  var what = $(sName);
  what.style.visibility = 'hidden';
  what.style.display = 'none'; // set display to none so that the item doesn't take up space
//   modifyAttribute(what,'hiddenByHideDiv','true'); // flag item as hidden by hidediv function
}

// $STGU: TESTME!! ;)

function moveStartupTable(){
//   alert('moveStartupTable');
  var tab = $('desc_table');
//   workaround for empty table space by using flashguide
  tab.style.display='block';
  var startup = $('startup');
  startup.appendChild(tab);
}

// addStartupText = "addStartupText('$CAPTION.');" &vbcrlf
function addStartupText(sCaption){
  sCaption = convertHTML(sCaption);
  moveStartupTable();
  var descDiv;
  try{
    descDiv = $('startup_desc');
    var test = descDiv.nodeType;
  }catch(e){
    descDiv = document.createElement('div');
    modifyAttribute(descDiv, 'id', 'startup_desc');
  }
  descDiv.innerHTML = sCaption;
}

// addAssistantText = "addAssistantText('$CAPTION.');" &vbcrlf
function addAssistantText(sCaption){
  sCaption = convertHTML(sCaption);
  var descDiv;
  try{
    descDiv = $('assistant_desc');
    var test = descDiv.nodeType;
  }catch(e){
    descDiv = document.createElement('div');
    modifyAttribute(descDiv, 'id', 'assistant_desc');
  }
  descDiv.innerHTML = sCaption;
}

// addFlashText = "addFlashText('$CAPTION.');" &vbcrlf
function addFlashText(sCaption){
  sCaption = convertHTML(sCaption);
  var descDiv;
  try{
    descDiv = $('flash_desc');
    var test = descDiv.nodeType;
  }catch(e){
    descDiv = document.createElement('div');
    modifyAttribute(descDiv, 'id', 'flash_desc');
  }
  descDiv.innerHTML = sCaption;
}

// addIndexText = "addIndexText('$CAPTION.');" &vbcrlf
function addIndexText(sCaption){
  sCaption = convertHTML(sCaption);
  var descDiv;
  try{
    descDiv = $('index_desc');
    var test = descDiv.nodeType;
  }catch(e){
    descDiv = document.createElement('div');
    modifyAttribute(descDiv, 'id', 'index_desc');
  }
  descDiv.innerHTML = sCaption;
}


// addFooterText = "addFooterText('$CAPTION.');" &vbcrlf
function addFooterText(sCaption){
  sCaption = convertHTML(sCaption);
  var descDiv;
  try{
    descDiv = $('startup_footer');
    var test = descDiv.nodeType;
  }catch(e){
    descDiv = document.createElement('div');
    modifyAttribute(descDiv, 'id', 'startup_footer');
  }
  descDiv.innerHTML = sCaption;
}

// addChoiceAssistant = "addChoiceAssistant('$IMG_PATH.','$CAPTION.');" &vbcrlf
function addChoiceAssistant(sImage, sCaption){
//   var targetDiv = $('startup');
    var destDiv;
    try{
      destDiv = $('assistant_choice');
      var test = destDiv.nodeType;
    }catch(e){
      destDiv = document.createElement('div');
      modifyAttribute(destDiv, 'id', 'assistant_choice');
    }
    
    var newDiv = document.createElement('div');
    modifyAttribute(newDiv, 'id', 'ch_assistant');
      if (typeof sCaption!='undefined'){
        var txt = CreateTextDOM(sCaption);
        newDiv.appendChild(txt);
      }
      
      
      var img = CreateImageDOM(sImage);
      img.style.cursor = 'pointer';
      img.onclick = function(){goToAssistant();}
      newDiv.appendChild(img);
    destDiv.appendChild(newDiv);
//   targetDiv.appendChild(destDiv);
}

// addChoiceFlash = "addChoiceFlash('$IMG_PATH.','$CAPTION.');" &vbcrlf
function addChoiceFlash(sImage, sCaption){
//   var targetDiv = $('startup');
    var destDiv;
    try{
      destDiv = $('flash_choice');
      var test = destDiv.nodeType;
    }catch(e){
      destDiv = document.createElement('div');
      modifyAttribute(destDiv, 'id', 'flash_choice');
    }
  
    var newDiv = document.createElement('div');
    modifyAttribute(newDiv, 'id', 'ch_flash');
    if (typeof sCaption!='undefined'){
        var txt = CreateTextDOM(sCaption);
        newDiv.appendChild(txt);
      }
      
      var img = CreateImageDOM(sImage);
      img.style.cursor = 'pointer';
      img.onclick = function(){goToFlash();}
//       modifyAttribute(img, 'onclick', 'goToFlash();');
      
      newDiv.appendChild(img);
    destDiv.appendChild(newDiv);
//   targetDiv.appendChild(destDiv);
}

// addChoicePdatamgr = "addChoicePdatamgr('$IMG_PATH.','$CAPTION.');" &vbcrlf
function addChoicePdatamgr(sImage, sCaption){
//   var targetDiv = $('startup');
    var destDiv;
    try{
      destDiv = $('index_choice');
      var test = destDiv.nodeType;
    }catch(e){
      destDiv = document.createElement('div');
      modifyAttribute(destDiv, 'id', 'index_choice');
    }
  
    var newDiv = document.createElement('div');
    modifyAttribute(newDiv, 'id', 'ch_index');
    if (typeof sCaption!='undefined'){
        var txt = CreateTextDOM(sCaption);
        newDiv.appendChild(txt);
      }
      
      var img = CreateImageDOM(sImage);
      img.style.cursor = 'pointer';
      img.onclick = function(){goToPdm();}
//       modifyAttribute(img, 'onclick', 'goToPdm();');
      
      newDiv.appendChild(img);
    destDiv.appendChild(newDiv);
//   targetDiv.appendChild(destDiv);
}



function goToAssistant(PARTSERVERLINK){
  if (typeof PARTSERVERLINK=='undefined'){PARTSERVERLINK='';};
	AjaxRequest('/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/ahp_assistant.vbb&option=folder&path=$CADENAS_DATA/23d-libs/ahp&partserver='+gbPartserver+'&root='+gsRoot+'&language='+gsLanguage+'&cleanup=startup'+PARTSERVERLINK);
}

function goToFlash(PARTSERVERLINK){

  if (typeof PARTSERVERLINK=='undefined'){PARTSERVERLINK='';};
  
  AjaxRequest('/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/ahp_assistant.vbb&option=flashedit&partserver='+gbPartserver+'&root='+gsRoot+'&language='+gsLanguage+'&cleanup=startup'+PARTSERVERLINK+'&'+gsFlashSuffix);
    		
}

function goToPdm(PARTSERVERLINK){
  if (typeof PARTSERVERLINK=='undefined'){PARTSERVERLINK='';};
  AjaxRequest('/cgi-bin/assistantredirector.exe?script=$CADENAS_DATA/23d-libs/ahp/guide/script/execute.vbb&option=close'+PARTSERVERLINK);
}



// addLogo('$IMG_PATH.')
function addLogo(sImage){
//   nothing to do
}

function restoreTablesAndValueranges(){
//   alert('restoreTablesAndValueranges');
  var test = $('tab_valueranges', false); // don't show it (fixes a graphical bug)
  if (!test){
//     alert('!test');
    var tav = $('tablesandvalueranges');
      var tab = document.createElement('table');
        modifyAttribute(tab, 'id', 'tab_valueranges');
        var tbody = document.createElement('tbody');
          var tr1 = document.createElement('tr');
  
            var td1 = document.createElement('td');
              modifyAttribute(td1, 'width', '150');
              modifyAttribute(td1, 'align', 'center');
              
              var div3 = document.createElement('div');
                modifyAttribute(div3, 'class', 'folderandproject');
                div3.style.width = '130px';
                div3.style.height = '200px';
                
                var tab = document.createElement('table');
                  tab.style.width = '130px';
                  tab.style.height = '150px';
                  
                  var tbody = document.createElement('tbody');
                  
  //                   prjNB
                    var tr = document.createElement('tr');
                      var td = document.createElement('td');
                        var a = document.createElement('a');
                          modifyAttribute(a, 'id', 'prjNB');
                          a.style.cursor='pointer';
                        td.appendChild(a);
                      tr.appendChild(td);
                    tbody.appendChild(tr);
                    
  //                   prjicon
                    var tr = document.createElement('tr');
                      var td = document.createElement('td');
                        var a2 = document.createElement('a');
                          modifyAttribute(a2, 'id', 'prjicon');
                          a2.style.cursor='pointer';
                        td.appendChild(a2);
                      tr.appendChild(td);
                    tbody.appendChild(tr);
                  
                  tab.appendChild(tbody);
                  
                div3.appendChild(tab);
              td1.appendChild(div3);
            tr1.appendChild(td1);
  
  //           projectdesc
            var td5 = document.createElement('td');
              modifyAttribute(td5, 'class', 'projectdesc');
  
              var div0 = document.createElement('div');
                modifyAttribute(div0, 'id', 'prjdesc');
              td.appendChild(div0);
  
              var div1 = document.createElement('div');
                modifyAttribute(div1, 'id', 'pdf');
                modifyAttribute(div1, 'valign', 'middle');
                div1.style.marginTop = '4px';
                
                var tab = document.createElement('table');
                  tab.style.width = '130px';
                  tab.style.height = '150px';
                  
                  var tbody = document.createElement('tbody');
                    
                    var tr = document.createElement('tr');
  //                     pdficon
                      var td = document.createElement('td');
                        var div2 = document.createElement('div');
                          modifyAttribute(div2, 'id', 'pdficon');
                        td.appendChild(div2);
                      tr.appendChild(td);
                    tbody.appendChild(tr);
                      
                      
  //                     pdflink
                      var td = document.createElement('td');
                        var a = document.createElement('a');
                          modifyAttribute(a, 'id', 'pdflink');
                          modifyAttribute(a, 'class', 'projecttablelink');
                          modifyAttribute(a, 'target', '_blank');
                        td.appendChild(a);
                      tr.appendChild(td);
                    tbody.appendChild(tr);
                    
                  tab.appendChild(tbody);
                  
                div1.appendChild(tab);
              td5.appendChild(div1);
            tr.appendChild(td);
          tbody.appendChild(tr);
          
          var tr = document.createElement('tr');
            var td = document.createElement('td');
              modifyAttribute(td, 'height', '5');
              modifyAttribute(td, 'colspan', '2');
  
  //             formerly spacer.gif
              var div = document.createElement('div');
                div.innerHTML = '&nbsp;';
              td.appendChild(div);
            tr.appendChild(td);
          tbody.appendChild(tr);
        tab.appendChild(tbody);
      tav.appendChild(tab);
    
  }
}

// addNavItem('$CONTENT.','$URL.')
function addNavItem(sContent,sUrl){
  sContent = convertHTML(sContent);
  
  var navigationarea=$('navigationarea');
    if (navigationarea){
      var naviDiv=document.createElement('div');
      if(naviDiv){
        modifyAttribute(naviDiv,'class','navigationitem');
  
       
        naviDiv.style.cursor='pointer';
        naviDiv.style.backgroundColor='#ffffff';
        naviDiv.style.border='1px solid';
        naviDiv.style.borderColor='#bbbbbb';
  //       naviDiv.style.backgroundColor='#022c43';
  //       naviDiv.style.width='100%';
  //       naviDiv.style.filter='alpha(opacity=100)'; // background color must not shine through
  //       naviDiv.style.opacity='1'; // background color must not shine through
        naviDiv.style.marginTop='0px'; // anpl - no spacing between menu elements
  
        naviDiv.onclick=function(){eval(sUrl);}
        
        naviDiv.innerHTML=sContent;
      }
    navigationarea.appendChild(naviDiv);
    navigationarea.style.visibility='visible';
      
    }
}



// addBasketBtn('$CONTENT.','$URL.')
function addBasketBtn(sContent,sUrl){
  sContent=convertHTML('&raquo; '+sContent);
//   alert(sContent);
//   alert(sUrl);
  var basketbtn=$('basketbutton');
    while(basketbtn.hasChildNodes())
    {
      basketbtn.removeChild(basketbtn.lastChild());
    }
    var basketbtnCaption=document.createTextNode(sContent);
    basketbtn.appendChild(basketbtnCaption);
    basketbtn.onclick=function(){eval(sUrl);}
    basketbtn.style.display='inline';
}




// addTooltip('$ID.','$CONTENT.','$IMG_PATH.','$CAPTION.','$FOLDER_ID.')
function addTooltip(sId,sContent,sImage,sCaption,sFolderID){
  
  if(sId!='')
  {
  
    sContent = convertHTML(sContent);
    sCaption = convertHTML(sCaption);
  
    
    var foldersandtooltipsDiv=$('foldersandtooltips');
      
      var tooltip = $(sId, false); // try to get tooltip, but don't show it
      
      if(tooltip == null) // if tooltip does not exist
      {
        var tooltip = document.createElement('div'); // create one
      }
      else // otherwise
      {
        cleanupDiv(sId); // clean up the existing one
      }
        
        tooltip.style.position='fixed';
        modifyAttribute(tooltip,'class','tooltip');
        modifyAttribute(tooltip,'id',sId);
        
        tooltip.style.width='500px';
        tooltip.style.height='350px';
  //       tooltip.style.filter='alpha(opacity=85)';
  //       tooltip.style.opacity='0.85';
        
        var headDiv=document.createElement('div');
        
        modifyAttribute(headDiv,'class','head');
        
  //       headDiv.style.filter='alpha(opacity=100)';
  //       headDiv.style.opacity='1';
        
        headDiv.innerHTML=sCaption;
        tooltip.appendChild(headDiv);
        
        var contentDiv=document.createElement('div');
          modifyAttribute(contentDiv,'class','content');
  //         contentDiv.style.filter='alpha(opacity=100)';
  //         contentDiv.style.opacity='1';
  
        if (sImage!=''){
          var imageDiv=document.createElement('div');
            modifyAttribute(imageDiv,'class','contentimage');
            imageDiv.innerHTML='<img src="'+sImage+'" border="0" alt="">';
          contentDiv.appendChild(imageDiv);
          
        }
  
  //         display the complete caption (contains <div> elements)
        contentDiv.innerHTML+=sContent;
        tooltip.appendChild(contentDiv);
      foldersandtooltipsDiv.appendChild(tooltip);
  
  
  //     append attributes (onMouseover and onMouseOut) to folderitem-div
  //     e.g.: onMouseOver="showTooltip('tooltipblockzylinder')" onMouseOut="hideTooltip()"
      var folderTable=$(sFolderID);
  
  //       folderTable.onmouseover=function(){window.setTimeout('showTooltip(\''+sId+'\');',500);}
  //       folderTable.onmouseover=function(){showTooltip(sId);}
  
      folderTable.onmousemove=function(){showTooltip(sId, sFolderID);} // show tooltip or register it for new event handling method
      
      if(!bUseNewEventHandling) // use old event handling?
      {
        folderTable.onmouseout=function(){hideTooltip();} // hide tooltip when mouse leaves it
      }
  }
}

function getCoordinates(oNode)
{
  // returns the coordinates of an element on a document
  // takes a DOM node
  var oCoordinates={x:0,y:0,w:0,h:0};
  var iLeftOffset=window.pageXOffset;
  var iTopOffset=window.pageYOffset;
  if((typeof(iLeftOffset)=='undefined')||(typeof(iTopOffset)=='undefined')) // internet explorer
  {
    iLeftOffset=document.documentElement.scrollLeft;
    iTopOffset=document.documentElement.scrollTop;
  }
  oCoordinates.x=-iLeftOffset; // take scrolling offset into account
  oCoordinates.y=-iTopOffset; // take scrolling offset into account
  oCoordinates.w=oNode.offsetWidth; // width of node
  oCoordinates.h=oNode.offsetHeight; // height of node
  while(oNode)
  {
    oCoordinates.x+=oNode.offsetLeft;
    oCoordinates.y+=oNode.offsetTop;
    oNode=oNode.offsetParent;
  }
  return(oCoordinates);
}

function isOnElement(oNode, x, y)
{
  // checks if a specific location (x and y coordinates) is on an element
  // takes a DOM node and coordinates
  if(oNode)
  {
    var c = getCoordinates(oNode);
    
    var bIsLeftOfElement = x < c.x;
    var bIsRightOfElement = x > (c.x + c.w);
    var bIsOverElement = y < c.y;
    var bIsUnderElement = y > (c.y + c.h);
    var bIsOnElement = !( bIsLeftOfElement || bIsRightOfElement || bIsOverElement || bIsUnderElement );
    
    return(bIsOnElement);
    
//     return(!((((x)<(c.x))||((x)>((c.x)+(c.w))))||(((y)<(c.y))||((y)>((c.y)+(c.h))))));

  }
  else
  {
    return(false);
  }
}

// addFolderItem('$IMG_PATH.','$CONTENT.','$URL.','$ID.','$LABEL.')
function addFolderItem(sImage, sContent, sUrl, sId, bIsDir, sLabel){
  if (typeof bIsDir=='undefined'){bIsDir=true;}
  if (typeof sLabel=='undefined'){sLabel='';} // accept a label
//   alert(sImage);
  sContent = convertHTML(sContent);
  
  var foldersandtooltipsDiv=$('foldersandtooltips');
    var newDiv=document.createElement('div');
    newDiv.style.visibility='visible';
    newDiv.style.display='block';
  //   todo: use "div_templates.js" for the userinterface

      modifyAttribute(newDiv,'class','folderandproject');

      newDiv.style.width='150px'; // anpl - wider width
      newDiv.style.height='315px'; // anpl - higher height
      newDiv.style.border='';

      var table=document.createElement('table');

      modifyAttribute(newDiv,'id',sId);

      table.style.width='100%';
//       table.style.width='130px';
      table.style.height='100%';
//       table.style.height='150px';

      table.style.backgroundColor='#ffffff'; // table now does the background (not div)
      modifyAttribute(table,'cellpadding','10px'); // table now does the padding (not div)
      modifyAttribute(table,'cellspacing','0'); // table must not have cellspacing


      modifyAttribute(table,'border','0');



  //    <tr>
  //      <td>
  //        <a onClick="LoadLink('/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/create.vbb&option=folder&path=ahp/blockzylinder&partserver=1&language=german&root=&beta=0');" style="cursor:pointer;">
  //          <img src="/blockzylinder/_documents/bz500.jpg" border="0" alt="">
  //        </a>
  //      </td>
  //    </tr>

      var tbody=document.createElement('tbody');
      var tr=document.createElement('tr');
        var td=document.createElement('td');
        
        // td now has border (not div)
        td.style.borderStyle='solid';
        td.style.borderColor='rgb(202,201,206)';
        td.style.borderWidth='1px';
        
          var a=document.createElement('a');
      if (gbPartserver==1){
        if (bIsDir==1){
          modifyAttribute(a,'href',('JavaScript:AjaxRequest("'+sUrl+'");'));
        }else{
          modifyAttribute(a,'href',('JavaScript:LoadLinkNewWindow("'+sUrl+'");'));
        }
      }else{
        modifyAttribute(a,'href',('JavaScript:AjaxRequest("'+sUrl+'");'));
      }

          a.style.cursor='pointer';
          modifyAttribute(a,'class','formattedlink');

          // old
//           a.innerHTML = ...;
          
          // new - using dom
          {
            var oImg=document.createElement('img');
              modifyAttribute(oImg,'src',sImage);
              modifyAttribute(oImg,'border','0');
              modifyAttribute(oImg,'alt','');
            a.appendChild(oImg);
            var oP=document.createElement('p');
              modifyAttribute(oP,'align','right');
              var oSpan=document.createElement('span');
                modifyAttribute(oSpan,'class','folderlink');
                oSpan.innerHTML='&raquo;&nbsp;'+sLabel;
              oP.appendChild(oSpan);
            a.appendChild(oP);
          }
          
        td.appendChild(a);
      tr.appendChild(td);
      tbody.appendChild(tr); 
      table.appendChild(tbody); 

  //   <tr>
  //     <td>
  //        <a onClick="LoadLink('/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/create.vbb&option=folder&path=ahp/blockzylinder&partserver=1&language=german&root=&beta=0');" style="cursor:pointer;">
  //          <div class="newshometext" style="text-align: center; height:100px; width:100px; white-space:normal;">Blockzylinder</div>
  //        </a>
  //     </td>
  //   </tr>

      var tbody=document.createElement('tbody');
      var tr=document.createElement('tr');
        var td=document.createElement('td');
        
        td.style.height='115px'; // fixed height so that every folder text has the same height, no matter how long it is
        td.style.borderStyle='none solid solid'; // no top border, since td on top has it
        td.style.borderColor='black rgb(202,201,206) rgb(202,201,206)'; // border colours
        td.style.borderWidth='0px 1px 1px'; // border widths
        
          var a=document.createElement('a');

      modifyAttribute(a,'href',('JavaScript:AjaxRequest("'+sUrl+'");'));

          a.style.cursor='pointer';

            var innerDiv=document.createElement('div');

      modifyAttribute(innerDiv,'class','newshometext');

            innerDiv.style.textAlign='left'; // text align left as in the draft
//             innerDiv.style.textAlign='center';
//             innerDiv.style.height='100px';
            innerDiv.style.width='120px'; // more space for folder text
            innerDiv.style.whiteSpace='normal';

            innerDiv.innerHTML=sContent;
          a.appendChild(innerDiv);
        td.appendChild(a);
      tr.appendChild(td);
      tbody.appendChild(tr);
      table.appendChild(tbody);

    newDiv.appendChild(table);

  foldersandtooltipsDiv.appendChild(newDiv);
  // Safari workaround
    var oSpan = document.createElement('span'); // create a generic inline element
    foldersandtooltipsDiv.appendChild(oSpan); // and place it in between the folder divs
}


// <div class="footer" id="seitenende">
//   &copy; 2007 AHP Merkle GmbH <BR>
//    V7.0.01 - 11/2007
// </div>
function addFooter(sContent){
  sContent = convertHTML(sContent);  
//   alert('addFooter('+sContent+');');
  var endDiv=$('seitenende');
    endDiv.innerHTML=sContent;
    endDiv.style.visibility='visible';

}

//     <div class="loadbar" id="loadbar">
//       Bitte warten...
//     </div>
function addWaiting(sContent){
  sContent = convertHTML(sContent);
  var loadbar=$('loadbar');
    loadbar.innerHTML=sContent;

}

// <td class="projecthead">
//   <div>
//     AHP Merkle GmbH
//   </div>            
// </td>
function addTitle(sContent){
  sContent = convertHTML(sContent);
  var projecthead=$('projecthead');
    var innerDiv=document.createElement('div');
    innerDiv.innerHTML=sContent;
  projecthead.appendChild(innerDiv);
  projecthead.style.visibility='visible';
}

function addHtmlTitle(sContent){
//   add title
  sContent = convertHTML(sContent);
  document.title = sContent;
}


// addHeaderContentHtml = "addHeaderHTML('$CONTENT.','$IMG_PATH.','$CAPTION.');"
function addHeaderHTML(sContent,sImage,sCaption){
  sContent = convertHTML(sContent);
  
  var x=sContent;
  $('prjdesc').innerHTML=sContent;

  $('tablesandvalueranges').style.display='block'; // part of Firefox workaround
  $('tab_valueranges'); // IE workaround
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv

  
  var prjIcon = $('prjicon');
    var imgTag = CreateImageDOM(sImage);
//     var imgTag = CreateImageDOM(sImage, '200', '200');

  prjIcon.appendChild(imgTag);

  var prjNB=$('prjNB');
    prjNB.innerHTML= convertHTML( sCaption );

}



// addPDFlink = "addPDFlink('$CAPTION.','$URL.');"&vbcrlf
function addPDFlink(sCaption,sUrl){
  var link=$('pdflink');
  if (gbPartserver==1){
    link.href=sUrl;
  }else{
    link.onclick = function(){
      AjaxRequest(sUrl);
    }
  }
    link.innerHTML= convertHTML( sCaption );

    $('pdf').style.display = 'block';
}

// addPDFIcon = "addPDFIcon('$IMG_PATH.');"&vbcrlf
function addPDFIcon(sImage){
  var div=$('pdficon');
//     var img = CreateImageDOM(sImage, 16, 16);
    var img = CreateImageDOM(sImage);
  div.appendChild(img);
}

// addTableHeadline = "addTableHeadline('$CONTENT.','$UNIT.','$IMG_PATH.');"&vbcrlf
function addTableHeadline(sContent,sUnit,sImage){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var headDiv=$('tableheadline');
    headDiv.style.fontWeight='bold'; // be bold
    headDiv.innerHTML=convertHTML( sContent );
    headDiv.innerHTML+=('&nbsp;'+sUnit); // non breaking space
}


// addTableHeader0 = "addTableHeader0('$CSV_COLS.');"&vbcrlf
function addTableHeader0(sCsvCols){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var body=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');

      modifyAttribute(row,'class','forcetableheader0');
      
      var csv=sCsvCols.split('@@');
      for (i=0;i<csv.length;i++){
        var td=document.createElement('td');
          modifyAttribute(td,'height','22');
          modifyAttribute(td,'class','forcetableheadertext');
          td.style.textAlign='left'; // align left
  
//           not main column
          if (i!=(csv.length-1)){
            modifyAttribute(td,'colspan','2');
          }
        td.innerHTML=convertHTML( csv[i] );
        row.appendChild(td);
      }
    body.appendChild(row);
}

// addTableHeader1 = "addTableHeader1('$CSV_COLS.');"&vbcrlf
function addTableHeader1(sCsvCols){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var body=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');

      modifyAttribute(row,'class','forcetableheader1');

      var csv=sCsvCols.split('@@');
      for(i=0;i<csv.length;i++){
        var td=document.createElement('td');

          modifyAttribute(td,'height','22');
          modifyAttribute(td,'class','forcetableheadertext');
//           not main column
          if(i!=0){
            modifyAttribute(td,'colspan','2');
          }
          td.innerHTML=convertHTML( csv[i] );
        row.appendChild(td);
      }
    body.appendChild(row);
}

// addTableHeader2 = "addTableHeader2('$CSV_COLS.');"&vbcrlf
function addTableHeader2(sCsvCols){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var body=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');

      modifyAttribute(row,'class','forcetableheader2');

      var csv=sCsvCols.split('@@');
      for(i=0;i<csv.length;i++){
        var td=document.createElement('td');
        modifyAttribute(td,'class','forcetabletd');
          if(i==0){
            modifyAttribute(td,'height','22');
            td.style.width='100px';
          }else{
            td.style.textAlign='center';
          }
          if(i%2==0) // every other col
          {
            td.style.borderRight='1px solid #cac9ce'; // seperation line
          }
        td.innerHTML = convertHTML( csv[i] );
        row.appendChild(td);
      }
    body.appendChild(row);
}
// addTableRow = "addTableRow('$CSV_COLS.');"&vbcrlf
function addTableRow(sCsvCols){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var body=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');

      modifyAttribute(row,'class','forcetabletr');

      var csv=sCsvCols.split('@@');
      for(i=0;i<csv.length;i++){
        var td=document.createElement('td');
          var tdValue=document.createElement('div');
          tdValue.innerHTML= convertHTML( csv[i] );

          if(i==0){
            modifyAttribute(td,'height','22');
            modifyAttribute(td,'class','forcetabletd1');

            var cellArr=csv[i].split(';;');
            var cellUrl=cellArr[0];
            var clArr=cellArr[1].split('<br>');
            
            tdValue=document.createElement('div');
            if (clArr.length==2){
              var p = document.createElement('p');
              p.innerHTML = convertHTML( clArr[0] );
              tdValue.appendChild(p);
            }

            var anchor=document.createElement('a');
              modifyAttribute(anchor,'class','forcetablelink');
              modifyAttribute(anchor,'href',('JavaScript:'+cellUrl));
            anchor.innerHTML= convertHTML( clArr[clArr.length-1] );

            tdValue.appendChild(anchor);

          }else{
          
            var bColumnClass = ((Math.floor((i-1)/2)%2)!=0);
            
            if(bColumnClass){
              modifyAttribute(td,'class','forcetabletd3');
            }else{
              modifyAttribute(td,'class','forcetabletd2');
            }
            td.style.verticalAlign='bottom';
          }
//         td.innerHTML = tdValue;
        td.appendChild(tdValue);
        row.appendChild(td);
      }
    body.appendChild(row);
}



// addTableButtons = "addTableButtons('$CAPTION_BAR.','$CAPTION_PSI.','$URL_BAR.','$URL_PSI.');"&vbcrlf
function addTableButtons(sCaptionBar,sCaptionPsi,sUrlBar,sUrlPsi){
  sCaptionBar = convertHTML(sCaptionBar);
  sCaptionPsi = convertHTML(sCaptionPsi);

  var switch_unit=$('switch_unit');

    var btnBar=CreateButtonDOMJS(sCaptionBar,sUrlBar);
//     var btnBar=document.createElement('input');
//       modifyAttribute(btnBar,'type','button');
//       modifyAttribute(btnBar,'value',sCaptionBar);
      modifyAttribute(btnBar,'width','80');
      btnBar.style.width='80px';
//       btnBar.onclick=function(){eval(sUrlBar);}
    switch_unit.appendChild(btnBar);

    var btnPsi=CreateButtonDOMJS(sCaptionPsi,sUrlPsi);
//     var btnPsi=document.createElement('input');
//       modifyAttribute(btnPsi,'type','button');
//       modifyAttribute(btnPsi,'value',sCaptionPsi);
      modifyAttribute(btnPsi,'width','80');
      btnPsi.style.width='80px';
//       btnPsi.onclick=function(){eval(sUrlPsi);}
    switch_unit.appendChild(btnPsi);
}

// addZubAuswahlHeader = "addZubAuswahlHeader('$CSV_COLS.');"&vbcrlf
function addZubAuswahlHeader(sCsvCols){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
//   $('tab_valueranges').style.visibility='visible';
  var body=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');

      modifyAttribute(row,'class','accessoriestableheader');

      var csv=sCsvCols.split('@@');
      for(i=0;i<csv.length;i++){
        var td=document.createElement('td');
          modifyAttribute(td,'class','accessoriestabletd');
          td.style.width='100px';
          td.style.textAlign='center';
          
          
        td.innerHTML = convertHTML( csv[i] );
        row.appendChild(td);
      }
    body.appendChild(row);
}


// addZubAuswahlRow = "addZubAuswahlRow('$CSV_COLS.');"
function addZubAuswahlRow(sCsvCols){

  var body=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');

      modifyAttribute(row,'class','accessoriestabletr');

      var csv = sCsvCols.split('@@');
      for(i=0;i<csv.length;i++){
        var td=document.createElement('td');
        
        
          var tdValue=document.createElement('div');
          if(i==0){

//           modifyAttribute(td,'height','22');
          modifyAttribute(td,'class','accessoriestabletd1');

          td.style.width='100px';
          td.style.textAlign='center';

          var cellArr=csv[i].split(';;');
          var cellVal=cellArr[0];
          var cellUrl=cellArr[1];

          var anchor=document.createElement('a');

          modifyAttribute(anchor,'class','accessoriestablelink');
          modifyAttribute(anchor,'href',('JavaScript:'+getLoadLink(cellUrl)));

          anchor.innerHTML=convertHTML( cellVal );
          tdValue.appendChild(anchor);

          }else{
            tdValue.innerHTML=convertHTML( csv[i] );

          modifyAttribute(td,'class','accessoriestabletd2');

            td.style.width='100px';
            td.style.textAlign='center';
          }

        td.appendChild(tdValue);
        row.appendChild(td);
      }
  body.appendChild(row);

}

function evalJScommand(cmd){
  try{ eval(cmd); }catch(e){}
}

// addOnLoadAttribute = "addOnLoadAttribute('$ATTR.');" &vbcrlf
function addOnLoadAttribute(sAttribute){
  var body = $('body');
  modifyAttribute(body,'onLoad',sAttribute);
}

function removeOnLoadAttribute(){
  var body = $('body');
  modifyAttribute(body,'onLoad','');
}



// addConfigTableHeader = "addConfigTableHeader('$OPTIONS,','$DESC,','$COLVALDESC,');" &vbcrlf
function addConfigTableHeader(soptions, sDesc, sColValDesc){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var table=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');
      modifyAttribute(row,'class','projecttableheader');
      row.style.backgroundColor='#dedede'; // have a background colour

//       options column
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','middle');
        modifyAttribute(cell,'height','22');
        modifyAttribute(cell,'colspan','3');
        modifyAttribute(cell,'class','projecttabletd');
        cell.style.paddingLeft='5px';
        cell.innerHTML=convertHTML( soptions );
      row.appendChild(cell);
      
//       description column
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','middle');
        modifyAttribute(cell,'class','projecttabletd');
        cell.style.paddingLeft='5px';
        cell.innerHTML=convertHTML( sDesc );
      row.appendChild(cell);

//       choice column
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','middle');
        modifyAttribute(cell,'colspan','2');
        modifyAttribute(cell,'class','projecttabletd');
        cell.style.paddingLeft='5px';
        cell.innerHTML=convertHTML( sColValDesc );
      row.appendChild(cell);

    table.appendChild(row);
}


// addConfigRowFix('$CSV_COLS.','$TOOLTIP.','$BACKTOOLTIP.','$BACKID.','$IMG_ID.');
// function addConfigRowFix(sCsvCols, sTooltipBack, sTooltipName, sBackId, sImageId){
function addConfigRowFix(sCsvCols, sBackId, sImageId, sImageInfoID){
  var table=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');
      modifyAttribute(row,'id','projecttableheader');

      var csv = sCsvCols.split('@@');

      var backimg = CreateImageDOM(csv[0]);
        modifyAttribute(backimg,'id',sBackId);
        backimg.onclick=function(){eval(getLoadLink(csv[6])); }
        backimg.style.cursor='pointer';

      var infoImg = CreateImageDOM(csv[1]);
      if (typeof sImageInfoID!='undefined'){
        infoImg.style.cursor = 'pointer';
        infoImg.onclick=function(){eval(getLoadLink(csv[6])); }
        modifyAttribute(infoImg, 'id', sImageInfoID);
      }
      

      var pdfImg = CreateImageDOM(csv[2]);
        pdfImg.onclick=function(){eval(getLoadLink(csv[7])); }
        pdfImg.style.cursor='pointer';

      var partImg = CreateImageDOM(csv[4]);
        modifyAttribute(partImg,'id',sImageId);
        partImg.onclick=function(){eval(getLoadLink(csv[6])); }
        partImg.style.cursor='pointer';


//       options
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        modifyAttribute(cell,'height','45');
        cell.appendChild(backimg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.style.borderLeft='1px solid rgb(202,201,206)'; // row open line (only first cell in row has it)
      row.appendChild(cell);

//       info
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'height','20');
        modifyAttribute(cell,'width','20');
        cell.appendChild(infoImg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       pdf
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        cell.appendChild(pdfImg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       description
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','150');
        cell.style.paddingLeft='3px';
        cell.innerHTML=convertHTML(csv[3]);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       choice
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','70');
        cell.style.paddingLeft='3px';
        cell.appendChild(partImg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       valrangeDescription
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        cell.style.paddingLeft='3px';
        cell.innerHTML=convertHTML( csv[5] );
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.style.borderRight='1px solid rgb(202,201,206)'; // row finish line (only last cell in row has it)
      row.appendChild(cell);
    table.appendChild(row);
}

// addConfigRowDyn('$COL1_IMG.','$COL1_URL.','$COL2_IMG.','$COL3_IMG.','$COL3_URL.','$DESCRIPTION.','$IMG_PATH.','$FWD_URL.','$CONT_DESC.');"
function addConfigRowDyn(sBackImg, sBackImgID, sBackURL,sInfoImg,sPDFImg,sPDFUrl,sDescription,sPartInfoImg, sPartInfoImgID, sFwdUrl, sContent, sImageInfoID){
  var table = $('projecttable'); // this is actually a tbody element
    var row = document.createElement('tr');
//       modifyAttribute(row,'id','projecttabletr');
      modifyAttribute(row,'class','projecttabletr'); 

      var backimg = CreateImageDOM(sBackImg, '', '', 'blue_img');
        modifyAttribute(backimg,'id',sBackImgID);
        backimg.onclick=function(){eval(getLoadLink(sBackURL)); }
        backimg.style.cursor='pointer';


      var infoImg = CreateImageDOM(sInfoImg, '', '', 'blue_img');
      if (typeof sImageInfoID!='undefined'){
        infoImg.style.cursor = 'pointer';
        infoImg.onclick=function(){eval(getLoadLink(sFwdUrl)); }
        modifyAttribute(infoImg, 'id', sImageInfoID);
      }


      var pdfImg=CreateImageDOM(sPDFImg, '', '', 'blue_img');
        pdfImg.style.cursor='pointer';

      var anchorpdfImg=document.createElement('a');
//         modifyAttribute(anchorpdfImg,'href',('JavaScript:'+getStaticLink(sPDFUrl)));
      
      if((sPDFUrl!='')&&(sPDFUrl.toLowerCase()!='&nbsp;'))
      {
        modifyAttribute(anchorpdfImg,'href',sPDFUrl);
      }
        anchorpdfImg.appendChild(pdfImg);
        pdfImg.style.border='0';


      var partImg = CreateImageDOM(sPartInfoImg);
        modifyAttribute(partImg,'id',sPartInfoImgID);
        partImg.onclick=function(){eval(getLoadLink(sFwdUrl)); }
        partImg.style.cursor='pointer';

//       options
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        modifyAttribute(cell,'height','45');
        cell.appendChild(backimg);
        cell.style.borderLeft='1px solid rgb(202,201,206)'; // row open line (only first cell in row has it)
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       info
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'height','20');
        modifyAttribute(cell,'width','20');
        cell.appendChild(infoImg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       pdf
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        cell.appendChild(anchorpdfImg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       description
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','200');
        cell.style.paddingLeft='3px';
        cell.innerHTML=convertHTML( sDescription );
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       choice
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','70');
        cell.style.paddingLeft='3px';
        cell.appendChild(partImg);
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       valrangeDescription
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        cell.style.paddingLeft='3px';
        cell.innerHTML=convertHTML( sContent );
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.style.borderRight='1px solid rgb(202,201,206)'; // row finish line (only last cell in row has it)
      row.appendChild(cell);
    table.appendChild(row);
}


function setSettingsValue(iMin,iMax,id,sFwdUrl){

  var iVal=$(id).value;
  iVal=replace_comma(iVal);
  $(id).value=iVal;
  iVal = parseFloat(iVal);
  iMin = parseFloat(iMin);
  iMax = parseFloat(iMax);
  if(iVal<iMin||iVal>iMax||isNaN(iVal)){
    alert('Wertebereich zwischen '+iMin+' und '+iMax+'');
  }else{
    var sUrl=sFwdUrl+iVal+'}';
    AjaxRequest(sUrl);
  }
}

function setSettingsCombo(sUrl,sId,sValue){
  var ele=$(sId);
  sUrl+=ele.value+'}';
  AjaxRequest(sUrl);
}


function addConfigRowRange(sCol1Img,sCol1Url,sCol2Img,sCol3Img,sCol3Url,sDescription,sImage,sFwdUrl,sContentDesc,sMinVal,sMaxVal,sButton,sBackId, sImageId, sImageInfoID){
  var table=$('projecttable'); // this is actually a tbody element
    var row=document.createElement('tr');
//       modifyAttribute(row,'id','projecttabletr');
      modifyAttribute(row,'class','projecttabletr'); 

      var backimg=CreateImageDOM(sCol1Img, '', '', 'blue_img');
        modifyAttribute(backimg, 'id', sBackId);
//         backimg.onclick=function(){eval(getLoadLink(sCol1Url)); }
        backimg.onclick=function(){eval(getLoadLink(sFwdUrl + $('inputedit').value + '}&fastforward=1' )); }
        backimg.style.cursor='pointer';

      var anchor=document.createElement('a');
        modifyAttribute(anchor,'href',('JavaScript:'+getLoadLink(sCol1Url)));
      anchor.appendChild(backimg);
      
      var infoImg=CreateImageDOM(sCol2Img, '', '', 'blue_img');
      if (typeof sImageInfoID!='undefined'){
        infoImg.style.cursor = 'pointer';
        infoImg.onclick=function(){setSettingsValue(sMinVal,sMaxVal,'inputedit',sFwdUrl);}
        modifyAttribute(infoImg, 'id', sImageInfoID);
      }
      
      var pdfImg=CreateImageDOM(sCol3Img, '', '', 'blue_img');
        pdfImg.style.cursor='pointer';

      var anchor=document.createElement('a');
        modifyAttribute(anchor,'href',('JavaScript:'+getStaticLink(sCol3Url)));
      anchor.appendChild(pdfImg);

      var partImg=CreateImageDOM(sImage);
        partImg.style.cursor='pointer';
        modifyAttribute(partImg,'id',sImageId);

      var text=CreateTextDOM(sContentDesc);
      var inputField=CreateInputDOM(sMinVal, 'inputedit');
        inputField.onkeydown=function(e){if(typeof(e)=='undefined'){e=window.event;}if(e.keyCode==13){setSettingsValue(sMinVal,sMaxVal,'inputedit',sFwdUrl);}}
      var button=CreateButtonDOM(sButton);
        button.onclick=function(){setSettingsValue(sMinVal,sMaxVal,'inputedit',sFwdUrl);}

//       options
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        modifyAttribute(cell,'height','45');
        cell.style.borderLeft='1px solid rgb(202,201,206)'; // row open line (only first cell in row has it)
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(backimg);
      row.appendChild(cell);

//       info
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'height','20');
        modifyAttribute(cell,'width','20');
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(infoImg);
      row.appendChild(cell);

//       pdf
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(pdfImg);
      row.appendChild(cell);

//       description
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','200');
        cell.style.paddingLeft='3px';
        cell.innerHTML=convertHTML( sDescription );
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       choice
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','70');
        cell.style.paddingLeft='3px';
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(partImg);
      row.appendChild(cell);

//       valrangeDescription
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        cell.style.paddingLeft='3px';

//         $STGU workaround to make "RETURN" key running
//         var form = document.createElement('form');
//           modifyAttribute(form, 'onSubmit', 'return false');
//           form.appendChild(text);
//           form.appendChild(inputField);
//           form.appendChild(button);
//         cell.appendChild(form)
        
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.style.borderRight='1px solid rgb(202,201,206)'; // row finish line (only last cell in row has it)
        cell.appendChild(text);
        cell.appendChild(inputField);
        cell.appendChild(button);
      row.appendChild(cell);
    table.appendChild(row);
}

function addConfigRowCombo(sCol1Img,sCol1Url,sCol2Img,sCol3Img,sCol3Url,sDescription,sImage,sFwdUrl,sContentDesc,sCsvCols,sButton,sBackId, sImageId, sImageInfoID){
  var table = $('projecttable'); // this is actually a tbody element
    var row = document.createElement('tr');
//       modifyAttribute(row,'id','projecttabletr');
      modifyAttribute(row,'class','projecttabletr');


      var backimg=CreateImageDOM(sCol1Img, '', '', 'blue_img');
        modifyAttribute(backimg, 'id', sBackId);
//         backimg.onclick=function(){eval(getLoadLink(sCol1Url)); }
        backimg.onclick=function(){eval(getLoadLink(sFwdUrl + $('combo_item').value + '}&fastforward=1' )); }
        backimg.style.cursor='pointer';
      
      var anchor=document.createElement('a');
        anchor.appendChild(backimg);

      var infoImg=CreateImageDOM(sCol2Img, '', '', 'blue_img');
      if (typeof sImageInfoID!='undefined'){
        infoImg.style.cursor = 'pointer';
        infoImg.onclick=function(){setSettingsCombo(sFwdUrl,'combo_item');}
        modifyAttribute(infoImg, 'id', sImageInfoID);
      }

      var pdfImg=CreateImageDOM(sCol3Img, '', '', 'blue_img');
        pdfImg.style.cursor='pointer';

      var anchor=document.createElement('a');
        modifyAttribute(anchor,'href',('JavaScript:'+getStaticLink(sCol3Url)));
        anchor.appendChild(pdfImg);

      var partImg=CreateImageDOM(sImage);
        partImg.style.cursor='pointer';
        modifyAttribute(partImg,'id',sImageId);

      var text=CreateTextDOM(sContentDesc);
      var comboField=CreateComboDOM(sCsvCols);
        modifyAttribute(comboField,'id','combo_item');
        comboField.onkeydown=function(e){if(typeof(e)=='undefined'){e=window.event;}if(e.keyCode==13){setSettingsCombo(sFwdUrl,'combo_item');}}

      var button=CreateButtonDOM(sButton); 
        button.onclick=function(){setSettingsCombo(sFwdUrl,'combo_item');}

      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        modifyAttribute(cell,'height','45');
        cell.style.borderLeft='1px solid rgb(202,201,206)'; // row open line (only first cell in row has it)
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(backimg);
      row.appendChild(cell);

//       info
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'height','20');
        modifyAttribute(cell,'width','20');
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(infoImg);
      row.appendChild(cell);

//       pdf
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','center');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','20');
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(pdfImg);
      row.appendChild(cell);

//       description
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','200');
        cell.style.paddingLeft='3px';
        cell.innerHTML=convertHTML( sDescription );
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
      row.appendChild(cell);

//       choice
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        modifyAttribute(cell,'width','70');
        cell.style.paddingLeft='3px';
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.appendChild(partImg);
      row.appendChild(cell);

//       valrangeDescription
      var cell=document.createElement('td');
        modifyAttribute(cell,'align','');
        modifyAttribute(cell,'valign','top');
        cell.style.paddingLeft='3px';
        
//         $STGU workaround to make "RETURN" key running
//         var form = document.createElement('form');
//           form.appendChild(text);
//           form.appendChild(comboField);
//           form.appendChild(button);
//         cell.appendChild(form);
        
        cell.style.borderBottom='1px solid rgb(202,201,206)'; // separation line
        cell.style.borderRight='1px solid rgb(202,201,206)'; // row finish line (only last cell in row has it)
        cell.appendChild(text);
        cell.appendChild(comboField);
        cell.appendChild(button);
      row.appendChild(cell);
    table.appendChild(row);
  
}


function addConfigTableFooter(sCaption, sContent, sUrl){
  var tableFooter=$('summary');
    var tbody=document.createElement('tbody');
    var row=document.createElement('tr');
//       spacer cell
      var cell=document.createElement('td');
        modifyAttribute(cell,'width','60');
        modifyAttribute(cell,'valign','middle');
        cell.style.padding='2px';
      row.appendChild(cell);

//       description cell
      var cell=document.createElement('td');
        modifyAttribute(cell,'width','270');
        modifyAttribute(cell,'valign','middle');
        cell.style.padding='2px';
        cell.innerHTML=convertHTML( sCaption );
      row.appendChild(cell);

//       content cell
      var cell=document.createElement('td');
        modifyAttribute(cell,'valign','middle');
        cell.style.padding='2px';

        if(typeof sUrl!='undefined'){
          if (gbPartserver==1){
            var a=CreateAnchorDOM(sUrl, sContent);
            modifyAttribute(a,'target','_blank');
          }else{
              var a = CreateTextDOM(sContent);
              a.style.cursor = 'pointer';
              a.onclick = function(){
                AjaxRequest(sUrl);
            }
          }

            modifyAttribute(a,'class','projecttablelink');
            
          cell.appendChild(a);
        }else{
          cell.innerHTML = convertHTML( sContent );
        }
      row.appendChild(cell);
    tbody.appendChild(row);
    tableFooter.appendChild(tbody);
}

// addConfigTableButtons('$CSV_ITEMS.');
function addConfigTableButtons(scsvItems){
  
  var footer=$('buttons');
    var body=document.createElement('tbody');
    var row=document.createElement('tr');
      var cell=document.createElement('td');
        modifyAttribute(cell,'class','prjpointtd');
        cell.style.border='1px solid rgb(202,201,206)';
        cell.style.paddingLeft='5px';
        cell.style.paddingRight='5px';
        cell.style.textAlign='center';
//         cell.style.backgroundColor='rgb(2,44,67)';
        cell.style.backgroundColor='#ffffff'; 
        modifyAttribute(cell,'colspan','3');

        var div=document.createElement('div');
          modifyAttribute(div,'class','projectpointcontent');
          div.style.textAlign='center';

          var form=document.createElement('form');
            modifyAttribute(form,'onSubmit','return false');
            modifyAttribute(form,'name','inputform');

          var csv=scsvItems.split('@@');
          for (i=0;i<csv.length;i++){
            var btn=CreateButtonDOMJS(csv[i].split('##')[0], csv[i].split('##')[1]);
//             var spacer = CreateTextDOM('&nbsp;');
            form.appendChild(btn);
//             form.appendChild(spacer);
          }
        div.appendChild(form);
      cell.appendChild(div);
    row.appendChild(cell);
    body.appendChild(row);
  footer.appendChild(body);
}


// addCadExportTableHeader('$CAPTION.');
function addCadExportTableHeader(sCaption){
  // show tab_valueranges since it was hidden (will only make a difference in IE)
  $('tab_valueranges');
//   $('tab_valueranges').style.display='block'; // restore display property
//   modifyAttribute($('tab_valueranges'),'hiddenByHideDiv','false'); // flag it as no longer hidden by hidediv
  
  var table=$('cadexporttable');

//     <tr class="projecttableheader">
//       <td align="" valign="center" height="22" colspan="3" class="projecttabletd" style="padding-left:5px;"><!-- begin ID CADEXPORT_BUTTON-->CAD Export<!-- end ID CADEXPORT_BUTTON--></td>
//     </tr>
  var body=document.createElement('tbody');
    var row=document.createElement('tr');
      modifyAttribute(row,'class','projecttableheader');

      var cell=document.createElement('td');
        modifyAttribute(cell,'valign','middle');
//         modifyAttribute(cell,'valign','center');
        modifyAttribute(cell,'height','22');
        modifyAttribute(cell,'colspan','3'); // Safari only accepts 'colspan', not 'colSpan', every other browser accepts both
        modifyAttribute(cell,'class','projecttabletd');
        cell.style.paddingLeft='5px';
        cell.style.border='1px solid rgb(202,201,206)';
        cell.style.backgroundColor='#e8e8e8';
        cell.innerHTML=convertHTML( sCaption );
      row.appendChild(cell);
    body.appendChild(row);
  table.appendChild(body);
}

function addExportRow(sButton,sUrl,sFormat){
  var table=$('cadexporttable');
  var body=document.createElement('tbody');
    var row=document.createElement('tr');
//       spacer
      var cell=document.createElement('td');
        modifyAttribute(cell,'valign','middle');
        modifyAttribute(cell,'width','60');
        cell.style.padding='5px';
        cell.style.borderBottom='1px solid rgb(202,201,206)';
        cell.style.borderLeft='1px solid rgb(202,201,206)';
        cell.innerHTML='&nbsp;';
      row.appendChild(cell);

//       format
      var cell=document.createElement('td');
        modifyAttribute(cell,'valign','middle');
        modifyAttribute(cell,'width','270');
        cell.style.padding='5px';
        cell.style.borderBottom='1px solid rgb(202,201,206)';
        cell.innerHTML = convertHTML( sFormat );
      row.appendChild(cell);

//       button
      var cell=document.createElement('td');
        modifyAttribute(cell,'valign','middle');
        cell.style.padding='5px';
        cell.style.borderBottom='1px solid rgb(202,201,206)';
        cell.style.borderRight='1px solid rgb(202,201,206)';
        var btn=CreateButtonDOM(sButton, sUrl);
        cell.appendChild(btn);
      row.appendChild(cell);
    body.appendChild(row);
  table.appendChild(body);
}


function addbasketContentHead(sCaption){

  $('tablesandvalueranges', false).style.display='none'; // part of Firefox workaround
  var oDiv=$('basket_summary');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'cellspacing','0');
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');

      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          modifyAttribute(oRow,'class','projecttableheader');
  
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'colspan','2');
            modifyAttribute(oCell,'class','projecttabletd');
            modifyAttribute(oCell,'valign','middle'); // ??
            modifyAttribute(oCell,'height','22');
            modifyAttribute(oCell,'align','left');
            oCell.style.fontSize='15px'; // be huge
            oCell.style.fontWeight='bold'; // be bold
          oCell.innerHTML=convertHTML( sCaption );
  
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}


// "addbasketContentHead1('$AMOUNT.',''$DESCRIPTION.');" &vbcrlf
function addbasketContentHead1(sAmount, sDescription){
//   baskettabletd
  $('tablesandvalueranges', false).style.display='none'; // part of Firefox workaround
  var oDiv=$('basket_summary');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');

      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
//           modifyAttribute(oRow,'class','projecttableheader');
  
          var oCell=document.createElement('td');
            oCell.style.borderLeft = '1px solid rgb(202,201,206)';
            oCell.style.borderTop = '1px solid rgb(202,201,206)';

            modifyAttribute(oCell, 'width', '40');
            oCell.style.width = '40';
            modifyAttribute(oCell, 'class', 'baskettabletd');
            modifyAttribute(oCell, 'height', '22');
            modifyAttribute(oCell, 'align', 'left');
            oCell.style.fontWeight='bold'; // be bold
          oCell.innerHTML=convertHTML( sAmount );
        oRow.appendChild(oCell);

          var oCell=document.createElement('td');
            oCell.style.borderTop = '1px solid rgb(202,201,206)';
            
            modifyAttribute(oCell, 'class', 'baskettabletd');
            modifyAttribute(oCell, 'colspan', '2');
            modifyAttribute(oCell, 'height', '22');
            modifyAttribute(oCell, 'align','left');
            oCell.style.fontWeight='bold'; // be bold
          oCell.innerHTML=convertHTML( sDescription );
        oRow.appendChild(oCell);
        
//           dummy cell 
            var oCell=document.createElement('td');
              oCell.style.borderTop = '1px solid rgb(202,201,206)';
              oCell.style.borderRight = '1px solid rgb(202,201,206)';
  
              modifyAttribute(oCell,'class','baskettabletd');
              modifyAttribute(oCell,'height','22');
              modifyAttribute(oCell,'align','right');
              
          oCell.innerHTML='&nbsp;';
        oRow.appendChild(oCell);
  
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);

}

function addbasketContentItem(sAmountMain, sDescMain, sUrlCad, sUrlClear, sCsvAccessories, sAccessoryCaption, sAccessoryUrl, sAccessoryQuestion, CookieObj, sConfigUrl)
{
  
  /*
      examples of a function call
      
      addbasketContentItem('1',
                            'Mainitem',
                            '/some/uri?to=cad',
                            '/some/other/uri?to=clear',
                            '5##Subitem 1@@100##Subitem 2');
  */
    
    if(gsUserDataRequired == '')
    {
      var sUserDataRequired = 'Please fill out all fields marked with the "*" sign.';
    }
    else
    {
      var sUserDataRequired = gsUserDataRequired;
    }
  
    var oDiv=$('basket_summary');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
    modifyAttribute(oTable,'cellspacing','0');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');

          var oCell=document.createElement('td');
          modifyAttribute(oCell,'height','20');
          modifyAttribute(oCell, 'colspan', '3');
          oCell.style.borderTop='1px solid rgb(202,201,206)';
          oCell.style.borderLeft='1px solid rgb(202,201,206)';
          oCell.style.backgroundColor='#c3c3c3'; 
          oCell.style.paddingLeft='2px';

            var oInput=document.createElement('input');
            modifyAttribute(oInput,'width','40');
            modifyAttribute(oInput,'type','text');
            
            iStaticFieldNr++; 
            modifyAttribute(oInput,'basketid',iStaticFieldNr);
            
            oInput.style.border='medium none';
            oInput.style.verticalAlign='middle';
            oInput.style.width='40px';
            oInput.style.height='17px';
            modifyAttribute(oInput,'value',sAmountMain);
            modifyAttribute(oInput,'name','countinp');

          oCell.appendChild(oInput);

            var oSpan=document.createElement('span');
            modifyAttribute(oSpan,'class','projecttablelink');
            oSpan.onclick = function(){
              if (gbPartserver==1){
                
                AjaxRequest(sConfigUrl);
              }else{
                AjaxRequest(sUrlCad);
              }
            }
            oSpan.innerHTML=convertHTML( sDescMain );
          oCell.appendChild(oSpan);
        oRow.appendChild(oCell);


          var oCell=document.createElement('td');
          modifyAttribute(oCell,'height','20');
          oCell.style.borderTop='1px solid rgb(202,201,206)';
          oCell.style.borderRight='1px solid rgb(202,201,206)';
          oCell.style.backgroundColor='#c3c3c3'; 
          oCell.style.paddingLeft='2px';
          oCell.style.textAlign='right';

            if(typeof sAccessoryCaption!='undefined'){
              var oSpan=document.createElement('span');
              oSpan.style.cursor = 'pointer';
              modifyAttribute(oSpan, 'id', 'addAccessoryText');
              oSpan.innerHTML=convertHTML( sAccessoryCaption );
              oCell.appendChild(oSpan);
  
              var spacer = CreateImageDOM(gsRoot+'/guide/image/spacer.gif', 1, 3);
              oCell.appendChild(spacer);

            }
          
            if(typeof sAccessoryUrl!='undefined' && sAccessoryUrl!=''){
              oSpan.onclick=function(){
                if (confirm(sAccessoryQuestion)){
//                   AddAcc(sUrl, cookieid, lina, path){
                  AddAcc(sAccessoryUrl, CookieObj['CookieID'], CookieObj['PrjVal']['LINA'], CookieObj['PrjVal']['RelPath'], CookieObj['PrjVal']['ParamList']);
//                   eval(getLoadLink(sAccessoryUrl));
                }
              }
            }
            
            /*
            
             *note1* = without this, certain images will appear smaller in ie than they do in other browsers
                       check if it is some kind of caching problem
                       if it is, remove these instructions
            
            */

            var oImgCad = CreateImageDOM(gsRoot+'/guide/image/cad.gif','','','blue_img');
//             var oImgCad=document.createElement('img');
//             modifyAttribute(oImgCad,'src',gsRoot+'/guide/image/cad.gif');
//             oImgCad.style.height='20px'; // *note1*
//             oImgCad.style.width='30px'; // *note1*

            oImgCad.onclick=function(){
              
//               if (gbPartserver==1){
//                 
//                 if(orderFormFilledCorrectly() == true) // if user data has been entered
//                 {
//                   eval( sUrlCad ); // dopreview(...);
//                 }
//                 else // otherwise
//                 {
//                   alert(sUserDataRequired); // display message 'user data required'
//                   eval(gsEnterUserdataFunction); // enter user data
//                 }
//                 
//               }else{
                AjaxRequest( sUrlCad );
//               }
              
            }
            
            oImgCad.style.cursor='pointer';

            var spacer = CreateImageDOM(gsRoot+'/guide/image/spacer.gif', 1, 3);
            oCell.appendChild(spacer);

          oCell.appendChild(oImgCad);
            var oImgClear = CreateImageDOM(gsRoot+'/guide/image/del_small.gif','','','blue_img');
//             var oImgClear=document.createElement('img');
//             modifyAttribute(oImgClear,'src',gsRoot+'/guide/image/del_small.gif');
//             oImgClear.style.height='20px'; // *note1*
//             oImgClear.style.width='30px'; // *note1*
            var sCurrentSettings = '';
            var sBasketPath = '/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/ahp_assistant.vbb&option=basket&path=$CADENAS_DATA/23d-libs/ahp&partserver=' + gbPartserver + '&basket=add&settings=';
            sBasketPath += sCurrentSettings +'&language=' +gsLanguage+ '&root=' +gsRoot+ '&cleanup=navigationarea,foldersandtooltips,prjNB,prjicon,prjdesc,pdficon,pdflink,projecthead,tableheadline,projecttable,summary,buttons,switch_unit,cadexporttable,basket_summary,basket_options,basket_export&hide=tablesandvalueranges,tab_valueranges&update=updateNav';

//             if (gbPartserver==1){
              oImgClear.onclick=function(){
                eval(sUrlClear);
                AjaxRequest(sBasketPath);}
//             }else{
//               oImgClear.onclick=function(){eval(sUrlClear);}
//             }
            oImgClear.style.cursor='pointer';

            var spacer = CreateImageDOM(gsRoot+'/guide/image/spacer.gif', 1, 3);
            oCell.appendChild(spacer);
          oCell.appendChild(oImgClear);

        oRow.appendChild(oCell);
      oBody.appendChild(oRow);

        if ( typeof sCsvAccessories!='undefined' && sCsvAccessories!='' ) {
          
          var oAccessories=sCsvAccessories.split('@@');
  
          for(var i=0;i<oAccessories.length;i++)
          {
            var oAccessory=oAccessories[i].split('##');
            var oRow=document.createElement('tr');
            oRow.style.backgroundColor='#e8e8e8'; // background color for accessories row
            
              var oCell=document.createElement('td');
  
                oCell.style.paddingLeft='40px'; // pad as wide as the input is
                oCell.style.borderLeft='1px solid rgb(202,201,206)';
                oCell.style.borderBottom='1px solid rgb(202,201,206)';
              
                modifyAttribute(oCell,'colspan','3');
                
                  var oInput=document.createElement('input');
                    modifyAttribute(oInput,'width','40');
                    modifyAttribute(oInput,'type','text');
                    oInput.style.border='medium none';
                    oInput.style.verticalAlign='middle';
                    oInput.style.width='40px';
                    oInput.style.height='17px';
                    modifyAttribute(oInput,'value',oAccessory[0]);
                    modifyAttribute(oInput,'name','countinp');
                    modifyAttribute(oInput,'basketid',iStaticFieldNr); 
                    modifyAttribute(oInput,'basketsubid',i); 
                  oCell.appendChild(oInput);
  
                  var oSpan=document.createElement('span');
                    oSpan.style.paddingLeft='5px';
                    oSpan.innerHTML=convertHTML( oAccessory[1] );
                  oCell.appendChild(oSpan);

  
              oRow.appendChild(oCell);

//               dummy cell 
              var oCell=document.createElement('td');
                oCell.style.borderRight='1px solid rgb(202,201,206)';
                oCell.style.borderBottom='1px solid rgb(202,201,206)';

                modifyAttribute(oCell,'height','22');
                modifyAttribute(oCell,'align','right');
              oCell.innerHTML='&nbsp;';
              
              oRow.appendChild(oCell);
              
            oBody.appendChild(oRow);
          }
        }
    oTable.appendChild(oBody);  
  oDiv.appendChild(oTable);
}

  
function addbasketOptionsHead(sCaption)
{
  iStaticFieldNr=-1; // reset field counter
  var oDiv=$('basket_options');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          modifyAttribute(oRow,'class','projecttableheader');
  
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'class','projecttabletd');
            modifyAttribute(oCell,'valign','middle'); // ??
            modifyAttribute(oCell,'height','22');
            modifyAttribute(oCell,'align','left');
            oCell.innerHTML=convertHTML( sCaption );
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}

function addbasketOptionsButtons(sAcceptCaption,sAcceptUrl, sUpdateCaption,sUpdateUrl, sClearCaption,sClearUrl, sOrderCaption,sOrderUrl, sOptionalCaption,sOptionalUrl)
{
  
  if(gsUserDataRequired == '')
  {
    var sUserDataRequired = 'Please fill out all fields marked with the "*" sign.';
  }
  else
  {
    var sUserDataRequired = gsUserDataRequired;
  }
  
  
  //
  // This is how the 'Send CAD Data' button event handler will be reassigned within 'order.js'.
  //
  //   if valid user data is stored within cookie
  //     --> assign event handler: order cad data from partserver (defined in this function)
  //
  //   otherwise
  //     --> display order form
  //     --> assign event handler: validate form data (defined in 'displayOrderForm' in 'order.js')
  //
  //      if data entered is valid 
  //        --> store user data
  //        --> order cad data from PARTserver
  //
  //      if form is cancelled
  //        --> reassign event handler depending on data stored within cookie (defined in 'cancel' in 'order.js')
  //
  //      if form is saved with success
  //        --> assign event handler: order cad data from partserver (defined in 'saveSettings' in 'order.js')
  //
  
  // global variables required to reassign the event handler for the 'Send CAD data' button
  gsEnterUserdataFunction = sOptionalUrl; // store javascript command to enter user data (global variable)
  gsOrderCadDataFunction = sClearUrl; // store javascript command to send cad data (global variable)
  
  var oDiv=$('basket_options');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
      modifyAttribute(oTable,'border','0');
      modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
        
          var oCell=document.createElement('td');
          modifyAttribute(oCell,'class','prjpointtd');
          oCell.style.border='1px solid rgb(202,201,206)';
          oCell.style.textAlign='center';
          oCell.style.backgroundColor='#ffffff'; 
//           oCell.style.backgroundColor='rgb(2,44,67)';
          
            var oForm=document.createElement('form');
              modifyAttribute(oForm,'class','prjpointcontent');
              oForm.style.textAlign='center';
              oForm.onsubmit=function(){return false;}
              oForm.name='inputform';
        
              var oAcceptButton=CreateButtonDOMJS(sAcceptCaption,sAcceptUrl);
              oForm.appendChild(oAcceptButton);
              var oUpdateButton=CreateButtonDOMJS(sUpdateCaption,sUpdateUrl);
              oForm.appendChild(oUpdateButton);
              
              if(gbPartserver == 1) // partserver
              {
                
                if(orderFormFilledCorrectly() == true) // check if order form is filled correctly
                {
                  
                  // create button with event handler as defined in global gsOrderCadDataFunction
                  // (order CAD data on click)
                  
                  var oClearButton=CreateButtonDOMJS(sClearCaption,gsOrderCadDataFunction);
                  
                  // *********************************************************************************
                  // *                                                                               *
                  // *      the event handler of this button will be MODIFIED within 'order.js'      *
                  // *                                                                               *
                  // *********************************************************************************
                  
                }
                else
                {
                  
                  // create button without event handler in the first place, since the event handler
                  // will be defined in the lines below
                  
                  var oClearButton=CreateButtonDOMJS(sClearCaption);
                  
                  
                  // now define the event handler
                  
                  oClearButton.onclick = function()
                  {
                    alert(sUserDataRequired); // display 'user data required' message
                    eval(gsEnterUserdataFunction); // display form and ask the user for his data
                  }
                  
                  // *********************************************************************************
                  // *                                                                               *
                  // *      the event handler of this button will be MODIFIED within 'order.js'      *
                  // *                                                                               *
                  // *********************************************************************************
                  
                }
                
              }
              else // local
              {
                // create button
//                 var oClearButton=CreateButtonDOMJS(sClearCaption,sClearUrl);
                var oClearButton=CreateButtonDOMJS(sClearCaption);
                
                oClearButton.onclick = function() // event handler
                {
                  eval(sClearUrl); // clear basket
                  eval(sUpdateUrl); // update basket
                }
                                
              }
              
              oForm.appendChild(oClearButton);

              if (gbPartserver==1){
//               STGU TO BE REMOVED
//               ANPL - Function is now implemented. No need to leave this disabled.
//                 modifyAttribute(oUpdateButton, 'disabled', 'disabled');
                
//                 orderFormFilledCorrectly() is defined in order.js

                modifyAttribute(oClearButton, 'id', 'btn_send_cad'); // required for identification of the element later on
              }
              
              var oBr=document.createElement('br');
              oForm.appendChild(oBr);
              
              var oOrderButton=CreateButtonDOMJS(sOrderCaption,sOrderUrl);
              //modifyAttribute(oOrderButton, 'disabled', 'disabled');
              oForm.appendChild(oOrderButton);
              if((typeof sOptionalCaption!='undefined')&&(typeof sOptionalUrl!='undefined'))
              {
                var oOptionalButton=CreateButtonDOMJS(sOptionalCaption,sOptionalUrl);
                oForm.appendChild(oOptionalButton);
              }
        
          oCell.appendChild(oForm);
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}


function addbasketExportHead(sCaption)
{
  var oDiv=$('basket_export');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          modifyAttribute(oRow,'class','projecttableheader');
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'class','projecttabletd');
            modifyAttribute(oCell,'valign','middle');
//             modifyAttribute(oCell,'valign','center');
            modifyAttribute(oCell,'height','22');
            modifyAttribute(oCell,'align','left');
            oCell.innerHTML=convertHTML( sCaption );
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}

function addbasketExportButtons(sImportCaption,sImportUrl, sExportCaption,sExportUrl)
{
  var oDiv=$('basket_export');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          var oCell=document.createElement('td');
          modifyAttribute(oCell,'class','prjpointtd');
          oCell.style.border='1px solid rgb(202,201,206)';
          oCell.style.textAlign='center';
          oCell.style.backgroundColor='#ffffff'; 
//           oCell.style.backgroundColor='rgb(2,44,67)';
          
            var oForm=document.createElement('form');
            modifyAttribute(oForm,'class','prjpointcontent');
            oForm.style.textAlign='center';
            oForm.onsubmit=function(){return false;}
            oForm.name='inputform';
  
            var oImportButton=CreateButtonDOM(sImportCaption,sImportUrl);
            oForm.appendChild(oImportButton);
            var oExportButton=CreateButtonDOM(sExportCaption,sExportUrl);
            oForm.appendChild(oExportButton);
  
          oCell.appendChild(oForm);
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}

function displaybasketFromCookie(sAccessoryCaption, sAccessoryUrl, sAccessoryQuestion)
{
//   quick fix not to display the "add accessories / seal kit"
//   var sPath = getHTMLargument('path');
  
  if (typeof sAccessoryCaption=='undefined')  { sAccessoryCaption = ''; };
  if (typeof sAccessoryUrl=='undefined')      { sAccessoryUrl = ''; };
  if (typeof sAccessoryQuestion=='undefined') { sAccessoryQuestion = ''; };

//   if (typeof sAccessoryCaption=='undefined')  { sAccessoryCaption = sAddAccessoriesMessage; };
//   if (typeof sAccessoryUrl=='undefined')      { sAccessoryUrl = '/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/ahp_assistant.vbb&option=basket&path=' +sPath+ PARTserverLink+ '&settings='; };
//   if (typeof sAccessoryQuestion=='undefined') { sAccessoryQuestion = sAddAccessoriesQuestion; };

  var oCookie=new ReadAllPrjFromCookies();
  if(oCookie['CountPrj']>0) // if there are projects
  {
    for(var i=0;i<oCookie['CountPrj'];i++) // iterate through the projects
    {
      var sCsvAccessories='';
      
      if(oCookie[i]['HasAcc']) // if there are accessories
      {
        for(var j=0;j<oCookie[i]['CountAcc'];j++) // iterate through the accesssories
        {
          if(j>0) // if it's not the first item
          {
            sCsvAccessories+='@@'; // we need some separator
          }
          sCsvAccessories+=oCookie[i][j]['AccVal']+'##'+oCookie[i][j]['AccName']; // build csv string
        }
      }
      // parameters for the function call
      var sAmountMain=oCookie[i]['PrjVal']['Count'];
      var sDescMain=oCookie[i]['PrjVal']['LINA'];
//       var sUrlCad='dopreview(\''+oCookie[i]['PrjVal']['RelPath']+'\',\''+oCookie[i]['PrjVal']['ParamList']+'\');';
//       alert(sUrlCad);
      var sUrlClear='deletebasket(\''+oCookie[i]['CookieID']+'\');';

      var sConfigUrl = '/cgi-bin/vbshtmlcgi.cgi?script=$CADENAS_DATA/23d-libs/ahp/guide/script/ahp_assistant.vbb&option=config&path=' +oCookie[i]['PrjVal']['RelPath']+ '&settings=' +oCookie[i]['PrjVal']['ParamList']+ '&root=' +gsRoot+ '&partserver=' +gbPartserver+ '&language=' +gsLanguage+ '&cleanup=projecttable,basket_summary,basket_options,basket_export,order_userdata,order_request,order_options,navigationarea,orderform';
      var sUrlCad = sConfigUrl; // cad button should configure part

      if(oCookie[i]['HasAcc']){
        // display basket item
        addbasketContentItem(sAmountMain,sDescMain,sUrlCad,sUrlClear,sCsvAccessories,'','','','',sConfigUrl);
        
      }else{
//         convert the texts from the MediaDB to HTML format (unicode escape signs)
        sAccessoryCaption = convertHTML(sAccessoryCaption);
        // display basket item
        addbasketContentItem(sAmountMain,sDescMain,sUrlCad,sUrlClear, '', sAccessoryCaption, sAccessoryUrl, sAccessoryQuestion, oCookie[i], sConfigUrl);
      }
    }
  }
}


function addOrderHeadLine1(sCaption){
  var oDiv=$('order_userdata');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          modifyAttribute(oRow,'class','projecttableheader');
  
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'class','projecttabletd');
            modifyAttribute(oCell,'valign','middle'); // ??
            modifyAttribute(oCell,'height','22');
            modifyAttribute(oCell,'align','left');
            oCell.innerHTML=convertHTML( sCaption );
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}


function addOrderHeadLine2(sCaption){
//   var oDiv=$('order_request');
    var oDiv=$('inner_orderhead_div'); 
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          modifyAttribute(oRow,'class','projecttableheader');
  
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'class','projecttabletd');
            modifyAttribute(oCell,'valign','middle'); // ??
            modifyAttribute(oCell,'height','22');
            modifyAttribute(oCell,'align','left');
            oCell.innerHTML=convertHTML( sCaption );
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}


function addOrderHeadLine3(sCaption){
  var oDiv=$('order_options');
    try
    {
      var oTable=$(oDiv.id+'_table'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table');
    }
    modifyAttribute(oTable,'border','0');
    modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow=document.createElement('tr');
          modifyAttribute(oRow,'class','projecttableheader');
  
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'class','projecttabletd');
            modifyAttribute(oCell,'valign','middle'); // ??
            modifyAttribute(oCell,'height','22');
            modifyAttribute(oCell,'align','left');
            oCell.innerHTML=convertHTML( sCaption );
        oRow.appendChild(oCell);
      oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}


// VB code sample how this method will be called
// ================
// sKeyValuePairCSV = sKeyValuePairCSV & sCompanyDesc &"##"& sCompany &"@@"&     sDivisionDesc &"##"& sDivision &"@@"
// sKeyValuePairCSV = sKeyValuePairCSV & sEmailDesc &"##"& sEmail &"@@"&         sKnrDesc &"##"& sKnr &"@@"
// sKeyValuePairCSV = sKeyValuePairCSV & sFirstnameDesc &"##"& sFirstname &"@@"& sLastnameDesc &"##"& sLastname &"@@"
// sKeyValuePairCSV = sKeyValuePairCSV & sStreetDesc &"##"& sStreet &"@@"
// sKeyValuePairCSV = sKeyValuePairCSV & sZipDesc &"##"& sZip &"@@"&             sCityDesc &"##"& sCity &"@@"
// sKeyValuePairCSV = sKeyValuePairCSV & sCountryDesc &"##"& sCountry &"@@"&     sStateDesc &"##"& sState &"@@"
// sKeyValuePairCSV = sKeyValuePairCSV & sPhoneDesc &"##"& sPhone &"@@"&         sFaxDesc &"##"& sFax 
// 
// sAddOrderUserData = data.templates.addOrderuserData
// sAddOrderUserData = replace(sAddOrderUserData, "$CSV_COLS.", sKeyValuePairCSV)

function addOrderuserData(sCsvCols){
  cleanupDiv('orderform')
  var oDiv=$('order_userdata');
    try
    {
      var oTable=$(oDiv.id+'_table_data'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table_data');
    }
  
      modifyAttribute(oTable,'border','0');
      modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
      var csv = sCsvCols.split('@@');
      
      var oRow=document.createElement('tr');
      
      var oArrangementArray=new Array();
      
      // oArrangementArray[new_position]=old_position;
      
      oArrangementArray[0]=0; // firm
      oArrangementArray[1]=1; // department
      oArrangementArray[2]=5; // last name
      oArrangementArray[3]=3; // customer id
      oArrangementArray[4]=4; // first name
      oArrangementArray[5]=6; // street
      oArrangementArray[6]=7; // postal code
      oArrangementArray[7]=8; // city
      oArrangementArray[8]=9; // country
      oArrangementArray[9]=11; // telephone
      oArrangementArray[10]=12; // telefax
      oArrangementArray[11]=2; // email
      
      for (i=0; i<oArrangementArray.length; i++){
        var caption = csv[oArrangementArray[i]].split('##')[0];
        var content = csv[oArrangementArray[i]].split('##')[1];
        
        if (((i%2)==0)||(i>5)){
          oBody.appendChild(oRow);
          var oRow=document.createElement('tr');
        }
      
//         var oCell=document.createElement('td');
//           modifyAttribute(oCell,'width','10'); // ??
//           modifyAttribute(oCell,'height','22');
//           modifyAttribute(oCell,'align','left');
//           oCell.innerHTML='&nbsp;';
//         oRow.appendChild(oCell);

        var txt = CreateTextDOM(caption);
        modifyAttribute(txt, 'align', 'left');
//         modifyAttribute(txt, 'valign', 'left')
        
        if(i==6)
        {
          var oOuterCell=document.createElement('td');
            var oInnerTable=document.createElement('table');
              modifyAttribute(oInnerTable,'width','100%');
              modifyAttribute(oInnerTable,'cellspacing','0');
              modifyAttribute(oInnerTable,'cellpadding','0');
              var oInnerBody=document.createElement('tbody');
                var oInnerRow=document.createElement('tr');
        }
        
        var oCell=document.createElement('td');
          modifyAttribute(oCell,'width','50%'); // ??
          modifyAttribute(oCell,'height','22');
          modifyAttribute(oCell,'align','left');
          oCell.style.paddingLeft='10px';
          oCell.style.paddingRight='10px';
          oCell.appendChild(txt);
          
//         !! IMPORTANT: needs to be 'input_'+i due to basket.js -> evaluating the arguments of the form 'userdata' !!
//         Index used for iteration has been changed. oArrangemantArray[i] will hold the "old" index.
          
//           var oBr=document.createElement('br');
//           oCell.appendChild(oBr);
          
          var eLine = CreateInputDOM(content, String('input_'+oArrangementArray[i]));
            eLine.style.width='100%';
            modifyAttribute(eLine, 'align', 'right');
//             modifyAttribute(eLine, 'valign', 'right');
          oCell.appendChild(eLine);

        if((i!=6)&&(i!=7))
        {
          oRow.appendChild(oCell);
        }else{
          oInnerRow.appendChild(oCell);
        }
        
        if(i==7)
        {
                oInnerBody.appendChild(oInnerRow);
              oInnerTable.appendChild(oInnerBody);
            oOuterCell.appendChild(oInnerTable);
          oRow.appendChild(oOuterCell);
          
          var oCell=document.createElement('td');
            modifyAttribute(oCell,'width','50%');
            modifyAttribute(oCell,'align','left');
            modifyAttribute(oCell,'valign','top');
            modifyAttribute(oCell,'rowspan','5');
            
            var oInnerDiv=document.createElement('div');
              modifyAttribute(oInnerDiv,'id','inner_orderhead_div');
            oCell.appendChild(oInnerDiv);
            
            var oInnerDiv=document.createElement('div');
              modifyAttribute(oInnerDiv,'id','inner_orderbody_div');
            oCell.appendChild(oInnerDiv);
            
          oRow.appendChild(oCell);
        }

//         modifyAttribute(eLine, 'id', 'input_'+i);
//         var oCell=document.createElement('td');
//           modifyAttribute(oCell,'width','10'); // ??
//           modifyAttribute(oCell,'height','22');
//           modifyAttribute(oCell,'align','left');
//           oCell.appendChild(eLine);
//         oRow.appendChild(oCell);
      }
//       append last row
      oBody.appendChild(oRow);
    
//       read saved values from cookie
//         $STGU: FIXME - I am not working ;)
//       $('input_0').value = ReadValsFromCookie("input_0");
//       $('input_1').value = ReadValsFromCookie("input_1");
//       $('input_2').value = ReadValsFromCookie("input_2");
//       $('input_3').value = ReadValsFromCookie("input_3");
//       $('input_4').value = ReadValsFromCookie("input_4");
//       $('input_5').value = ReadValsFromCookie("input_5");
//       $('input_6').value = ReadValsFromCookie("input_6"); 
//       $('input_7').value = ReadValsFromCookie("input_7");
//       $('input_8').value = ReadValsFromCookie("input_8");
//       $('input_9').value = ReadValsFromCookie("input_9");
//       $('input_10').value = ReadValsFromCookie("input_10");
//       $('input_11').value = ReadValsFromCookie("input_11");
//       $('input_12').value = ReadValsFromCookie("input_12");
    
    
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
}

function addOrderRequest(sType,sOrder,sRequest,sCommentsDesc,sComments){


//   var oDiv=$('order_request');
    var oDiv=$('inner_orderbody_div'); 
    try
    {
      var oTable=$(oDiv.id+'_table_data'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table_data');
    }
      modifyAttribute(oTable,'border','0');
      modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
      
        var oRow = document.createElement('tr');
//           var oCell = document.createElement('td');
//             modifyAttribute(oCell, 'height', '26');
//             oCell.innerHTML = '&nbsp;';
//           oRow.appendChild(oCell);

          var oCell = document.createElement('td');
            modifyAttribute(oCell, 'valign', 'top');
            oCell.innerHTML = convertHTML( sType );
          oRow.appendChild(oCell);
        oBody.appendChild(oRow);

        var oRow=document.createElement('tr');
          var oCell = document.createElement('td');
            modifyAttribute(oCell, 'colspan', '4');
            var oSelectBox = document.createElement('select');
              modifyAttribute(oSelectBox, 'id', 'ordertype');
              var option = document.createElement('option');
                modifyAttribute(option, 'value', 'order');
                if (sOrder.split('##').length != 0){ 
                  modifyAttribute(option, 'selected', 'selected');
                  sOrder = sOrder.split('##')[0];
                }
                option.innerHTML = convertHTML( sOrder );
              oSelectBox.appendChild(option);

              var option = document.createElement('option');
                modifyAttribute(option, 'value', 'request');
                if (sRequest.split('##').length != 0){ 
                  modifyAttribute(option, 'selected', 'selected');
                  sRequest = sRequest.split('##')[0];
                }
                option.innerHTML = convertHTML( sRequest );
              oSelectBox.appendChild(option);
              oSelectBox.style.width='100%';
            
            oCell.appendChild(oSelectBox);
          oRow.appendChild(oCell);
        oBody.appendChild(oRow);
          
        var oRow = document.createElement('tr');

          var oCell = document.createElement('td');
            modifyAttribute(oCell, 'valign', 'top');
            oCell.innerHTML = convertHTML( sCommentsDesc );
          oRow.appendChild(oCell);
          
        oBody.appendChild(oRow);
        var oRow=document.createElement('tr');

          var oCell = document.createElement('td');
            modifyAttribute(oCell, 'colspan', '4');
            var oTxtArea = CreateTextAreaDOM(sComments);
            
//             !! IMPORTANT: needs to be 'comments' due to basket.js -> evaluating the arguments of the form 'userdata' !!
            modifyAttribute(oTxtArea, 'id', 'comments'); 
            oTxtArea.style.width='100%';
            oTxtArea.style.height='140';
            oCell.appendChild(oTxtArea);
          oRow.appendChild(oCell);
          
        oBody.appendChild(oRow);
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);

}


function addOrderPrint(sSave, sSaveUrl, sPrint, sPrintUrl, sMissing){
  var oDiv=$('order_options');
    try
    {
      var oTable=$(oDiv.id+'_table_data'); // get existing table
      var oType=oTable.nodeType; // this will throw an error if table does not exist
    }catch(e){
      var oTable=document.createElement('table'); // create new table
      modifyAttribute(oTable,'id',oDiv.id+'_table_data');
    }
      modifyAttribute(oTable,'border','0');
      modifyAttribute(oTable,'width','100%');
      var oBody=document.createElement('tbody');
        var oRow = document.createElement('tr');
          var oCell = document.createElement('td');
            modifyAttribute(oCell, 'class','prjpointtd');
            modifyAttribute(oCell, 'colspan','6');
    
            oCell.style.textAlign='center';
            oCell.style.border='1px solid rgb(202,201,206)';
            oCell.style.backgroundColor='#ffffff';
//             oCell.style.backgroundColor='rgb(2,44,67)';
            
            var oForm = document.createElement('form');
              modifyAttribute(oForm, 'name', 'inputform');
              modifyAttribute(oForm, 'onSubmit', 'return false');
              modifyAttribute(oForm, 'class', 'prjpointcontent');
              oForm.style.textAlign = 'center';
              
              var btn = CreateButtonDOMJS(sSave, 'UpdateValuesAndSubmit(\'\');');
              oForm.appendChild(btn);
              var btn = CreateButtonDOMJS(sPrint, 'UpdateValuesAndSubmit(\'print\', \'' +gsRoot+ '\');');
              oForm.appendChild(btn);
            oCell.appendChild(oForm);
          oRow.appendChild(oCell);
          
        oBody.appendChild(oRow);
      
    oTable.appendChild(oBody);
  oDiv.appendChild(oTable);
  ReadFromAllCookies(); // now that the form is built, read user data from cookies
}

/*
  obsolete -> if the building via DOM fails this is the fallback
*/
function createFlashHtml(){

  var AddParams = '&partserver='+gbPartserver+'&language='+gsLanguage+'&root='+gsRoot+'&'+gsFlashSuffix;
  
  AddParams = escape(AddParams);

  var flashDiv = $('flash');

    var sHtml = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="660" height="440" id="flashguide">';
    sHtml += '<param name="allowScriptAccess" value="sameDomain" />';
    sHtml += '<param name="movie" value="'+gsRoot+'/guide/include/flashguide/flashguide.swf?datafile='+gsRoot+'/guide/include/flashguide/data.xml&translationfile='+gsRoot+'/guide/include/flashguide/translation.xml&language='+gsLanguage+'&prefix=&imageprefix='+gsRoot+'&suffix='+AddParams+'" />';
    sHtml += '<param name="quality" value="high" />';
    sHtml += '<param name="bgcolor" value="#ffffff" />';
    sHtml += '<param name="language" value="'+gsLanguage+'" />';
    sHtml += '<embed src="'+gsRoot+'/guide/include/flashguide/flashguide.swf?datafile='+gsRoot+'/guide/include/flashguide/data.xml&translationfile='+gsRoot+'/guide/include/flashguide/translation.xml&language='+gsLanguage+'&prefix=&imageprefix='+gsRoot+'&suffix='+AddParams+'" quality="high" bgcolor="#ffffff" width="660" height="440" name="flashguide" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
    sHtml += '</object>';
//     document.write(sHtml);
  flashDiv.innerHTML = sHtml;
}



// <div id="flash" style="visibility: visible;">
//   <object id="flashguide" width="660" height="440" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0">
//     <param name="allowScriptAccess" value="sameDomain"/>
//     <param name="movie" value="/guide/include/flashguide/flashguide.swf?datafile=/guide/include/flashguide/data.xml&translationfile=/guide/include/flashguide/translation.xml&language=english&prefix=&imageprefix=&suffix=&partserver=0&language=english&root="/>
//     <param name="quality" value="high"/>
//     <param name="bgcolor" value="#ffffff"/>
//     <param name="language" value="english"/>
//     <embed width="660" height="440" src="/guide/include/flashguide/flashguide.swf?datafile=/guide/include/flashguide/data.xml&translationfile=/guide/include/flashguide/translation.xml&language=english&prefix=&imageprefix=&suffix=&partserver=0&language=english&root=" quality="high" bgcolor="#ffffff" name="flashguide" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
//   </object>
// </div>

function createFlash(){
  
  var AddParams = '&partserver='+gbPartserver+'&language='+gsLanguage+'&root='+gsRoot+'&'+gsFlashSuffix;
  
  AddParams = escape(AddParams);
  
  var flashDiv = $('flash');
    /* 
      Internet Explorer and Opera need special treatment for dynamic adding of <object> and <embed> tags 
      http://forum.de.selfhtml.org/archiv/2007/2/t145551/ (german self HTML website)
    */
    if (navigator.appName == 'Microsoft Internet Explorer' || navigator.appName == 'Opera') {
      var obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="660" height="440" id="flashguide">';
      
      var html = '<param name="allowScriptAccess" value="sameDomain">';
      html += '<param name="movie" value="' +gsRoot+'/guide/include/flashguide/flashguide.swf?datafile='+gsRoot+'/guide/include/flashguide/data.xml&translationfile='+gsRoot+'/guide/include/flashguide/translation.xml&language='+gsLanguage+'&prefix=&imageprefix='+gsRoot+'&suffix='+AddParams+ '">';
      html += '<param name="quality" value="high">';
      html += '<param name="bgcolor" value="#ffffff">';
      html += '<param name="language" value="' +gsLanguage+ '">';

      var embed = '<embed src="' +gsRoot+'/guide/include/flashguide/flashguide.swf?datafile='+gsRoot+'/guide/include/flashguide/data.xml&translationfile='+gsRoot+'/guide/include/flashguide/translation.xml&language='+gsLanguage+'&prefix=&imageprefix='+gsRoot+'&suffix='+AddParams+ '" ';
          embed += 'quality="high" bgcolor="#ffffff" width="660" height="440" name="flashguide" ';
          embed += 'allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ';
          embed += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
      html += embed;

      obj += html;
      obj += '</object>';
      
      flashDiv.innerHTML = obj;
      
    }else{ /* every other Browser */
      var obj = document.createElement('object');
        
        modifyAttribute(obj, 'classid', 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000');
        modifyAttribute(obj, 'codebase', 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0');
        modifyAttribute(obj, 'width', '660');
        modifyAttribute(obj, 'height', '440');
        modifyAttribute(obj, 'id', 'flashguide');
        
        var param = document.createElement('param');
          modifyAttribute(param, 'name', 'allowScriptAccess');
          modifyAttribute(param, 'value', 'sameDomain');
        obj.appendChild(param);
        
        var param = document.createElement('param');
          modifyAttribute(param, 'name', 'movie');
          modifyAttribute(param, 'value', gsRoot+'/guide/include/flashguide/flashguide.swf?datafile='+gsRoot+'/guide/include/flashguide/data.xml&translationfile='+gsRoot+'/guide/include/flashguide/translation.xml&language='+gsLanguage+'&prefix=&imageprefix='+gsRoot+'&suffix='+AddParams);
        obj.appendChild(param);
        
        var param = document.createElement('param');
          modifyAttribute(param, 'name', 'quality');
          modifyAttribute(param, 'value', 'high');
        obj.appendChild(param);
        
        var param = document.createElement('param');
          modifyAttribute(param, 'name', 'bgcolor');
          modifyAttribute(param, 'value', '#ffffff');
        obj.appendChild(param);
    
        var param = document.createElement('param');
          modifyAttribute(param, 'name', 'language');
          modifyAttribute(param, 'value', gsLanguage);
        obj.appendChild(param);
        
        var embed = document.createElement('embed');
          modifyAttribute(embed, 'src', gsRoot+'/guide/include/flashguide/flashguide.swf?datafile='+gsRoot+'/guide/include/flashguide/data.xml&translationfile='+gsRoot+'/guide/include/flashguide/translation.xml&language='+gsLanguage+'&prefix=&imageprefix='+gsRoot+'&suffix='+AddParams);
          modifyAttribute(embed, 'quality', 'high');
          modifyAttribute(embed, 'bgcolor', '#ffffff');
          modifyAttribute(embed, 'width', '660');
          modifyAttribute(embed, 'height', '440');
          modifyAttribute(embed, 'name', 'flashguide');
          modifyAttribute(embed, 'allowScriptAccess', 'sameDomain');
          modifyAttribute(embed, 'type', 'application/x-shockwave-flash');
          modifyAttribute(embed, 'pluginspage', 'http://www.macromedia.com/go/getflashplayer');
        obj.appendChild(embed);
  
      flashDiv.appendChild(obj);
    }
}

function setFlashSuffix(sSuffix)
{
  gsFlashSuffix = sSuffix; // set flash suffix
}

function setUserDataRequired(sMessage)
{
  gsUserDataRequired = sMessage; // set message
}

// used in cookies.js -> checkUserCookies()
// function setPopupForbiddenMessage(sMsg){
//   alert('setPopupForbiddenMessage('+sMsg+')');
//   gsPopupForbiddenMessage = sMsg;
// }
