dojo.require("dijit._base.place");

dojo.addOnLoad(function() {
  viewport = dijit.getViewport();
});


function initLightbox(width, height) {
  var lightbox = document.getElementById("lightboxDiv");
  lightbox.style.width = width;
  lightbox.style.height = height;
  for (var i=0; i<lightbox.childNodes.length; i++) lightbox.removeChild(lightbox.childNodes[i]);
  var player = document.createElement("div");
  player.id = "player";
  player.innerHTML = "You need Flash player 8+ and JavaScript enabled to view this video.";
  lightbox.appendChild(player);
}
function showOverlay() {
  var lightboxPos = dojo.marginBox("lightboxDiv");
  var x = viewport.w / 2 - lightboxPos.w / 2;
  var y = viewport.h / 2 - lightboxPos.h / 2;
  dojo.style("lightboxDiv", {left: x+"px", top: y+"px", visibility: "visible"});
  dojo.style("lightboxCloser", {left: (x+lightboxPos.w-15)+"px", top: (y-10)+"px", visibility: "visible"});
  dojo.style("overlay", {display: "block", opacity: 0.0});
  dojo.animateProperty({
    node: "overlay",
    properties: {opacity: 0.7},
  }).play();
}
function hideOverlay() {
  dojo.style("lightboxDiv", {visibility: "hidden"});
  dojo.style("lightboxCloser", {visibility: "hidden"});
  dojo.animateProperty({
    node: "overlay",
    properties: {opacity: 0.0},
    onEnd: function(node) {document.getElementById("overlay").style.display = "none";}
  }).play();
}


