﻿/* ---------------------------------------------------------------------------------- */
/* ----- Functies: onLoad ----------------------------------------------------------- */
/* ---------------------------------------------------------------------------------- */

$(document).ready(function() {
  // Lightbox activeren
  if ($(".lightbox").length > 0) {
    $(".lightbox").lightbox();
  }
  $("#overlay").css({ "opacity": "0.7" });

  // Popup overlay doorzichtig maken
  $("#popup_overlay").css({ "opacity": "0.7" });
  if ($('.home_banner').length > 0) {
    $('.home_banner').innerfade({
      speed: 1000,
      timeout: 6000,
      type: 'random_start',
      containerheight: '270px'
    });
  }
});


/* ---------------------------------------------------------------------------------- */
/* ----- Functies: Popup ------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------- */

// Gewenste popup tonen indien een ID is meegegeven, anders alle popups verbergen
function togglePopup(popupId, linkEl) {
  if (popupId) {
    if ($("#" + popupId + ":hidden").length > 0) {
      $("html, body").scrollTop(0);
      $("#popup_overlay").height($(document).height());
      if (linkEl) {
        $("#" + popupId + " iframe").attr("src", linkEl.href)
      }
      $("#popup_overlay").fadeIn(400, function() { $("#" + popupId).fadeIn(400) });
    } else {
      $("#" + popupId).fadeOut(400, function() { $("#popup_overlay").fadeOut(400) });
    }
  } else {
    $("#popup_overlay, .popup").fadeOut(400);
  }
}

