function OpenURL(_url, _addFooter, _width) {
    $(document).ready(function() {
        $.colorbox({ href: _url, innerWidth: "582px", innerHeight: _width + "px", scrolling: false, opacity: 1, iframe: true, addFooter: _addFooter, overlayClose:false });
    });
}

$(document).ready(function() {
    $("#div_parametre").click(function() {
        if ($("#table_sup").css('display') == 'none') {
            $("#table_sup").fadeIn("slow");
            $("#parametre").css({ 'background-image': 'url(../images/moins.png)' });
        }
        else {
            $("#table_sup").fadeOut("slow");
            $("#parametre").css({ 'background-image': 'url(../images/plus.png)' });
        }
    });

    $("#div_recheche").click(function() {
        if ($(".table_sup").css('display') == 'none') {
            $(".table_sup").fadeIn("slow");
            $(".parametre").css({ 'background-image': 'url(../images/moins.png)' });
            $("#ctl00_ContentPlaceHolder1_cycle1_IsOpen").val(1);
        }
        else {
            $(".table_sup").fadeOut("slow");
            $(".parametre").css({ 'background-image': 'url(../images/plus.png)' });
            $("#ctl00_ContentPlaceHolder1_cycle1_IsOpen").val(0);
        }
    });

    $("#ctl00_ContentPlaceHolder1_txtRep").click(function() {
        if ($("#ctl00_ContentPlaceHolder1_hidden_txt").val() == $("#ctl00_ContentPlaceHolder1_txtRep").val()) {
            $("#ctl00_ContentPlaceHolder1_txtRep").val("");
        }
    });

    tmpHtml = "<div class='clearfix'>" + $(".paging_result td").html() + "</div>";
    //$(".paging_result td").html(tmpHtml);

    $(".EnterChecked").keyup(function(e) {
        if (e.keyCode == 13) {
            __doPostBack('ctl00$ContentPlaceHolder1$btn_id', '');
        }
    });

    $(".EnterChecked2").keyup(function(e) {
        if (e.keyCode == 13) {

            __doPostBack('ctl00$ContentPlaceHolder1$btn_send', '');
        }
    });


    $('.clearDefault').clearDefault();

    $(".txt_cyclename").keyup(function(e) {
        if (e.keyCode == 13) {
            __doPostBack('ctl00$ContentPlaceHolder1$cycle1$lnk_recherche', '');
        }
    });
    $(".btn_rate").click(function() {
        if ($(this).attr("class") == "plus btn_rate") {
            $(".div_rate").fadeIn("slow");
            $(this).attr("class", "moins btn_rate");
        } else {
            $(".div_rate").fadeOut("slow");
            $(this).attr("class", "plus btn_rate");
        }
    });

    $(".btn_reussi").click(function() {
        if ($(this).attr("class") == "plus btn_reussi") {
            $(".div_reussi").fadeIn("slow");
            $(this).attr("class", "moins btn_reussi");
        } else {
            $(".div_reussi").fadeOut("slow");
            $(this).attr("class", "plus btn_reussi");
        }
    });

    $(".SeeReponse").change(function() {
        if ($(".rep-ok").get(0).style.display == "none") {
            $(".rep-ok").fadeIn("slow");
        }
        else { $(".rep-ok").fadeOut("slow"); }
    });


});


function swapStatusEsp() {
    var oElem = $("#ico_espaces").get(0);

    if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {
        oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        //var str = "|" + sElem + "|";
        $("#ctl00_ContentPlaceHolder1_espace").val("");
    }
    else {
        oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
        $("#ctl00_ContentPlaceHolder1_espace").val("ok");
    }
}
function swapStatusMaj() {
    var oElem = $("#ico_majuscules").get(0);
    if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {
        oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        //var str = "|" + sElem + "|";
        $("#ctl00_ContentPlaceHolder1_majuscule").val("");
    }
    else {
        oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
        $("#ctl00_ContentPlaceHolder1_majuscule").val("ok");
    }
}
function swapStatuspar() {
    var oElem = $("#ico_parentheses").get(0);
    if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {
        oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        //var str = "|" + sElem + "|";
        $("#ctl00_ContentPlaceHolder1_parenthese").val("");
    }
    else {
        oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
        $("#ctl00_ContentPlaceHolder1_parenthese").val("ok");
    }
}


