  
  $(document).keydown(function(oEvent) {
    
    var iKey = (oEvent.keyCode ? oEvent.keyCode : oEvent.which);
    
    // toets naar rechts
    if(iKey == 39) {
      document.location = $('.a_next_foto').attr('href');
    }
    
    // toets naar links
    if(iKey == 37) {
      document.location = $('.a_prev_foto').attr('href');
    }
    
  });
  
  var iTimeoutId = null;
  var iTimeoutId2 = null;
  
  /* exif functions */
  
  function mOverExif() {
    eDiv = document.getElementById('pExif').getElementsByTagName("DIV");
    eDiv.item(0).style.display='block';
    
    /*document.getElementById('pExif').style.backgroundImage='none';*/
    
    //document.getElementById('pExif').style.right='5px';
    
    /*eDiv.item(0).style.borderLeft='1px #CFD2D4 solid';
    document.getElementById('pExif').style.borderRight='none';*/
  }
  
  function mOutExif() {
    eDiv = document.getElementById('pExif').getElementsByTagName("DIV");
    eDiv.item(0).style.display='none';
    
    /*document.getElementById('pExif').style.backgroundImage='url(images/exif_info.gif)';
    document.getElementById('pExif').style.paddingLeft='32px';*/
    /*eDiv.item(0).style.borderLeft='none';
    document.getElementById('pExif').style.borderRight='1px #0064C8 solid';*/
  }
  
  /* -------------- */
  
  function shoppingcartOver() {
    eDiv = document.getElementById('div_shoppingcart').getElementsByTagName("DIV");
    eDiv.item(0).style.display='block';
    /*eDiv.item(0).style.borderLeft='1px #EE3248 solid';
    document.getElementById('div_shoppingcart').style.borderRight='none';*/
    
    /*eDiv.item(0).style.borderLeft='1px #CFD2D4 solid';
    document.getElementById('div_shoppingcart').style.borderRight='none';*/
  }
  
  function shoppincartOut() {
    eDiv = document.getElementById('div_shoppingcart').getElementsByTagName("DIV");
    eDiv.item(0).style.display='none';
    
    /*eDiv.item(0).style.borderLeft='none';
    document.getElementById('div_shoppingcart').style.borderRight='1px #0064C8 solid';*/
  }
  
  /* goTo functions */
  
  function goToImgDir( sType, sDir ) {
    document.location='fotos.php?type='+sType+'&dir='+sDir;
  }
  
  function goToImg( sImg ) {
    document.location='fotos.php?img='+sImg+'#span_title';
  }
  
  /* -------------- */
  
  function mOverImg( pRow, pCol ) {
    /* image */
    changeClass('pImg'+pRow+'_'+pCol, 'photoImg_over');
    /* text */
    changeClass('pText'+pRow+'_'+pCol, 'photoText_over');
    /* row below */
    changeClass('pRLine'+pRow+'_'+pCol, 'pRLine_over');
    /* row above */
    ff = pRow-1;
    changeClass('pRLine'+ff+'_'+pCol, 'pRLine_over');
    /* coll left */
    ff = pCol-1;
    changeClass('pCLineO'+pRow+'_'+ff, 'pCLine_over');
    changeClass('pCLineT'+pRow+'_'+ff, 'pCLine_over');
    /* coll right */
    changeClass('pCLineO'+pRow+'_'+pCol, 'pCLine_over');
    changeClass('pCLineT'+pRow+'_'+pCol, 'pCLine_over');
  }
  
  function mOutImg( pRow, pCol ) {
    /* image */
    changeClass('pImg'+pRow+'_'+pCol, 'photoImg');
    /* text */
    changeClass('pText'+pRow+'_'+pCol, 'photoText');
    /* row below */
    changeClass('pRLine'+pRow+'_'+pCol, 'pRLine');
    /* row above */
    ff = pRow-1;
    changeClass('pRLine'+ff+'_'+pCol, 'pRLine');
    /* coll left */
    ff = pCol-1;
    changeClass('pCLineO'+pRow+'_'+ff, 'pCLine');
    changeClass('pCLineT'+pRow+'_'+ff, 'pCLine');
    /* coll right */
    changeClass('pCLineO'+pRow+'_'+pCol, 'pCLine');
    changeClass('pCLineT'+pRow+'_'+pCol, 'pCLine');
  }
  
  function changeClass( pElementId, pClassName ) {
    if( document.getElementById( pElementId ))
      document.getElementById(pElementId).className=pClassName;
  }
  
  
  /* goTo functions */
  

  
  /* -------------- */
  
  function mOverPhotoThumb( eId ) {
    if( activePhotoThumb != eId ) {
      document.getElementById('pThumbTd'+eId).className='pThumbPhoto_over';
    }
  }

  function mOutPhotoThumb( eId ) {
    if( activePhotoThumb != eId ) {
      document.getElementById('pThumbTd'+eId).className='pThumbPhoto';
    }
  }
  
  var activePhotoThumb = null;
  var centerThumb = null;
  
  function setActivePhotoThumb( eId ) {
    document.getElementById('pThumbTd'+eId).className='pThumbPhoto_active';
    activePhotoThumb = eId;
    
    iStart = activePhotoThumb-3;
    if( iStart < 0 )
      iStart = 0;
    iStop = iStart + 6;
    if( iStop >= numbOfPhoto ) {
      iStop = numbOfPhoto-1;
      iStart = iStop - 6;
    }
    centerThumb = iStart+3;
      
    for( i=iStart; i<=iStop; i++ ) {
      showPhoto( i );
    }
      
    if( document.getElementById('pThumbTd0').style.display == 'block' || document.getElementById('pThumbTd0').style.display == 'table-cell' || activePhotoThumb == 0 )
      DisableThToLeft();
    
    if( document.getElementById('pThumbTd'+(numbOfPhoto-1)).style.display == 'block' || document.getElementById('pThumbTd'+(numbOfPhoto-1)).style.display == 'table-cell' || activePhotoThumb == (numbOfPhoto-1) )
      DisableThToRight();
  }
  
  function showPhoto( eId ) {
    if( document.getElementById('pThumbTd'+eId)) {
      if( navigator.appName == 'Microsoft Internet Explorer' ) {
        document.getElementById('pThumbTd'+eId).style.display='block';
      } else {
        document.getElementById('pThumbTd'+eId).style.display='table-cell';
      }
    }
  }
  
  function hidePhoto( eId ) {
    if( document.getElementById('pThumbTd'+eId)) {
      document.getElementById('pThumbTd'+eId).style.display='none';
    }
  }
  
  function mOverThLeft() {
    if( document.getElementById('pThumbLeft').className != 'pThumbLeft_n' )
      document.getElementById('pThumbLeft').className='pThumbLeft_o';
  }
  
  function mOutThLeft() {
    if( document.getElementById('pThumbLeft').className != 'pThumbLeft_n' )
      document.getElementById('pThumbLeft').className='pThumbLeft';
  }
  
  function mDownThLeft() {
    mClickThLeft();
    iTimeoutId = setTimeout('iTimeoutId2 = setInterval(\'mClickThLeft()\', 50)', 500);
  }
  
  function mUpThLeft() {
    clearTimeout(iTimeoutId);
    clearInterval(iTimeoutId2);
  }
  
  function mClickThLeft() {
    if( document.getElementById('pThumbLeft').className != 'pThumbLeft_n' ) {
      iThShow = centerThumb - 4;
      iThHide = centerThumb + 3;
      centerThumb--;
      showPhoto( iThShow );
      hidePhoto( iThHide );
      if( iThShow <= 0 )
        DisableThToLeft();
      EnableThToRight();
    }
  }
  
  function DisableThToLeft() {
    document.getElementById('pThumbLeft').className='pThumbLeft_n';
  }
  
  function EnableThToLeft() {
    document.getElementById('pThumbLeft').className='pThumbLeft';
  }
  
  function mOverThRight() {
    if( document.getElementById('pThumbRight').className != 'pThumbRight_n' )
      document.getElementById('pThumbRight').className='pThumbRight_o';
  }
  
  function mOutThRight() {
    if( document.getElementById('pThumbRight').className != 'pThumbRight_n' )
      document.getElementById('pThumbRight').className='pThumbRight';
  }
  
  function mDownThRight() {
    mClickThRight();
    iTimeoutId = setTimeout('iTimeoutId2 = setInterval(\'mClickThRight()\', 50)', 500);
  }
  
  function mUpThRight() {
    clearTimeout(iTimeoutId);
    clearInterval(iTimeoutId2);
  }
  
  function mClickThRight() {
    if( document.getElementById('pThumbRight').className != 'pThumbRight_n' ) {
      iThShow = centerThumb + 4;
      iThHide = centerThumb - 3;
      centerThumb++;
      showPhoto( iThShow );
      hidePhoto( iThHide );
      if( iThShow >= (numbOfPhoto-1))
        DisableThToRight();
      EnableThToLeft();
    }
  }
  
  function DisableThToRight() {
    document.getElementById('pThumbRight').className='pThumbRight_n';
  }
  
  function EnableThToRight() {
    document.getElementById('pThumbRight').className='pThumbRight';
  }
  
  function hideFlash() {
    eDiv = document.getElementById('div_header').getElementsByTagName("DIV");
    eDiv.item(0).style.display='none';
  }
