// http://colorpowered.com/colorbox/

function hideEmbedContent() {
  $('#drop-io').hide();
}

function showEmbedContent() {
  $('#drop-io').show();
}

var PLC = {
  DEFAULT_OPTIONS: {
    transition:"elastic",
    opacity:0.85,
    scrolling:false,
    close:"close",
    overlayClose:true,
    onOpen: function() { hideEmbedContent(); },
    onClosed: function() { showEmbedContent(); }
  },

  start: function() {
    var opts = {
           "video_preview":   $({maxWidth:"450px",maxHeight:"350px"}).extend(true,$(PLC.DEFAULT_OPTIONS)),
           "audio_preview":   $({maxWidth:"450px",maxHeight:"150px"}).extend(true,$(PLC.DEFAULT_OPTIONS)),
           "image_preview":   $({maxWidht:"700px",maxHeight:"500px"}).extend(true,$(PLC.DEFAULT_OPTIONS)),
           "document_preview":$({innerWidth: "700px",innerHeight:"500px"}).extend(true,$(PLC.DEFAULT_OPTIONS)),
           "embed_preview":$({maxWidth:"450px",maxHeight:"250px"}).extend(true,$(PLC.DEFAULT_OPTIONS))

           };

      var types = $(["video_preview","image_preview","document_preview","embed_preview","audio_preview"]);

    types.each(function(i,s) {
      if( $(".plc."+s).length != 0 ) {
        $(".plc."+s).each(function(i,e) {
          var options = { href : e.href };

          /*@cc_on
            @if (@_jscript_version >= 5.7)
              $(e)
                .bind('cbox_open', function() {
                  $('object, embed').hide();
                })
                .bind('cbox_cleanup', function() {
                  $('object, embed').show();
                });
            @end
          @*/

          $(e).colorbox($(options).extend(true, opts[s])[0], function() {
            // do something?
          });
        });
      }
    })
  },

  refresh: function() {
    PLC.start();
  }

};
