ckeditoroptions = {
    filebrowserBrowseUrl :      'inc/ckfinder/ckfinder.html',
    filebrowserImageBrowseUrl : 'inc/ckfinder/ckfinder.html?Type=Images',
    filebrowserFlashBrowseUrl : 'inc/ckfinder/ckfinder.html?Type=Flash',
    filebrowserUploadUrl :      'inc/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
    filebrowserImageUploadUrl : 'inc/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
    filebrowserFlashUploadUrl : 'inc/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
    toolbar : [
                ['Cut','Copy','Paste','PasteText'],
                ['Undo','Redo'],'/',
                ['Bold','Italic','Underline','-','Superscript'],
                ['NumberedList','BulletedList'],
                ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],'/',
                ['Format', 'Image'],
                ['TextColor','BGColor'],
                ['Link','Unlink'],
                ['Table','HorizontalRule','SpecialChar']],
    language : 'fr',
    width : '510px',
    height : '500px',
    resize_enabled : false,
    removePlugins : 'scayt'
};

$(document).ready(function(){
    
    // using fancybox for course show
    
    // liens vers les détails des cours
    $('#listecours a').fancybox({
        'autoDimensions'    : false,
        'width'             : 800,
        'height'            : 'auto',
        'autoScale'         : false
    });
    $('#courselink_' + window.location.hash.substr(7)).click();
    
    
    
    // activation de CKeditor :
    $('textarea.wysiwyg').ckeditor(function(){}, ckeditoroptions);
    
    // animation des NEWSFLASH :
    $('.unnewsflash').eq(0).fadeIn(2000);
    if ($('.unnewsflash').length > 1) {
        window.setTimeout('newsflash_change()', 5000);
    }
    newsflash_change = function() {
        var newsflash = $('.unnewsflash');
        newsflash.eq(0).parent().append('<div class="unnewsflash">' + newsflash.eq(0).text() + '</div>');
        newsflash.eq(0).fadeOut(1000, function(){
            $(this).remove();
            newsflash.eq(1).fadeIn(1000);
        });
        window.setTimeout('newsflash_change()', 5000);
    }
    
    // fondu enchaîné des bannières :
    window.setTimeout('banner_change()', 7000);
    banner_change = function() {
        var banners = $('div#visuel img');
        var nb = banners.length - 1;
        banners.eq(nb).parent().prepend('<img src="' + banners.eq(nb).attr('src') + '" alt="' + banners.eq(nb).attr('alt') + '" />');
        banners.eq(nb).fadeOut(1000, function(){
            $(this).remove();
        });
        window.setTimeout('banner_change()', 7000);
    }
    
    // animation du bouton "EDIT" :
    var timer;
    var adminshown = false;
    $('#adminbutton').hover(function(){
        if (adminshown === false) {
            adminshown = true;
            $(this).animate({top:'0px'});
        }
        clearTimeout(timer);
    }, function(){
        timer = window.setTimeout('admin_hide()', 1000);
    });
    admin_hide = function (){
        adminshown = false;
        $('#adminbutton').animate({top:'-30px'});
    }
    
    if (window.location.href.indexOf('horaire') !== -1) {
        $('table').removeAttr('style').removeAttr('cellpadding').removeAttr('cellspacing').removeAttr('border').addClass('horaires');
    }
    
    if (window.location.href.indexOf('cours') !== -1) {
//         $('#listecours').after($('#contenttext > p > img').css({margin: '30px 0 0 0'}));
        $('#grillecours').find('th,td').removeAttr('style').each(function(){
            $(this).html($(this).text());
        });
    }

    
});

function check_question_form() {
    var result = true;
    $('tr.mandatory input').each(function(){
        if (this.value == '') {
            alert("Veuillez renseigner tous les champs marqués en rouge.");
            result = false;
            return false;
        }
    });
    return result;
}

