CurrentOpen = null;
LastOpened = null;
timeouter = null;
timeouttime = 3000;

function OpenBehindMe( element, menuitemID, menuitem ){

  elem = document.getElementById( 'SubMenu' + menuitemID );
  if ( elem ){
    if ( CurrentOpen ){
      CurrentOpen.style.visibility = 'hidden';
    }
    CurrentMenuitem = menuitem;
    elem.style.visibility = 'visible';
    elem.style.left = element.offsetLeft + 'px';
    CurrentOpen = elem;
    KeepOpen();
  }
}

function KeepOpen(  ){
  LastOpened = new Date();
  if ( timeouter ){
    clearTimeout( timeouter );
  }
  timeouter = setTimeout( "HideMenu()", timeouttime );
}

function HideMenu( ){
  if ( CurrentOpen && LastOpened){
    time = new Date() - LastOpened;
    if ( time >= timeouttime ){
      CurrentOpen.style.visibility = 'hidden';
      CurrentOpen = null;
    } else {
      setTimeout( "HideMenu()", time );
    }
  }
}


function ShowFlash( url, width, height ){
  document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">' );
  document.write( '<param name="allowScriptAccess" value="sameDomain" />' );
  document.write( '<param name="movie" value="' + url + '">' );
  document.write( '<param name="quality" value="high">' );
  document.write( '<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>' );
  document.write( '</object>');
}


function ShowMoviePlayer( url, width, height ){
  document.write( '<object id="mediaPlayer" width="' + width + '" height="' + height + '"' );
  document.write( '    classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"' );
  document.write( '    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"' );
  document.write( '    standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">' );
  document.write( '      <param name="fileName" value="' + url + '">' );
  document.write( '      <param name="animationatStart" value="true">' );
  document.write( '      <param name="transparentatStart" value="true">' );
  document.write( '      <param name="autoStart" value="true">' );
  document.write( '      <param name="showControls" value="true">' );
  document.write( '      <param name="loop" value="true">' );
  document.write( '      <embed type="application/x-mplayer2"' );
  document.write( '      pluginspage="http://microsoft.com/windows/mediaplayer/en/download/"' );
  document.write( '      id="mediaPlayer" displaysize="4" autosize="-1"' );
  document.write( '      bgcolor="darkblue" showcontrols="true" showtracker="-1"' );
  document.write( '      showdisplay="0" showstatusbar="-1" videoborder3d="-1" width="' + width + '" height="' + height + '"' );
  document.write( '      src="' + url + '" autostart="true" designtimesp="5311" loop="true"> </embed>' );
  document.write( '  </object>' );
}


var DarkLayer = null;
var aBlock = null;
var aSluiten = null;
function OpenPicture( url ){
  if ( url ){ 
    bodys = document.getElementsByTagName( 'body' );
    body = bodys[ 0 ];

    if ( body ){

      if ( ! DarkLayer ){
        MaxHeight = 500;
        mD = document.getElementById( 'mDiv' );
        if ( mD ){ 
          MaxHeight = Math.max( mD.offsetHeight, MaxHeight );
        }
        MaxHeight = Math.max( document.documentElement.clientHeight, MaxHeight );

        DarkLayer = document.createElement( 'div' ); 
        DarkLayer.className = 'DarkLayer';
        DarkLayer.style.height = MaxHeight;
        aBlock = document.createElement( 'a' );
        aBlock.className = 'PopUpA';
        aBlock.href = "javascript:void(ClosePicture())";
        aBlock.appendChild( document.createTextNode( ' ' ) );
        aBlock.title = "klik hier om te sluiten";
 
        aSluiten = document.createElement( 'a' );
        aSluiten.className = 'SluitenA';
        aSluiten.href = "javascript:void(ClosePicture())";
        aSluiten.appendChild( document.createTextNode( 'sluiten' ) );
        aSluiten.title = "klik hier om te sluiten";
      }

      body.appendChild( aBlock );
      body.appendChild( DarkLayer );
      body.appendChild( aSluiten );

      aBlock.style.backgroundImage = 'url(' + url + ')';
    }
  }
}

function ClosePicture () {
  bodys = document.getElementsByTagName( 'body' );
  body = bodys[ 0 ];
  body.removeChild( DarkLayer );
  body.removeChild( aBlock );
  body.removeChild( aSluiten );
}
