$(document).ready(initReglage);

function initReglage()
{
  var classBody = $("body").attr("class");
  
  //on gère la taille du tableau
  var tailleMain = $("#main").css("width");
  
  $('table').each(  
  function()
  { 
    var tailleTab = $(this).css("width");
    if (tailleTab > tailleMain)
    {
      $(this).css("width",tailleMain);
    }
  }
  
  );
  
  //on gère le menu à l'accueil
 /* if (classBody == "accueil")
  {
    $("#nested .first_level>li a span").each(
    
      function()
      {
        var contenuSpan = $(this).html();
        if (contenuSpan == "Fiches Techniques")
        {
          $(this).parent().parent().css("display","none");
        }
      }
    
    );
  } */
  
  //on gere l'espacement des cellules
  $('table').attr("cellspacing","0");
  $('table').attr("cellpadding","0");
  
  //on gère la première ligne des tableaux
  if ( classBody !="ficheTechnique" && classBody !="presentation" )
  {
      $('table tr:first-child').css("background-color","#cccccc");
      $('table tr:first-child').css("color","#ffffff");
      $('table tr:first-child').css("font-weight","bold");
      $('table tr:first-child').css("text-align","center");
  }
  else
  {
      /*if (classBody == "ficheTechnique")
      {
        $("<img src='/images/kookline/imgDown.jpg' alt='Telecharger' class='imgFichTek'/>").insertAfter("table tr td ul");
        $('table tr td ul li').css("font-weight","bold");
        $('table tr td ul li span').css("font-weight","bold");
      } */
      $('table').attr("border","0");
      $('table').css("border","0 none");
      $('table tr td').css("border","0 none");
      $("table tr td p").css("text-align","left");
      $("table tr td a").attr("target","_blank");
  
  }
  
  $('table tr:first-child td:last-child').css("border-right","0 none");
  
  //on gère le menu #banner #nested
  $('#banner #nested .first_level>li:last>a').css("border","0 none");
  
  //on gère la taille des select dans les formulaires
  $('.formulaire select').each
  (
    function()
    {
    $(this).css("width","230px");
    }
  );
  
  //on gère les checkbox
  $('.formulaire div:has(.group_multi_checkbox)').each
  (
    function()
    {
       $(this).css("float","left");
    }
  );
  
  //on gère les btn radio
  $('.formulaire div:has(.group_multi_radio)').each
  (
    function()
    {
       $(this).css("float","left");
    }
  );
  //permet de placer le formulaire de contact 
  if (classBody == "contact")
  {
    $('#contactInfo').css("display","block");
    var classError = false;
    $(".error_form").each(function(){classError = true;});
    if (classError)
    {
        //$('form').css("width","697px");
        $('form .submit #submitid').css("margin-right","5px");
        $("form fieldset>div:first").attr("id","msgMail");
        /*$("form fieldset>div").each(
        
          function(i)
          {
            var idDiv = $(this).attr("id");
            if (idDiv == "msgMail")
            {
               $(this).css("float","right");
               $(this).css("margin-right","5px");
            }
            else
            {
                if (i==1)
                {
                  $(this).css("float","right");
                  $(this).css("clear","both");
                  $(this).attr("class","msgMail");
                  $(this).css("width","44%");
                  $(this).css("margin-top","5px");
                }
                else
                {
                  if(i==2)
                  {
                    $(this).css("margin-top","-15px");
                    $(this).css("clear","left");
                    $(this).css("float","left");
                  }
                  else
                  {
                    $(this).css("clear","left");
                    $(this).css("float","left");
                  }
                }
                
            }
           
          }
        );
        $("form fieldset div:not(.msgMail) textarea").attr("rows","1");*/
        $(".msgMail textarea").attr("rows","6");
        $(".msgMail textarea").css("height","117px");
        $("form .submit input#submitid").attr("value","ENVOYER");
    }
    else
    {
        $("form fieldset>div").css("clear","left");
        $("form fieldset>div").css("float","left");
        //$("form fieldset>div:first").css("float","right");
        //$("form fieldset>div:first").attr("id","msgMail");
        //$("form fieldset div:not(#msgMail) textarea").attr("rows","1");
        $("#msgMail textarea").attr("rows","6");
        $("#msgMail textarea").css("height","117px");
        $("form .submit input#submitid").attr("value","ENVOYER");
    }  
  }
  
  if (classBody == "actualite")
  {
    $("<h1 id='hUnActu'>Actualit&eacute;s</h1>").insertBefore("#news_events_list");
    $('#hUnActu').css("text-align","left");
    $('#hUnActu').css("margin-left","57px");
    $("#news_events_list .news_event").each(
      function()
      {
          var idActu = $(this).attr("id");
          var contenuChapo = $(this).children(".chapo").html();
          $('<ul class="chapoUl"><li>'+contenuChapo+'<span></span></li></ul>').insertAfter("#"+idActu+" .period");
      }
    );
    /*$('<ul class="chapoUl"><li><span></span></li></ul>').insertAfter(".period");
    var contenuChapo = $('.chapo').html();*/
    $('.chapo').css("display","none");
    //$('.chapoUl li span').html(contenuChapo);
  }
  
  var hauteurMain = $('#main').height();
  /*var hautConteneur = $('#contents').height();*/
  
  /*615 correspond à la hauteur de la div wrapper. Mis en dur dut à IE6*/
  if (hauteurMain>615)
  {
    $('#wrapper').css("overflow","auto");
  }
}
