dojo.ready(function() {
  dojo.query(".audiolink").forEach(function(link){
      dojo.connect(link, "onclick", null, function(e){
        var node    = e.target;
        var url     = dojo.attr(node, "href");
        dojo.query("#audioiframe").attr("src", url);
        dojo.stopEvent(e);
      });
  });

  dojo.query("#part2").forEach(function(link){
      dojo.connect(link, "onclick", null, function(e){
        var node    = e.target;
        var url     = 'http://www.youtube.com/embed/rHecLLDr_d4';
        dojo.query("#youtubeplayer").attr("src", url);
        e.target.innerHTML = '';
        dojo.stopEvent(e);
      });
  });

  // dojo.byId('mboxbg').style.display = 'none';
  dojo.byId('newsletter').style.display = 'none';

  // if (dojo.byId("vid")) {
  //   // alert("has vid");
  //   var link = dojo.byId("vid");
  //   dojo.connect(link, "onclick", null, function(e){
  //     dojo.byId('mboxbg').style.display = 'block';

  //     var height = document.body.clientHeight;

  //     height = height + 'px';

  //     dojo.byId('mboxbg').style.height = height;

  //     dojo.stopEvent(e);
  //   });
  // };

  // if (dojo.byId("watch")) {
  //   var link = dojo.byId("watch");
  //   dojo.connect(link, "onclick", null, function(e){
  //     dojo.byId('mboxbg').style.display = 'block';

  //     var height = document.body.clientHeight;

  //     height = height + 'px';

  //     dojo.byId('mboxbg').style.height = height;

  //     dojo.stopEvent(e);
  //   });
  // };



  // var link = dojo.byId("closelink");
  // dojo.connect(link, "onclick", null, function(e){
  //   dojo.byId('mboxbg').style.display = 'none';
  //   dojo.stopEvent(e);
  // });

  if (dojo.byId("email")) {
    var email = dojo.byId("email");
    dojo.connect(email, "onclick", null, function(e){
      dojo.byId('newsletter').style.display = 'block';

      var height = document.body.clientHeight;

      height = height + 'px';

      dojo.byId('newsletter').style.height = height;

      dojo.stopEvent(e);
    });
  };

  if (dojo.byId("emailHome")) {
    var email = dojo.byId("emailHome");
    dojo.connect(email, "onclick", null, function(e){
      dojo.byId('newsletter').style.display = 'block';

      var height = document.body.clientHeight;

      height = height + 'px';

      dojo.byId('newsletter').style.height = height;

      dojo.stopEvent(e);
    });
  };

  if (dojo.byId("mailingList")) {
    var email = dojo.byId("mailingList");
    dojo.connect(email, "onclick", null, function(e){
      dojo.byId('newsletter').style.display = 'block';

      var height = document.body.clientHeight;

      height = height + 'px';

      dojo.byId('newsletter').style.height = height;

      dojo.stopEvent(e);
    });
  };

  var link = dojo.byId("cancelnewsletter");
  dojo.connect(link, "onclick", null, function(e){
    dojo.byId('newsletter').style.display = 'none';
    dojo.stopEvent(e);
  });
});



$(document).ready(function() {

  $(".iframe").fancybox({
   'height' : 486,
   'width'  : 864,
   'padding'  : 0,
   'overlayColor' : '#000'
  });

  $('.disc').click(function(event) {
    event.preventDefault();
    // console.log($(this).next().children('a'));
    var link = $(this).next().children('a').attr('href');
    // console.log(link);
    window.open(link, '_blank');
  });

});

