function replaceElementContent(id, text)
{
    document.getElementById(id).innerHTML = text;
}
function afficherAccroche(id)
{
    id = 'accroche' + id;

    if (document.layers)
    {
        current = (document.layers[id].display == 'none') ? 'table-row' : 'none';
        document.layers[id].display = current;
    }
    else if (document.all)
    {
        current = (document.all[id].style.display == 'none') ? '' : 'none';
        document.all[id].style.display = current;
    }
    else if (document.getElementById)
    {
        vista = (document.getElementById(id).style.display == 'none') ? 'table-row' : 'none';
        document.getElementById(id).style.display = vista;
    }
}

function changeClass(di, clas)
{
    document.getElementById(di).className=clas;
}

function visionner(url, width, height, hostURL, hostNom, player, noAutoStart, noResize, previewImage, downloadLink, redirectLink, mp4URL, previewImageHD, mp4Width, mp4Height)
{
    //var baseWidth = (mp4URL != '') ? 858 : 640;
    var baseWidth = (mp4URL != '' || width > 640) ? 864 : 640;

    if (mp4URL != '' && mp4Width > 0 && mp4Height > 0) {
        width = mp4Width;
        height = mp4Height;
    }

    if (!width || !height) {
        width=baseWidth;
        height=Math.round(baseWidth / 4 * 3);
    }

    if (!noResize) {
        ratio=width/height;
        width=baseWidth;
        height=Math.round(baseWidth/ratio);
    }

    var autoStart = (noAutoStart) ? 'false' : 'true';

    document.getElementById('flvVisionneur').innerHTML = '';
    
    var html = '';
    if (player == 'wmp') {
        height += 64;
        html = '<object id="Player" name="Player" width="' + width + '" height="' + height + '" align="center" type="application/x-oleobject" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">';
        html += '<param name="URL" value="' + url + '"></param>';
        html += '<param name="autoStart" value="true"></param>';
        html += '<param name="showControls" value="true"></param>';
        html += '<param name="stretchToFit" value="true"></param>';
        html += '<param name="DisplaySize" value="4"></param>';
        html += '<embed width="' + width + '" height="' + height + '" align="center" src="' + url + '" type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" autostart="true" displaysize="4"></embed>';
        html += '</object>';
        html += '<p style="font-size: 11px; margin: 0; margin-top: 5px; text-align: center;">Double-cliquez sur la vid&eacute;o pour passer en mode plein &eacute;cran</p>';
    } else if (player == 'qt') {
        height += 16;
        html += '<object name="Player" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="' + width + '" height="' + height + '" >';
        html += '<param name="pluginspage" value="http://www.apple.com/quicktime/download/indext.html">';
        html += '<param name="TYPE" value="video/quicktime">';
        html += '<param name="SRC" value="' + url + '">';
        html += '<param name="CONTROLLER" value="TRUE">';
        html += '<param name="AUTOPLAY" value="true">';
        html += '<param name="scale" value="aspect">';
        html += '<embed width="' + width + '" height="' + height + '" hspace="0" vspace="5" controller="TRUE" src="' + url + '" type="video/quicktime" bgcolor="#000000" border="0" frameborder="NO" palette="foreground" pluginspace="http://www.apple.com/quicktime/download/indext.html" title="" scale="aspect"></embed>';
        html += '</object>';
    } else if (player == 'divx') {
        height += 20;
        html = '<object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616" width="' + width + '" height="' + height + '" codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab">';
        html += '<param name="src" value="' + url + '" />';
        html += '<embed type="video/divx" src="' + url + '" width="' + width + '" height="' + height + '" pluginspage="http://go.divx.com/plugin/download/">';
        html += '</embed>';
        html += '</object>';
        html += '<p style="font-size: 11px; margin: 0; margin-top: 5px; text-align: center;">Double-cliquez sur la vid&eacute;o pour passer en mode plein &eacute;cran</p>';
    } else if (player == 'flv' || player == 'mp4') {
        //height += 20;

        if (mp4URL) {
            //var myFlashVars = "file=" + mp4URL + "&fallback=" + url;
            //var myFlashVars = "file=" + url + "&plugins=http://www.jeuxonline.info/flvplayer/hd&hd.file=" + mp4URL + "&hd.state=true";
            var myFlashVars = "file=" + url + "&plugins=hd&hd.file=" + mp4URL;
//            var myFlashVars = "file=" + mp4URL;
        } else {
            var myFlashVars = "file=" + url;
        }
        myFlashVars += "&showdigits=true&autostart=" + autoStart + "&showfsbutton=true&repeat=false&overstretch=false";
        myFlashVars += "&frontcolor=ffffff&backcolor=FFFFFF";

        if (previewImageHD && width > 512) {
            myFlashVars += "&image=" + previewImageHD;
        }
        else if (previewImage) {
            myFlashVars += "&image=" + previewImage;
        }
        if (downloadLink) {
            myFlashVars += "&showdownload=true&link=" + downloadLink;
        }
        if (redirectLink) {
            myFlashVars += "&linkfromdisplay=true&linktarget=_top";
        }

        myFlashVars += "&skin=http://dl.jeuxonline.info/player/bekle.zip&controlbar=over";

        var flvHtml = '<embed src="http://dl.jeuxonline.info/player/player.swf" width="' + width + '" height="' + height + '" allowscriptaccess="always" allowfullscreen="true" flashvars="' + myFlashVars + '" wmode="transparent" style="width:' + width + 'px; height:' + height + 'px;vertical-align:bottom;margin-left:-3px" />';
        document.getElementById('flvVisionneur').innerHTML = flvHtml;

    }
    if (html != '') {
        document.getElementById('videoVisionneur').innerHTML = html;
    }
}

