$(document).ready(function()
{
    /**
     * Fix PNG transparency for Internet Explorer 6 browser by using DD_belated
     * 
     * See: http://www.dillerdesign.com/experiment/DD_belatedPNG/
     */
    (function() {
      //Skip if browser is not IE6
      if (!($.browser.msie && $.browser.version.substr(0, 1) < 7)) {
        return false;
      }

      // Fix all inline img tags using PNG files
      $('img[src$=.png]').each(function () {
        var elt = $(this); 

        if (elt.attr('rel') != 'ignore-png-fix') {
          DD_belatedPNG.fixPng(this);
        }
      });

      // Fix all tags with backgroun-image or list-style-image css property using
      // PNG files 
      $('*', 'body').each(function() {
        var elt = $(this);

        if(elt.css('backgroundImage') && !elt.hasClass('separateur') && elt.attr('rel') != 'ignore-png-fix' && elt.css('backgroundImage').indexOf('.png') > -1) {
            DD_belatedPNG.fixPng(this);
        } else if(elt.css('background') && !elt.hasClass('separateur') && elt.attr('rel') != 'ignore-png-fix' && elt.css('background').indexOf('.png') > -1) {
            alert(elt.css('background'));
            DD_belatedPNG.fixPng(this);
        } else if (elt.css('listStyleImage') && !elt.hasClass('separateur') && elt.attr('rel') != 'ignore-png-fix' && elt.css('listStyleImage').indexOf('.png') > -1) {
            DD_belatedPNG.fixPng(this);
        }
      });
    })();

    /**
     * Append a usefull "js" class to the body so you can style whether
     * javascript is available or not.
     * 
     * Css example to hide accordion only when javascript engine is turned on:
     * 
     *   .js .accordion {
     *     display: none;
     *   }
     * 
     */
    (function() {
      $('body').addClass('js');
    })();

    /**
     * Open "external" windows in new tabs or windows according browser
     * configuration
     * 
     * Usage: Just append rel="external" to your <a href=""> tag
     */
    (function() {
      $('a[rel*=external]').click( function() {
        window.open(this.href);
        return false;
      });
    })();

    /**
     * Remove border on radio and option elements for IE6
     */
    (function() {
      if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
        $('input[type=radio]').css('border', 'none');
        $('input[type=checkbox]').css('border', 'none');
      }
    })();

    /**
     * Fix css special selector for IE6
     */
    (function() {
      //Skip if browser is not IE6
      if (!($.browser.msie && $.browser.version.substr(0, 1) < 7)) {
        return false;
      }

      $('div.formulaire-degrade > table').css('width', '800px');
      $('div.formulaire-degrade > table').css('margin', 'auto');
      $('div.formulaire-degrade > div').css('width', '800px');
      $('div.formulaire-degrade > div').css('margin', 'auto');
      $('td > h5').css('margin-top', '15px');
      $('tbody > tr > td > h5').css('margin-top', '0px');
      $('tr.doux > td').css('color', 'gray');
    })();

});