function swapStatusPonct() {
    var oElem = $("#ico_ponctuation").get(0);
    if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {
        oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        //var str = "|" + sElem + "|";
        $("#ctl00_ContentPlaceHolder1_ponctuation").val("");
    }
    else {
        oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
        $("#ctl00_ContentPlaceHolder1_ponctuation").val("ok");
    }
}

function swapStatusEvaluation() {
    var oElem = $("#ico_evalutation").get(0);
    if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {
        oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        //var str = "|" + sElem + "|";
        $("#ctl00_ContentPlaceHolder1_evaluation").val("");
    }
    else {
        oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
        $("#ctl00_ContentPlaceHolder1_evaluation").val("ok");
    }
}

function swapStatusInvers() {
    var oElem = $("#ico_invers").get(0);
    var bCheckBoxState

    if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {
        oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        //var str = "|" + sElem + "|";
        $("#ctl00_ContentPlaceHolder1_inverser").val("");
        bCheckBoxState = false;
    }
    else {
        oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
        $("#ctl00_ContentPlaceHolder1_inverser").val("ok");
        bCheckBoxState = true;
    }

    //sElem = $("#ctl00_ContentPlaceHolder1_typeex").value;


    //    if (sElem == "quest") {
    //        RefreshQuestNbFiches(bCheckBoxState)
    //    }
    //    else {
    //        if (sElem == "dictee" || sElem == "comp") {
    //            RefreshAudioNbFiches(bCheckBoxState)
    //        }
    //    }

    //    RefreshAudioDispo(bCheckBoxState)
}


