// check for layer/resolution and setWidth/SetLayout
// JPU: Be gentle when changing the indenting, this is too complex for me :-/
function setLayout() {
    if (document.getElementById('menuCoulisseAria') == null) {
        // collection
        if (document.getElementById('leftCoulisse') != null) {
            if (screen.width > 800) {
                document.getElementById('switchlayout').style.width = '650px';
                document.getElementById('switchlayout').style.left = '300px';
            } else {
                document.getElementById('switchlayout').style.left = '140px';
                document.getElementById('collectionMenu').style.width = '30px';
                document.getElementById('framework').style.width = '750px';
                document.getElementById('switchlayout').style.width = '610px';
           document.getElementById('leftCoulisse').style.left = '60px';
                if (document.getElementById('rightCoulisse') != null) 
                    document.getElementById('rightCoulisse').style.left = '750px';
            }
            if (document.getElementById('rightCoulisse') != null)
                document.getElementById('contentDivPad').style.padding = '20px 110px 20px 20px';
        } else {
            // collection no visuals
            if (screen.width > 800) {
                document.getElementById('switchlayout').style.width = '730px';
                document.getElementById('switchlayout').style.left = '220px';
            } else {
                document.getElementById('switchlayout').style.left = '60px';
                document.getElementById('collectionMenu').style.width = '30px';
                document.getElementById('framework').style.width = '750px';
                document.getElementById('switchlayout').style.width = '690px';
                if (document.getElementById('rightCoulisse') != null)
                    document.getElementById('rightCoulisse').style.left = '750px';
            }
            
            if (document.getElementById('rightCoulisse') != null)
                document.getElementById('contentDivPad').style.padding = '20px 110px 20px 20px';
        }
    } else {
        // aria
    if (screen.width > 800) {
            document.getElementById('switchlayout').style.width = '810px';
        if (document.getElementById('contentDivside') != null)
                document.getElementById('contentDivmain').style.width = '590px';
        } else {
      document.getElementById('framework').style.width = '750px';
      document.getElementById('switchlayout').style.width = '610px';
      if (document.getElementById('rightCoulisse') != null)
                document.getElementById('rightCoulisse').style.left = '750px';
      if (document.getElementById('contentDivside') != null)
      document.getElementById('contentDivmain').style.width = '570px';
      if (document.getElementById('contentDivside') != null)
                document.getElementById('contentDivside').style.display = 'none';
                /*document.getElementById('contentDivmain').style.width = '570px';
      if (document.getElementById('contentDivside') != null)
                document.getElementById('contentDivside').style.left = '414px';*/
    }
    document.getElementById('switchlayout').style.left = '140px';
        if (document.getElementById('leftCoulisse')) {
        document.getElementById('leftCoulisse').style.left = '60px';
        }
    if (document.getElementById('rightCoulisse') != null)
            document.getElementById('contentDivPad').style.padding = '20px 110px 20px 20px';
  }
}

//set min-height safari
var Browser = function(){
  this.ie = navigator.appName.toLowerCase().indexOf('microsoft') != -1 ? 1 : 0;
  this.mac =  navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 1 : 0;
  this.win = !this.mac ? 1 : 0;
  this.safari =  navigator.userAgent.toLowerCase().indexOf('safari') != -1 ? 1 : 0;
  this.mozilla = navigator.appName.toLowerCase().indexOf('netscape') != -1 && !this.safari ? 1 : 0;
  this.winIE = this.ie && !this.mac ? 1: 0;
  this.macIE = this.ie && this.mac ? 1: 0;
  this.safariVersion = function (){
    if (!this.safari) return false;
    var ua = navigator.userAgent.toLowerCase();
    var indexNum = ua.indexOf('safari/') + 7;
    var vNum = ua.substring(indexNum,indexNum+3);
    return parseInt(vNum,10);
  }
}
var browser = new Browser();
function SetHeight(){
  if (browser.safari){
    document.getElementById('contentDivPad').style.display = "table-cell";
    document.getElementById('contentDivPad').style.height = "556px";
  }
}
//window.onload = function() {SetHeight();}



function showArrow(){
  document.getElementById('png').style.display = 'block';
}
function hideArrow(){
  document.getElementById('png').style.display = 'none';
}

//read more 
function zie_ook(id){
  var e = document.getElementById(id).style
  e.display=(e.display=="block") ? "none" : "block"
  window.scrollTo(0,100000);
}

//droplist
function startList() {
if (document.all&&document.getElementById) {
  navRoot = document.getElementById("droplist");
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
  if (node.nodeName=="LI") {
    node.onmouseover=function() {
    this.className+=" over";}
    node.onmouseout=function() {
    var out = true;
      if(window.event)  {
        var element = window.event.toElement;
        while(element)  {
          out &=  element !=  this;
          element = element.parentNode;}
        }
      if(out) {
        this.className=document.getElementById('sublevel').className.replace(" over", " ");}
        }
      }
    }
  }
}
  
// center popup script  
  var win = null;
  function newWindow(mypage,myname,w,h,scroll,resize){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+''
    win = window.open(mypage,myname,settings)
  }
  
//swap images
function createMouseOvers(){
  var p = 0, d = document.images;
  prelImgs = new Array();
  for (var i = 0; i < d.length; i++){
    var o = d[i];
    if (o.src.indexOf('_out') != -1){
      o.onmouseover = function (){swapImage(this);}
      o.onmouseout = o.onmouseover;
      prelImgs[p] = new Image ();
      prelImgs[p].src= d[i].src.substring(0,o.src.length-8)+'_over.gif';
      p++;
    }
  }
}

function swapImage(o){
  var s = o.src;
  o.src = s.indexOf('_over') == -1 ?
  s.substring(0,s.length-8)+'_over.gif' :
  s.substring(0,s.length-9)+'_out.gif';
}


if (window.HTMLElement) {
  HTMLElement.prototype.contains = function(el)
  {
    var tempEl = el;
    while (tempEl!=null) {
      if (tempEl == this) return true;
      tempEl = tempEl.parentNode;
    }
    return false;
  };
}

function isInside(parentEl, evt) {
  if (window.HTMLElement) {
    // mozilla and alike
    return parentEl.contains(evt.relatedTarget);
  } else {
    return parentEl.contains(evt.toElement);
  }
}

var popupHandle;
function popup(pagina) {
  window.name = "eerstevenster";
  var width = 800;
  var height = 600;
  //
  // fullscreen if screenX=800
  if(navigator.appName == "Microsoft Internet Explorer") {
    screenX = window.screen.availWidth;
  }else{
    screenX = window.outerWidth
  }
  if (screenX==800) {
    var properties = "width=800,height=600,toolbar=no,status=no,resizable=no,scrollbars=no,fullscreen=yes";
  } else {
    var properties = "width=800,height=600,toolbar=no,status=no,resizable=no,scrollbars=no";
  }
  var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
  if(navigator.appName == "Microsoft Internet Explorer") {
    screenY = document.body.offsetHeight;
    screenX = window.screen.availWidth;
  }else{
    screenY = window.outerHeight
    screenX = window.outerWidth
  }
  leftvar = Math.round((screenX - width) / 2);
  rightvar = Math.round((screenY - height) / 2);
  if(navigator.appName == "Microsoft Internet Explorer") {
    leftprop = leftvar;
    topprop = rightvar;
  }else {
    leftprop = (leftvar - pageXOffset);
    topprop = (rightvar - pageYOffset);
  }
  properties = properties + ",left=" + leftprop;
  properties = properties + ",top=" + topprop;
  popupHandle = open( pagina, "carteOrange", properties);
  setTimeout('popupHandle.focus();',250);

}

