(function ($) {
  Drupal.behaviors.gulllake2011 = {
    attach: function (context, settings) {
      $('a.iframe-modal', context).click(function () {
        var options = {},
          attributePrefix = 'data-modal-';
        
        $.each(this.attributes, function (i, attribute) {
          if (attribute.name.indexOf(attributePrefix) !== -1) {
            options[attribute.name.substring(0, attributePrefix.length)] = attribute.value;
          }
        });
        
        var iframeHtml = '<iframe style="width:100%;height:100%;" src="' + $(this).attr('href') + '" frameborder="0"></iframe>';
        
        options = $.extend({
          title: $(this).attr('title') || $(this).text(),
          draggable: false,
          resizable: false,
          modal: true,
          width: 600,
          height: 400,
          open: function() {
            $(this).html(iframeHtml);
          },
          close: function() {
            // Needed to stop videos from playing.
            $(this).dialog('destroy').remove();
          }
        }, options); 
        
        // Adding overflow: hidden prevents scrollbars.
        $('<div/>').css({overflow: 'hidden'}).dialog(options);
      
        return false;
      });
    }
  };
}(jQuery));;

