function displayLinks()
{
  $('#body').scrollTo('#download_button', 500, {
    queue: true,
    onAfter: function()
    {
      $('#download_links').slideToggle(500);
    }
  });
}

function displayLongDescription(media_id)
{
  $('#full_description_' + media_id).fadeIn(500);
  $('#full_description_' + media_id).scrollTop = 0;
}

function displayDeadLinkBox(media_id, type)
{
  $('#overlay').css('height', document.body.clientHeight);
  $('#dead_link_ajax_indicator').hide();
  document.getElementById('dead_link_captcha').value = '';
  document.getElementById('dead_link_media_id').value = media_id;
  document.getElementById('dead_link_media_type').value = type;
  
  $('#overlay').fadeIn(300, function()
  {
    var div = document.getElementById('dead_link_box');
    
    if (typeof document.body.style.maxHeight == "undefined") {
      $('html').css('overflow','hidden');
      $('body','html').css({height: '100%', width: '100%'});
    }
    
    $.ajax({
     type: "POST",
     url: "/lien_mort",
     cache: false,
     success: function(html)
     {
       var div = document.getElementById('dead_link_box');
       
       $('#dead_link_box div.captcha_container').html('');
       $('#dead_link_box div.captcha_container').prepend(html);
       
       $('#dead_link_box').css('display', 'block');
       
       div.style.marginLeft = '-' + parseInt((div.clientWidth / 2), 10) + 'px';
       
       if (!(jQuery.browser.msie && jQuery.browser.version < 7))
       {
         div.style.marginTop = '-' + parseInt((div.clientHeight / 2), 10) + 'px';
       }
       else
       {
         div.style.marginTop = (0 - parseInt(div.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px')
       }
     }
   });
  });
}

function closeDeadLinkBox()
{
  $('#dead_link_box').hide(500);
  $('#overlay').hide(500);
  $('body','html').css({height: 'auto', width: 'auto'});
  $('html').css('overflow','');
  
  return false;
}

function sendDeadLink()
{
  var captcha_typed = document.getElementById('dead_link_captcha').value;
  
  if (captcha_typed == '')
  {
    alert("Vous devez taper le code contenu dans l'image");
  }
  else
  {
    $('#dead_link_ajax_indicator').show('slow');
    //document.getElementById('dead_link_ajax_indicator').style.display = 'inline';
    
    var media_id   = document.getElementById('dead_link_media_id').value;
    var media_type = document.getElementById('dead_link_media_type').value;
    var captcha    = document.getElementById('dead_link_captcha').value;
    
    $.ajax({
      type: "POST",
      url: "/lien_mort/signaler",
      data: "media_id=" + media_id + "&captcha=" + captcha + "&type=" + media_type,
      cache: false,
      success: function(msg)
      {
        if (msg == 'wrong_code')
        {
          alert('Le code tapé est incorrect');
        }
        else
        {
          alert('Votre signalement a bien été pris en compte, merci de votre contribution !');
          
          closeDeadLinkBox();
        }
        
        $('#dead_link_ajax_indicator').hide('slow');
      }
    });
  }
  
  return false;
}

function displayTrailer(trailer_id)
{
  $('#overlay').css('height', document.body.clientHeight);
  
  $('#overlay').fadeIn(300, function()
  {
    if (typeof document.body.style.maxHeight == "undefined")
    {
      $('html').css('overflow','hidden');
      $('body','html').css({height: '100%', width: '100%'});
    }
    
    var html = '';
    
    html  = '<div class="trailer_content">'
    html += '<div style="padding: 5px 0"><a href="#" onclick="hideTrailer(); return false">Fermer</a></div>';
    html += '<object>';
    html += '<param name="movie" value="http://www.allocine.fr/blogvision/' + trailer_id + '" />';
    html += '<param name="allowFullScreen" value="true" />';
    html += '<param name="allowScriptAccess" value="always" />';
    html += '<embed src="http://www.allocine.fr/blogvision/' + trailer_id + '" type="application/x-shockwave-flash" width="100%" height="100%" allowFullScreen="true" allowScriptAccess="always" />';
    html += '</object>';
    html += '</div>';
    
    $('#trailer_box').html('');
    $('#trailer_box').prepend(html);
    $('#trailer_box').css('display', 'block');
    
    var div = document.getElementById('trailer_box');
    
    div.style.marginLeft = '-' + parseInt((div.clientWidth / 2), 10) + 'px';
    
    if (!(jQuery.browser.msie && jQuery.browser.version < 7))
    {
      div.style.marginTop = '-' + parseInt((div.clientHeight / 2), 10) + 'px';
    }
    else
    {
      div.style.marginTop = (0 - parseInt(div.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px')
    }
  });
}

function hideTrailer()
{
  $('#trailer_box').hide(500);
  $('#trailer_box div.trailer_content').html('');
  $('#overlay').hide(500);
  $('body','html').css({height: 'auto', width: 'auto'});
  $('html').css('overflow','');
  
  return false;
}

function displayStreamingVideo(link)
{
  $('#overlay').css('height', document.body.clientHeight);
  
  $('#overlay').fadeIn(300, function()
  {
    if (typeof document.body.style.maxHeight == "undefined")
    {
      $('html').css('overflow','hidden');
      $('body','html').css({height: '100%', width: '100%'});
    }
    
    var html = '';
    
    html  = '<div class="trailer_content">'
    html += '<div style="padding: 5px 0"><a href="#" onclick="hideTrailer(); return false">Fermer</a></div>';
    html += '<object>';
    html += '<param name="movie" value="' + link + '" />';
    html += '<param name="allowFullScreen" value="true" />';
    html += '<embed src="' + link + '" type="application/x-shockwave-flash" width="100%" height="100%" allowFullScreen="true" allowScriptAccess="always" />';
    html += '</object>';
    html += '</div>';
    
    $('#trailer_box').html('');
    $('#trailer_box').prepend(html);
    $('#trailer_box').css('display', 'block');
    
    var div = document.getElementById('trailer_box');
    
    div.style.marginLeft = '-' + parseInt((div.clientWidth / 2), 10) + 'px';
    
    if (!(jQuery.browser.msie && jQuery.browser.version < 7))
    {
      div.style.marginTop = '-' + parseInt((div.clientHeight / 2), 10) + 'px';
    }
    else
    {
      div.style.marginTop = (0 - parseInt(div.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px')
    }
  });
}

function hideStreamingVideo()
{
  $('#trailer_box').hide(500);
  $('#trailer_box div.trailer_content').html('');
  $('#overlay').hide(500);
  $('body','html').css({height: 'auto', width: 'auto'});
  $('html').css('overflow','');
  
  return false;
}