
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( '<PARAM NAME=wmode VALUE=transparent>' );
  document.write( '<embed src="' + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent" ></embed>' );
  document.write( '</object>');
}



var DarkLayer = null;
OpenPictureNext = null;
OpenPicturePrev = null;
function OpenPicture( idx ){ 
  label = '';
  index = 0;
  if ( idx != null){ 
    label = Afbeeldingen[ idx ].Titel;
    url = Afbeeldingen[ idx ].Groot;
  }
  if ( url ){
    bodys = document.getElementsByTagName( 'body' );
    body = bodys[ 0 ];
 
    phj = document.getElementById( 'PopupHolder' );
 
    phjFoto = document.getElementById( 'PopupFoto' );
 
    pvol = document.getElementById( 'PopupVolgende' );
    pvor = document.getElementById( 'PopupVorige' );
    plab = document.getElementById( 'PopupFotoLabel' );

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

      if ( ! DarkLayer ){

        DarkLayer = document.createElement( 'div' );
        DarkLayer.className = 'DarkLayer';
        DarkLayer.style.height = '100%';
      }
      body.appendChild( DarkLayer );
      phj.style.display = 'block';
      phjFoto.src = AbsUrl + url;

      plab.innerHTML = label;
      
      pvor.style.visibility = Afbeeldingen[ idx - 1 ] ? 'visible' : 'hidden';
      pvol.style.visibility = Afbeeldingen[ idx + 1 ] ? 'visible' : 'hidden';

      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 ClosePopup() {
  p = window.parent.document.getElementById( 'PopupFrame' );
  if ( p ){ 
    p.style.display = 'none';
  }
}



var IC_Photo_DarkLayer = null;
var IC_Photo_Popup_referer = null;

var IC_Photo_Settings = {
  MarginToBorders: 10,
  Title: 'Klik hier om te sluiten',
  CloseTitle: 'sluiten',
  UseAltTag: true,
  UseCloseTag: true,
  UseDarkLayer: true,
  Padding: 15
};

function IC_Photo_Popup( Link, URL, Width, Height, Alt ){
  var Body = document.getElementsByTagName( 'body' ).item( 0 );
  var Html = document.getElementsByTagName( 'html' ).item( 0 );

  if ( ! IC_Photo_DarkLayer && IC_Photo_Settings.UseDarkLayer ){
    IC_Photo_DarkLayer = document.createElement( 'div' );
    IC_Photo_DarkLayer.id = 'IC_Photo_DarkLayer';
    Body.appendChild( IC_Photo_DarkLayer );
  }

  if ( IC_Photo_Popup_referer == null ){
    IC_Photo_Popup_referer = document.createElement( 'a' );
    IC_Photo_Popup_referer.id = 'IC_Photo_Popup_Holder';
    IC_Photo_Popup_referer.onclick = IC_Photo_Popup_Close;
    IC_Photo_Popup_referer.href = '#';
    IC_Photo_Popup_referer.title = IC_Photo_Settings.Title;

    if ( IC_Photo_Settings.UseAltTag ){
      var AltTag = document.createElement( 'span' );
      AltTag.className = 'AltLabel';
      AltTag.appendChild( document.createTextNode( Alt ) );
      IC_Photo_Popup_referer.appendChild( AltTag );
      IC_Photo_Popup_referer.Label = AltTag;
    }
 
    if ( IC_Photo_Settings.UseCloseTag ){
      var ATag = document.createElement( 'a' );
      ATag.className = 'CloseButton';
      ATag.href = '#';
      ATag.appendChild( document.createTextNode( IC_Photo_Settings.CloseTitle ) );
      IC_Photo_Popup_referer.appendChild( ATag );
    }

    Body.appendChild( IC_Photo_Popup_referer );
  }
  if ( IC_Photo_Popup_referer != null ) {
    IC_Photo_Popup_referer.style.display = 'block';

    IC_Photo_Popup_referer.style.height = ( Height + IC_Photo_Settings.Padding * 2 ) + 'px';
    IC_Photo_Popup_referer.style.width = ( Width + 30 ) + 'px';

    LabelHeight = 0;

    if ( IC_Photo_Settings.UseAltTag ){
      IC_Photo_Popup_referer.Label.innerHTML = Alt;

      if ( Alt != '' ){
        LabelHeight = IC_Photo_Popup_referer.Label.offsetHeight;

        IC_Photo_Popup_referer.style.height = ( Height + LabelHeight + IC_Photo_Settings.Padding * 2 ) + 'px';
      }
    }

    IC_Photo_Popup_referer.style.backgroundPosition = 'center ' + ( IC_Photo_Settings.Padding + LabelHeight ) + 'px';

    IC_Photo_Popup_referer.style.backgroundImage = 'url(' + URL + ')';

    if ( true ){

      WindowMax = Math.max( Body.offsetHeight, Html.offsetHeight );

      Top = WindowMax / 2 - IC_Photo_Popup_referer.offsetHeight / 2;
      Top = Math.max( Top, IC_Photo_Settings.MarginToBorders );
 
      WindowMax = Math.max( Body.offsetWidth, Html.offsetWidth );
      Left = WindowMax / 2 - IC_Photo_Popup_referer.offsetWidth / 2;

      IC_Photo_Popup_referer.style.top = Top + 'px';
      IC_Photo_Popup_referer.style.left = Left + 'px';

      if ( IC_Photo_Settings.UseDarkLayer ){
        IC_Photo_DarkLayer.style.display = 'block';

        DLHeight = Math.max( Body.offsetHeight, Html.offsetHeight, Top + IC_Photo_Popup_referer.offsetHeight );

        IC_Photo_DarkLayer.style.height = DLHeight + 'px';

      }
    }
  }
}


function IC_Photo_Popup_Close(){
  if ( IC_Photo_Popup_referer != null ){
    IC_Photo_Popup_referer.style.display = 'none';
  }
  if ( IC_Photo_Settings.UseDarkLayer && IC_Photo_DarkLayer != null ){
    IC_Photo_DarkLayer.style.display = 'none';
  }
  return false;
}

function getPositionFrom(element) {
  var Pos = {top:0,left:0};
  var absoluteAncestor = false;

  while ( element.offsetParent ) {

    Pos.top += element.offsetTop - element.scrollTop;
    Pos.left += element.offsetLeft - element.scrollLeft;

    element = element.offsetParent;

    if ( element.nodeName.toLowerCase() != 'html' ) {
      if ( element.currentStyle ) {
        if (element.currentStyle[ 'position' ] == 'absolute')
          absoluteAncestor = true;
      } else {
        if ( window.getComputedStyle ){
          if ( document.defaultView.getComputedStyle(element,null).getPropertyValue( 'position' ) == 'absolute' ){
            absoluteAncestor = true;
          }
        }
      }
    }
  }

  if ( ! absoluteAncestor ){
    var Body = document.getElementsByTagName( 'BODY' ).item( 0 );
    Pos.top += Body.offsetTop;
    Pos.left += Body.offsetLeft;
  }

  return Pos;
}

function ProductNavigateTo( Index, PrevLink, NextLink, Afbeelding, productkleurID ){
  var kleurSelect = document.getElementById( 'Kleur' ); 
  if ( kleurSelect ){
    for( var i = 0; i < kleurSelect.options.length; i++ ){
      if ( kleurSelect.options[ i ].value == productkleurID ){
        kleurSelect.options[ i ].selected = true;
      }
    }
  }
  var productIndex = document.getElementById( 'ProductIndex' );
  if ( productIndex ){
    productIndex.innerHTML = Index;
  }
  var prevLink = document.getElementById( 'NavATerug' );
  if ( prevLink ){
    prevLink.href = PrevLink ? PrevLink : '#';
    prevLink.className = PrevLink ? 'NavLink' : 'NoNavLink';
  }
  var nextLink = document.getElementById( 'NavAVooruit' );
  if ( nextLink ){
    nextLink.href = NextLink ? NextLink : '#';
    nextLink.className = NextLink ? 'NavLink' : 'NoNavLink';
  }
  var AfbeeldingObj = document.getElementById( 'ProductAfbeeldingGroot' );
  if ( AfbeeldingObj ){
    AfbeeldingObj.src = Afbeelding;
  }
}


