function getURL(urlToTest) {
  if (urlToTest.indexOf("https://") != -1) {
    url = "https://www.dieck-buch.de";
  } else {
      url = "http://www.dieck-buch.de";
    }
  return url
}

function PrintVersion() {
  imageWidth = 600;
  imageHeight = 400;
  scriptName = getURL(window.location.href) + "/_printpage/ibps_printpage.php?URL=" + window.location.href;
  win = window.open(scriptName, "PrintVersion","width=" + imageWidth + ",height=" + imageHeight + ",toolbar=0, location=0, status=0, menubar=0, scrollbars=1, resizable=1, status=no");
  moveWin(win, imageWidth, imageHeight);
}

function moveWin(win, imageWidth, imageHeight) {
  posX = screen.availWidth;
  posY = screen.availHeight;
  win.moveTo(((posX/2)-(imageWidth/2)),((posY/2)-(imageHeight/2)));
  win.focus();
}

function switchLayer(type) {

  if (type == "simple") {
    if (document.all) {
      document.all["searchfieldStandard"].style.display="inline";
      document.all["searchfieldExtended"].style.display="none";
      document.all["miniwarenkorb"].style.display="inline";
    } else {
        document.getElementById("searchfieldStandard").style.display = "block";
        document.getElementById("searchfieldExtended").style.display = "none";
        document.getElementById("miniwarenkorb").style.display = "block";
      }
  }
  
  if (type == "extended") {
    if (document.all) {
      document.all["searchfieldExtended"].style.display="inline";
      document.all["miniwarenkorb"].style.display="none";
      document.all["searchfieldStandard"].style.display="none";
    } else {
        document.getElementById("searchfieldExtended").style.display = "block";
        document.getElementById("miniwarenkorb").style.display = "none";
        document.getElementById("searchfieldStandard").style.display = "none";
      }
  }
}

function isEmail(email) {
  // werden regular expressions unterstuetzt?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }

  if (!supported) return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(email) && r2.test(email));
}

function openImageWin(url) {
  win = window.open(url,'ImageWin','width=400,height=400');
  win.focus();
}
