var prevButtonID = "";

function openwindow(url,target) {
  window.open(url, target, "");
}
function select(linkID, url) {
  mark(linkID);
  openwindow(url,"_self");
}
function init() {
  setScroll();
  if( document.createEvent ) {
    window.captureEvents(Event.RESIZE);
  } else if( document.createEventObject ) {
  }
  window.onresize = setScroll;
}
function setScroll() {
  var scrollArea = document.getElementById("scrollArea");
  if (document.getElementById("headerElement")) {
    headerWidth=42;
  } else {
    headerWidth=0;
  }
  if (document.getElementById("footer")) {
    footerWidth=20;
  } else {
    footerWidth=0;
  }
  if (window.innerHeight) { 
    scrollArea.style.height = window.innerHeight - headerWidth - footerWidth;
  } else {
    scrollArea.style.height = document.body.clientHeight - 2 - headerWidth - footerWidth;
  }
}

function mark(linkID) {
  if (prevButtonID != "") {
    document.getElementById(prevButtonID).style.color = "";
    cssRule("a#"+linkID+":link","color","#ddd");
    cssRule("a#"+linkID+":visited","color","#ddd");
    cssRule("a#"+linkID+":focus","color","#ddd");
    cssRule("a#"+linkID+":active","color","#ddd");
  }
  document.getElementById(linkID).style.color = "yellow";
  cssRule("a#"+linkID+":link","color","yellow");
  cssRule("a#"+linkID+":visited","color","yellow");
  cssRule("a#"+linkID+":focus","color","yellow");
  cssRule("a#"+linkID+":active","color","yellow");
  prevButtonID = linkID;
}

function showPicture(url) {
  showPictureWithSize(url,520,350);
}

function showPictureWithSize(url,width, height) {
  if (window.innerHeight) { 
    maxHeight = window.innerHeight - headerWidth - footerWidth;
  } else {
    maxHeight = document.body.clientHeight - 2 - headerWidth - footerWidth;
  }
  if (height > maxHeight) {
    dispHeight = maxHeight;
    dispWidth = Math.round(dispHeight/height * width);
  } else {
    dispWidth = width;
    dispHeight = height;
  }
  agbWindow = window.open(url, "Kundenfoto", "resizable=yes,scrollbars=yes,width="+dispWidth+",height="+dispHeight+",left=20,top=0");
  agbWindow.focus();
}

function showVersandkosten() {
  vkWindow = window.open("shippingFees.htm", "Versandkosten", "resizable=yes,scrollbars=yes,width=860,height=600,left=100,top=100");
  vkWindow.focus();
}

function showAGB() {
  agbWindow = window.open("agb.htm", "AGB", "resizable=yes,scrollbars=yes,width=800,height=500,left=100,top=100");
  agbWindow.focus();
}


