$(function(){

  $('.texte').each(function(){
    $(this).height($(this).parent().parent().height());
    $(this).width($(this).parent().parent().width());
  });

/*
  $.colorbox({
    href:"buzz.html",
    open: true,
    overlayClose: false,
    transition: 'none',
    onComplete: function(){
      box_buzz_btns()
    },
    height: "600"
  });*/

  //
  //
  //$.colorbox({
  //		href:"prebuzz.html",
  //		overlayClose: false,
  //		onComplete: function(){	pre_box_finished() },
  //    onClosed: function() {loadbuzz()},
  //    overlayClose: false,
  //    opacity: 1,
  //    escKey: true,
  //    close: '',
  //		height: "500"
  //	});


  /**
	*  Gestion des popins
	**/
  $('a.box-1').colorbox({
    href:"buzz.html",
    overlayClose: false,
    onComplete: function(){
      box_buzz_btns()
    },
    height: "600"
  });




  $('a.box-10').colorbox({
    href:"kost.html",
    iframe: true,
    overlayClose: false,
    width: "740",
    height: "510"
  });
  VideoJS.setupAllWhenReady();
  $('a.box-2').colorbox({
    href:"altergaz.html",
    iframe: true,
    overlayClose: false,
    width: "740",
    height: "450",
    opacity: "0.97"
  });
  $('a.box-4').colorbox({
    href:"chemise_web.html",
    iframe: true,
    overlayClose: false,
    width: "740",
    height: "520",
    opacity: "0.97"
  });
  $('a.box-7').colorbox({
    href:"focus.html",
    iframe: true,
    overlayClose: false,
    width: "760",
    height: "700"
  });

	$('a.box-9').colorbox({
    href:"fluidbook-evolvemag-2/index.html",
    iframe: true,
    overlayClose: false,
    width: "900",
    height: "750"
  });
});


function pre_box_finished() {
  $('#cboxClose').hide();
  setTimeout(function(){
    $.colorbox.close()
    }, 4000);
}




/**
* Gestion des boutons de la box BUZZ
**/
function box_buzz_btns(){
    try{

    }catch(ex){}

  VideoJS.setupAllWhenReady();
  $('#vignettes ul li a').each(function(){
    $(this).click(function(){
      var video_to_play = $(this).attr('href');

      var source_html = '<video id="example_video_1" class="video-js" width="480" height="362" controls="controls" autoplay="autoplay" preload="auto" poster="' +video_to_play+'.png">';
      source_html +=  '<source src="'+video_to_play+'.mp4" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' class="mp4"/>';
      source_html +=  '<source src="'+video_to_play+'.webm" type=\'video/webm; codecs="vp8, vorbis"\' class="webm" />';
      source_html +=  '<source src="'+video_to_play+'.ogv" type=\'video/ogg; codecs="theora, vorbis"\' class="ogg" />';
      source_html +=  '<!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->';
      source_html +=  '<object id="flash_fallback_1" class="vjs-flash-fallback" width="480" height="362" type="application/x-shockwave-flash"';
      source_html +=  '  data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">';
      source_html +=  '  <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />';
      source_html +=  '  <param name="allowfullscreen" value="true" />';
      source_html +=  '  <param name="flashvars" value=\'config={"playlist":[{"url": "'+video_to_play+'.mp4","autoPlay":false,"autoBuffering":true}]}\' id="flashvars"/>';
      source_html +=  '  <!-- Image Fallback. Typically the same as the poster image. -->';
      source_html +=  '  <img src="'+video_to_play+'.png" width="480" height="362" alt="Poster Image" title="No video playback capabilities." />';
      source_html +=  '</object>';
      source_html +=  '</video>';

      $('.video-js-box').empty().append(source_html);
      VideoJS.setupAllWhenReady();
      return false;
    });
  });

};

