
function commonPrepare() {
  $('.header').wrapAll('<div id="header"></div>');
  $('.auteur').wrapAll('<div id="auteur"></div>');
  $('.livre').wrapAll('<div id="livre"></div>');
  $('.blog').wrapAll('<div id="blog"></div>');
  $('.conseils').wrapAll('<div id="conseils"></div>');
  $('.activites').wrapAll('<div id="activites"></div>');
  $('.videos').wrapAll('<div id="videos"></div>');
  $('#conseils h2, #activites h2, #videos h2').wrap('<div class="l3titre"></div>');
  $('.definition').wrapAll('<div id="definition" class="barbloc bbleft"></div>');
  $('.idees').wrapAll('<div class="barbloc bbleft"></div>');
  $('.famille').wrapAll('<div class="barbloc bbleft"></div>');
  $('.mono').wrapAll('<div class="barbloc bbleft"></div>');
  $('.grandir').wrapAll('<div class="barbloc bbleft"></div>');
  $('div.bbleft').wrapAll('<div id="leftbar"></div>');
  $('.conseils2').wrapAll('<div class="barbloc bbright"></div>');
  $('.histoires').wrapAll('<div class="barbloc bbright"></div>');
  $('.ecoles').wrapAll('<div class="barbloc bbright"></div>');
  $('.glossaire').wrapAll('<div class="barbloc bbright"></div>');
  $('.ressources').wrapAll('<div class="barbloc bbright"></div>');
  $('div.bbright').wrapAll('<div id="rightbar"></div>');
  $('.content').wrapAll('<div id="content"></div>');
  $('.footer').wrapAll('<div id="footer"></div>');
  commonResize();
}

function commonResize() {
  var w = $(window).width();
  if (w < $(document).width())
    w = $(document).width();
  if (w > 985) {
    $('#header, #auteur, #conseils, #leftbar, #footer, #pubgg1').css('marginLeft', Math.floor((w-985)/2)+'px');
  }
  else {
    $('#header, #auteur, #conseils, #leftbar, #footer, #pubgg1').css('marginLeft', '0px');
  }
  $('#pubgg2').css('marginLeft', (parseInt($('#pubgg1').css('marginLeft').replace('px', ''))+741)+'px');
  $('#pubgg3').css('marginLeft', (parseInt($('#pubgg1').css('marginLeft').replace('px', ''))+253)+'px');
  var m = 1010;
  if ($('#leftbar').height() > m) m = $('#leftbar').height() - 10;
  if ($('#rightbar').height() > m) m = $('#rightbar').height() - 10;
  if ($('#content').height() < m)
    $('#content').height(m);
  $('#pubgg3').css('top', ($('#content').height() + 460 - 280)+'px');
}

function preloadImages() {
  var d = document;
  if(d.images) {
    if(!d.MM_p) d.MM_p = new Array();
    var i,j = d.MM_p.length;
    var a = preloadImages.arguments;
    for(i = 0; i < a.length; i ++)
      if (a[i].indexOf("#") != 0) {
	d.MM_p[j] = new Image;
	d.MM_p[j++].src = a[i];
      }
  }
}


