var newsection;

function chgtoprint() {
  /* 1: move contents of right column to bottom and make right column invisible */
  var contrgt = document.getElementById("rechts");
  var cpynode = contrgt.cloneNode(true);
  document.getElementById("spalterechts").style.display = "none";
  var conttabl = document.getElementById("contentarea");
  newsection = conttabl.parentNode.insertBefore(cpynode, conttabl.nextSibling);

  /* 2: replace anchors by their target and address information in plain text form */
  var allatags = newsection.getElementsByTagName("a");
  var ix = 0;
  while (allatags[ix]) {
    if (allatags[ix].firstChild) {
      var refline1 = document.createTextNode(allatags[ix].innerHTML);
      allatags[ix].parentNode.insertBefore(refline1, allatags[ix]); /* link-title */
      var refline2 = document.createTextNode(': [' + allatags[ix].href + '] ');
      allatags[ix].parentNode.insertBefore(refline2, allatags[ix]); /* link-address */
      allatags[ix].style.display = "none";
    }
    ix++;
  }
  newsection.style.borderTop = "1px solid silver";
}

function retrnfrprnt() {
	newsection.parentNode.removeChild(newsection);
	document.getElementById("spalterechts").style.display = "block";
}

/* Test if CTRL-p (print key) is pressed and do print-page modifications
   (this is needed as long as FF doesn't support 'onbeforeprint' and 'onafterprint')
*/
function isctrlp(e){
  var evtobj = window.event ? event : e;
  var kyCode = evtobj.charCode ? evtobj.charCode : evtobj.keyCode;
  var StdKey = String.fromCharCode(kyCode);
  var ShfKey = '';
  if (evtobj.altKey || evtobj.ctrlKey || evtobj.shiftKey) {
    ShfKey = (evtobj.shiftKey ? "SHIFT+": "");
    ShfKey += (evtobj.ctrlKey ? "CTRL+": "");
    ShfKey += (evtobj.altKey ? "ALT+": "");
  }
  if (ShfKey+StdKey == "CTRL+p") { /* accept CTRL-p only */
// DBG: alert ("CTRL+p");
    chgtoprint();
    window.setTimeout("retrnfrprnt()", 300);
  }
}
if (!(window.onbeforeprint !== undefined)) {
  /* no 'onbeforeprint' and 'onafterprint', so we catch CTRL-p */
  document.onkeypress = isctrlp;
}