function colorerVideoVersion(versionId)
{
    if (document.getElementsByTagName) {
        var tables = document.getElementsByTagName('table');
        for (var l=0; l < tables.length; l++)
        {
            var t = tables[l];
            if (t.id == 'version_' + versionId) {
                t.className = 'videoVersion videoVersionSelectionne';
            } else if (t.id.substring(0, 8) == 'version_') {
                t.className = 'videoVersion';
            }
        }
    }
}
function afficherImage(url, x, y)
{
    x += 24;
    y += 24;
    window.open(url, '_blank', 'width=' + x + ',height=' + y + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}
function afficherVideoCapture(vidCapID, videoID, fichier, x, y)
{
    y += 24;
    url = 'http://www.jeuxonline.info/jolfiches/videoCapture.php?videoCaptureID=' + vidCapID + '&videoID=' + videoID + '&fichier=' + fichier;
    window.open(url, '_blank', 'width=' + x + ',height=' + y + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function signaler(commentaireId)
{
    x = window.confirm('Etes-vous certain de vouloir demander la suppression de ce commentaire ?');
    if (x) {
        d = document.getElementById('signalement_' + commentaireId);
        d.innerHTML = '<img src="http://www.jeuxonline.info/jolfiches/videoCommentaireSignaler.php?commentaireId=' + commentaireId + '" width="0" height="0" alt="" /> <span style="color: red;">Commentaire signal&eacute;</span>';
    }
}

function verifierFormulaireModificationFiche()
{
    if (document.getElementById) {
        raison = document.getElementById('raison').value;
        if (raison == '') {
            window.alert("Vous devez expliquer la raison des changements que vous avez apportés à cette fiche dans le champ prévu à cet effet.");
            return false;
        } else {
            return true;
        }
    }

    return true;
}

function afficher(id)
{
    if (document.getElementById)
    {
        vista = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
        document.getElementById(id).style.display = vista;
    }
    return false;
}

function afficherFiltres()
{
    afficher('filtres');
    if (document.getElementById)
    {
        t = document.getElementById('afficherFiltres').innerHTML;
        nT = (t == '+') ? '-' : '+';
        document.getElementById('afficherFiltres').innerHTML = nT;
    }
    return false;
}

$(document).ready(function(){
    if (document.getElementById('text_tools_1')) {
        $("#text_tools_1").click(function(){ 
            var fontSize = $("#actuCorps").css('font-size');
            fontSize = fontSize.replace('px', '');
            if (fontSize > 9) fontSize--;
            $.cookie('actuFontSize', fontSize, { path: '/', expires: 30 } );
            $("#actuCorps").css('font-size', fontSize + 'px');
            if (fontSize == 12) {
                $('#text_tools_default').hide();
            } else {
                $('#text_tools_default').show();
            }
            return false;
        });
    }
    if (document.getElementById('text_tools_2')) {
        $("#text_tools_2").click(function(){
            var fontSize = $("#actuCorps").css('font-size');
            fontSize = fontSize.replace('px', '');
            if (fontSize < 28) fontSize++;
            $.cookie('actuFontSize', fontSize, { path: '/', expires: 30 } );
            $("#actuCorps").css('font-size', fontSize + 'px');
            if (fontSize == 12) {
                $('#text_tools_default').hide();
            } else {
                $('#text_tools_default').show();
            }
            return false;
        });
    }
    if (document.getElementById('text_tools_3')) {
        $("#text_tools_3 a, #text-tools2-3 a").click(function(){
            window.open(this.href, 'jol_print', 'width=660,height=480,location=no,resizable=yes,menubar=no,directories=no,status=no,toolbar=no,scrollbars=yes');
            return false;
        });
    }
    if (document.getElementById('text_tools_default')) {
        $("#text_tools_default").click(function(){
            $('#actuCorps').css('font-size', '12px');
            $('#text_tools_default').hide();
            $.cookie('actuFontSize', null, { path: '/' } );
            return false;
        });
    }
    // Image preview
    if (document.getElementById('image_preview_container')
        && document.getElementById('image_preview')
        && document.getElementById('carousel')) {
        var colonneGaucheWidth = $('#carousel-container').outerWidth();
        if (colonneGaucheWidth > 400) {
            var decal = Math.round((colonneGaucheWidth - 414) / 2);
            $('#image_preview').css('left', decal + 'px');
        }
        $('#carousel img').mouseover(function(){
            var src = $(this).attr('src');
            src = src.replace('-100', '-400');
            $('#image_preview').css('backgroundImage', 'url(' + src + ')');
            $('#image_preview_container').show();
        });
        $('#carousel img').mouseout(function(){
            $('#image_preview_container').hide();
        });
    }

    // Onglets vidéos
    if (document.getElementById('video_onglets')) {
        $('#video_onglets a').click(function() {
            var href=$(this).attr('href');
            var id=href.match(/#(.*)$/);
            id=id[1];
            $('#video_onglets_container div.video_onglets_contenu').hide();
            $('#video_onglets_contenu_' + id).show();
            $('#video_onglets li').removeClass('actif');
            $('#video_onglet_' + id).addClass('actif');
            $(this).blur();
        });
    }
});
// Kelkoo
var oKKConf = {"width": "300","border": "#FFFFFF","background": "#FFFFFF","link": "#00468C","font": "#000000"};
