$(document).ready(function(){
    
    $(this).initBody(); // body classes
    $(this).formInit(); // append class depending on type of input
    $(this).firstLastChild(); // appends class to first and list children of lists, td and th elements
   // $(this).evenOddChild(); // appends class to odd and even list children of lists, td and th elements
    $(this).brokenImage(); // hides broken images
    
    $(this).markExtLink('out'); // marks external links : options 'in' or 'out' depending where tha marker has to be related to the link
    
/////////////////////////////////////////////////////////
//            DROPDOWN
////////////////////////////////////////////////////////
    $(function(){

    $("ul.dropdown li").hover(function(){
    
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

    });
    
/////////////////////////////////////////////////////////
//            FANCYBOX
////////////////////////////////////////////////////////
    
    function formatTitle(title, currentArray, currentIndex) {
        return '<div class="fancybox-title-padding">' + title + '' + ' (' + (currentIndex + 1) + '/' + currentArray.length + ') </div>';
    }
    
    $('.article-gallery a, .view-picture').fancybox({
        'padding'        : 2,
        'titlePosition'    : 'inside',
        'titleFormat'    : formatTitle
    });
    
    $('.open-popup').fancybox({
        'padding'        : 0
    });

/////////////////////////////////////////////////////////
//            GALLERY
////////////////////////////////////////////////////////

  /**  $('.gallery-wrapper .gallery-item:nth-child(4n)').each(function(){
        $('<div class="clear"></div>').insertAfter(this);
    });   */
    
/////////////////////////////////////////////////////////
//            FORM TRANSFORM
////////////////////////////////////////////////////////

    
    
});