function swapStatusTypeEx(sElem) {
    var bInverse = false;

    if (document.getElementById('ico_invers').style.backgroundImage == "url(../images/ico_yes.gif)") {
        bInverse = true;
    }

    if (sElem == 'debut') {
        sElem = $("#ctl00_ContentPlaceHolder1_typeex").val();
    }

    if (sElem == "test") {
        sElem = "quest";
        $("#ctl00_ContentPlaceHolder1_evaluation").val("ok");
    }



    var aEmpty = $(".ico_start");
    for (i = 0; aEmpty.length > i; i++) {
        if (sElem == aEmpty[i].getAttribute('rel')) {
            oElem = aEmpty[i];
        }
        else {

        }
    }

    if ('undefined' != typeof (oElem)) {

        if ("url(../images/ico_yes.gif)" == oElem.style.backgroundImage) {
            $("#ctl00_ContentPlaceHolder1_typeex").val("");
        }
        else {
            
            $("#ctl00_ContentPlaceHolder1_typeex").val(sElem);
            if (sElem == "dictee" || sElem == "comp") {
                if ($("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "0" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() != $("#ctl00_ContentPlaceHolder1_nbaudioHidden").val()) {
                    if (!bInverse)
                        $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbaudioHidden").val());
                    else
                        $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbaudioReversedHidden").val());

                }
            }
            else {
                if (sElem == "quest") {
                    if ($("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "0" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == $("#ctl00_ContentPlaceHolder1_nbFicheNonFillBlanksHidden").val()) {
                        if (!bInverse) {
                            $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbficheHidden").val());
                        }
                        else
                            $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbFicheNonFillBlanksHidden").val());

                    }
                }
                else {
                    if (sElem == "podCast") {
                        if ($("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "0" || $("ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() != $("ctl00_ContentPlaceHolder1_nbpodcastHidden").val()) {

                            $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbpodcastHidden").val());

                        }
                    }
                    else {
                        if (sElem == "mult") {

                            if ($("ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "0" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == $("#ctl00_ContentPlaceHolder1_nbficheHidden").val()) {

                                $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbFicheNonFillBlanksHidden").val());

                            }
                        }
                        else {
                            if (sElem == "famili") {

                                if ($("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == "0" || $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val() == $("#ctl00_ContentPlaceHolder1_nbficheHidden").val()) {

                                    $("#ctl00_ContentPlaceHolder1_txt_nbFichesAfaire").val($("#ctl00_ContentPlaceHolder1_nbFicheNonFillBlanksHidden").val());

                                }
                            }
                        }
                    }

                }
            }

            __doPostBack('ctl00$ContentPlaceHolder1$btn_next', '');
        }
    }

}


function swapUnique(sElem, redirect) {
    var aEmpty = $(".ico_start");
    for (i = 0; aEmpty.length > i; i++) {
        if (sElem == aEmpty[i].getAttribute('rel')) {
            oElem = aEmpty[i];
        }
    }
    if ('undefined' != typeof (oElem)) {
        if ("url(../images/ico_yes.gif)" == oElem.style.backgroundImage) {
            //oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
        }
        else {
//            aYes = $(".ico_empty");
//            for (var i = 0; aYes.length > i; i++) {
//                aYes[i].style.backgroundImage = "url(../images/ico_empty.gif)";
//            }
            //oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
            if ('' != redirect) {
                window.location = redirect;
            }
        }
    }

}

function parseID2() {

    aYes = $(".ico_empty");
    for (var i = 0; aYes.length > i; i++) {
        var str = "|" + aYes[i].rel + "|"
        $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val().replace(str, "|"));

        $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val()+ aYes[i].rel + "|");

    }
}
function parseIDStart() {

    aYes = $(".ico_start");
    for (var i = 0; aYes.length > i; i++) {
        var str = "|" + aYes[i].rel + "|"
        $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val().replace(str, "|"));

        $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val() + aYes[i].rel + "|");

    }
}


function swapStatusImport(sElem, ids) {
    var aEmpty = $(".ico_empty");
    for (i = 0; aEmpty.length > i; i++) {
        if (sElem == aEmpty[i].getAttribute('rel')) {
            oElem = aEmpty[i];
        }
    }
    if ('undefined' != typeof (oElem)) {

        if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {

            oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
            var str = "|" + ids;
            $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val().replace(str, "|"));
        }
        else {

            oElem.style.backgroundImage = "url(../images/ico_yes.gif)";

            if ($("#ctl00_ContentPlaceHolder1_selectedIds").val() == "") {
                $("#ctl00_ContentPlaceHolder1_selectedIds").val("|" + ids);
            }
            else {
                $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val() + ids);
            }
        }
    }
}


function swapStatusDelete(sElem, ids) {
    var aEmpty = $(".ico_empty");
    for (i = 0; aEmpty.length > i; i++) {
        if (sElem == aEmpty[i].getAttribute('rel')) {
            oElem = aEmpty[i];
        }
    }
      
    if ('undefined' != typeof (oElem)) {
        
        if (-1 != oElem.style.backgroundImage.indexOf("ico_empty.gif")) {

            oElem.style.backgroundImage = "url(../images/ico_yes.gif)";
            var str = "|" + ids;
            $("#ctl00_ContentPlaceHolder1_selectedIdsDelete").val($("#ctl00_ContentPlaceHolder1_selectedIdsDelete").val().replace(str, "|"));
        }
        else {

            oElem.style.backgroundImage = "url(../images/ico_empty.gif)";

            if ($("#ctl00_ContentPlaceHolder1_selectedIdsDelete").val() == "") {
                $("#ctl00_ContentPlaceHolder1_selectedIdsDelete").val("|" + ids);
            }
            else {
                $("#ctl00_ContentPlaceHolder1_selectedIdsDelete").val($("#ctl00_ContentPlaceHolder1_selectedIdsDelete").val() + ids);
            }
        }
    }
}

