
var pageResized = false;

function prepareDocument() {
  $('.content').wrapAll('<div id="content" class="page"/>');
  $('.liens').wrapAll('<div id="liens" class="page"/>');
  $('.share').wrapAll('<div id="share" class="page"/>');
  var pdf = '';
  if ($('#content h2.content').attr('pdf'))
    pdf = '<p class="action pdf"><a href="'+$('#content h2.content').attr('pdf')+'">Télécharger le PDF</a></p>';
  if (!$('#share').length)
    $('body').append('<div id="share" class="page"/>');
  var html = '<p class="titre">Partager</p><p class="action recom">Recommander cette page</p><p class="action print">Imprimer la page<p>'+pdf;
  if ($('#share p.lien').length)
    html += '<p class="titre liens">Liens</p>';
  $('#share').prepend(html);
  $('#liens p.savoirplus a').html('en savoir plus');
  commonPrepare();
  // actions
  $('#share p.print').click(printPage);
  $('#share p.recom').click(recoForm);
}

function resizeDocument(w) {
  var h = $('#content').height();
  if ($('#liens').height() > h)
    h = $('#liens').height();
  if (!pageResized) h += 30;
  pageResized = true;
  if (h < 600 - 96 - 27)
    h = 600 - 96 - 27;
  $('#content').height(h);
  $('#page').height(h + 97);
  $('#footer').css('top', (h + 97)+'px');
}

function documentPrepared() {
  commonPrepared();
}

function printPage() {
  window.open('/imprimer.php?id='+$('#liens p.titre').attr('id').substr(3));
}


