function toggleLayer( whichLayer ) { 
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works    
    elem = document.layers[whichLayer];
    
  vis = elem.style;  
   
  // if the style.display value is blank we try to figure it out here  
  if (vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function showLayer( whichLayer ) { 
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works    
    elem = document.layers[whichLayer];
    
  vis = elem.style;  
   
  vis.display = 'block';
}

function hideLayer( whichLayer ) { 
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works    
    elem = document.layers[whichLayer];
    
  vis = elem.style;  
   
  vis.display = 'none';
}

function isLayerHidden ( whichLayer ) {
  var elem, vis;
  var res;
  
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
    elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works    
    elem = document.layers[whichLayer];
    
  vis = elem.style; 
  
  // if the style.display value is blank we try to figure it out here  
  if (vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined) {
    res = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?false:true;
  } else {
    res = (vis.display==''||vis.display=='block')?false:true;
  }
  
  return res;
}

function tr_mouseover(obj) {
  obj.className = "highlight";
}

function tr_mouseout(obj) {
  obj.className = "standard";
}

function LaegFlereIKurv(udgtype, udgid, antal) {
  // udgtype:
  //   0 = Bog
  //   1 = Artikel
  //   2 = Tidsskrift
  //   3 = Aargang
  //   4 = Andre mat.

  tekst = "";
  if (document.getElementById("inputvareaargang")!=null) {
    tekst = document.getElementById("inputvareaargang").value;
    if (tekst=="") {
      alert("Du skal vælge årgang før du kan lægge varen i kurven.");
      document.getElementById("inputvareaargang").focus();
      return false;
    }
  }

  document.getElementById("IFrameKurv").src = "/kurv/tilfoejtilkurv.asp?udgtype="+udgtype+"&udgid="+udgid+"&antal="+antal+"&aar="+tekst;
//  document.getElementById("IFrameKurv").location.replace("/kurv/tilfoejtilkurv.asp?udgtype="+udgtype+"&udgid="+udgid+"&antal="+antal+"&aar="+tekst);
  
  if (antal > 1) {
    document.getElementById("KurvPopupOverskrift").innerHTML = "Varene er lagt i kurven";
    document.getElementById("KurvPopupTekstStart").innerHTML = "Varene er nu lagt i din indkøbskurv.";
  } else {
    document.getElementById("KurvPopupOverskrift").innerHTML = "Varen er lagt i kurven";
    document.getElementById("KurvPopupTekstStart").innerHTML = "Varen er nu lagt i din indkøbskurv.";
  }

//  showLayer("LaegIKurvPopupContainer");
}  

function viskurv() {
  hideLayer("LaegIKurvPopupContainer");
  document.getElementById("IFrameKurv").src = "/kurv/.";
//  document.getElementById("IFrameKurv").location.replace("/kurv/.");
//  window.frames("IFrameKurv").location.href = "/kurv/.";
  location.href="/kurv/varer.asp";
}

function LaegIKurv(udgtype, udgid) {
  // udgtype:
  //   0 = Bog
  //   1 = Artikel
  //   2 = Tidsskrift
  //   3 = Aargang
  //   4 = Andre mat.
  LaegFlereIKurv(udgtype, udgid, 1);
}

function TrimString(instr) {
  if (instr==null) {
    instr = ""
  }
  instr2 = instr.replace( /^\s+/g, "" );
  return instr2.replace( /\s+$/g, "" );
}

function visbillede(billedefil) {
  var wwidth = 450;
  var wheight= 540;
  
  var wleft = (screen.width-wwidth)/2;
  var wtop = (screen.height-wheight)/2;
  // /billeder/visbillede.asp?billede="+
  
//  window.open("http://www.msn.dk","Tidsskriftet SFINX - vis billede","left="+wleft+",top="+wtop+",screenX="+wleft+",screenY="+wtop+
//             ",width="+wwidth+",height="+wheight+",scrollbars=yes,resizable=no");

  window.open("/billeder/visbillede.asp?billede="+billedefil, "", "left="+wleft+",top="+wtop+",screenX="+wleft+",screenY="+wtop+",width="+wwidth+",height="+wheight+",scrollbars=no,resizable=yes");
}

function getKeyCode(e) {
  if(window.event) // IE
  {
    keynum = window.event.keyCode;
  }
  else if(e.which) // Netscape/Firefox/Opera
  {
    keynum = e.which;
  }
  else
  {
    keynum = e.keyCode;
  }
  return keynum;
}

