
var DarkLayer = null;
OpenPictureNext = null;
OpenPicturePrev = null;
function OpenAfbeelding( idx ){
  if ( idx != null){
    url = Images[ idx ];
  }
  if ( url ){
    bodys = document.getElementsByTagName( 'body' );
    body = bodys[ 0 ];
    phj = document.getElementById( 'PopupHolder' );

    phjFoto = document.getElementById( 'PopupFoto' );

    phjSluiten = document.getElementById( 'Sluiten' );

    pvol = document.getElementById( 'PopupVolgende' );
    pvor = document.getElementById( 'PopupVorige' );

    if ( body && phj && phjFoto && pvol && pvor && phjSluiten ){


      if ( ! DarkLayer ){

        DarkLayer = document.createElement( 'div' );
        DarkLayer.className = 'DarkLayer';
        DarkLayer.style.height = GetWindowHeight() + 'px';
      }

      body.appendChild( DarkLayer );
      phj.style.display = 'block';
      phjFoto.style.backgroundImage = 'url(' + url + ')';

      pvor.style.display = Images[ idx - 1 ] ? 'block' : 'none';
      pvol.style.display = Images[ idx + 1 ] ? 'block' : 'none';

      phjSluiten.href = '#foto' + idx;

      OpenPictureNext = idx + 1;
      OpenPicturePrev = idx - 1;
    }
  }
}
function ClosePicture () {
  bodys = document.getElementsByTagName( 'body' );
  body = bodys[ 0 ];
  body.removeChild( DarkLayer );
  phj = document.getElementById( 'PopupHolder' );
  if ( phj ){
    phj.style.display = 'none';
  }
}
function GetWindowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight + 1;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight + 2;
  }
  var Body = document.getElementsByTagName( 'body' ).item( 0 );
  var Html = document.getElementsByTagName( 'html' ).item( 0 );

  if ( Body && Html ){
    IC_Body = Body;
    IC_HTML = Html;
  }
  return Math.max( myHeight, IC_HTML.offsetHeight, IC_Body.offsetHeight );
}

// Pagina doorsturen box weergeven/verstoppen
function ShowHide() {
  if(document.getElementById("StuurPagina").style.display == 'block') {
    document.getElementById("StuurPagina").style.display = 'none';
  } else {
    document.getElementById("StuurPagina").style.display = 'block';
  }
}

// Checklist items weergeven / verstoppen
var previousCell = null;
var previousAnchor = null;

function OpenClose(anchor, id) {
  var cell = document.getElementById( "item" + id );
  if ( cell != null ){
    if ( anchor.className == "Open"  ) {
      anchor.className = "Close";
      cell.style.display = "none";
    } else {
      anchor.className = "Open";
      cell.style.display = "block";
    }

    if(previousCell != null && previousCell != cell ) previousCell.style.display = "none";
    if(previousAnchor != null && previousAnchor != anchor ) previousAnchor.className = "Close";

    previousCell = cell;
    previousAnchor = anchor;
  }
  return false;
}