function swapCheckBox(k) {

    var aEmpty = $(".chkbx");
    for (i = 1; aEmpty.length >= i; i++) {
        if (i != k) {
            document.getElementById("ctl00_ContentPlaceHolder1_chkbx_propo" + i).disabled = true;
        }
    }

    __doPostBack('ctl00$ContentPlaceHolder1$btn_envoyer_rep', '');



    //      for(i=1; aEmpty.length>=i; i++)
    //      {
    //      
    //        if(i==k)
    //        {
    //            
    //            document.getElementById("ctl00_ContentPlaceHolder1_chkbx_propo"+i).checked=true;
    //        }
    //        else
    //        {
    //            document.getElementById("ctl00_ContentPlaceHolder1_chkbx_propo"+i).checked=false;
    //        }
    //        
    //      }
}


function onPress(e) {
    var keynum;

    if (window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }

    if ($("#ctl00_ContentPlaceHolder1_hidden_txt").val() == $("#ctl00_ContentPlaceHolder1_txtRep").val()) {
        $("#ctl00_ContentPlaceHolder1_txtRep").val("");
    }

    if (keynum == 13) {
        __doPostBack('ctl00$ContentPlaceHolder1$btn_envoyer_rep', '');
    }

}

function fillScore(fiche, votrescore, sur, reponse,score1,score2,pourc) {
  
    $('.center', parent.document).html(fiche);
    $('#Lbl_score', parent.document).html(votrescore);
    $('#Lbl_ex_restants1', parent.document).html(sur);
    $('#Lbl_ex_restants3', parent.document).html(reponse);
    $('#Lbl_resultat', parent.document).html(score1);
    $('#Lbl_ex_restants2', parent.document).html(score2);
    $('.progress-bar', parent.document).attr("style", "width:" + pourc + "%");

    $('#btn_passer', parent.document).live('click', function() {
        __doPostBack('ctl00$ContentPlaceHolder1$btn_passer', '');
    });
}


function swapStatusError(sElem, ids) {
    var aEmpty = $(".ico_yes");
    for (i = 0; aEmpty.length > i; i++) {
        if (sElem == aEmpty[i].getAttribute('rel')) {
            oElem = aEmpty[i];
        }
    }
    if ('undefined' != typeof (oElem)) {

        if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {

            oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
            var str = "|" + ids;
            $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val().replace(str, "|"));
        }
        else {

            oElem.style.backgroundImage = "url(../images/ico_yes.gif)";

            if ($("#ctl00_ContentPlaceHolder1_selectedIds").val() == "") {
                $("#ctl00_ContentPlaceHolder1_selectedIds").val("|" + ids);
            }
            else {
                $("#ctl00_ContentPlaceHolder1_selectedIds").val($("ctl00_ContentPlaceHolder1_selectedIds").val() + ids);
            }
        }
    }


}



function swapStatusImport(sElem, ids) {
    var aEmpty = $(".ico_empty");
    for (i = 0; aEmpty.length > i; i++) {
        if (sElem == aEmpty[i].getAttribute('rel')) {
            oElem = aEmpty[i];
        }
    }
    if ('undefined' != typeof (oElem)) {

        if (-1 != oElem.style.backgroundImage.indexOf("ico_yes.gif")) {

            oElem.style.backgroundImage = "url(../images/ico_empty.gif)";
            var str = "|" + ids;
            $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#selectedIds").val().replace(str, "|"));
        }
        else {

            oElem.style.backgroundImage = "url(../images/ico_yes.gif)";

            if ($("#ctl00_ContentPlaceHolder1_selectedIds").val() == "") {
                $("#ctl00_ContentPlaceHolder1_selectedIds").val("|" + ids);
            }
            else {
                $("#ctl00_ContentPlaceHolder1_selectedIds").val($("#ctl00_ContentPlaceHolder1_selectedIds").val() + ids);
            }
        }
    }
}


if ($.browser.msie && $.browser.version == "6.0") {
  setTimeout(essbo, 2500);
}

function essbo() {
  //alert("essbo");
  $("#colorbox").css({ height: "900px" });
}
