/* 
fichier scripts.js
*/

var timerend=0;
var minutes=1;
var seconds=0;
var minutes0=1;
var seconds0=0;
var seconds2=0;
func = "";

var num_qcm = 0;

function showtimer(){
  if (seconds2 == seconds){
        if(minutes+0 == 0){
            if (seconds+0 == 0){
                t = 0;
        }
        else{
            t=1;
            }}
        else{t=1;};
      if ((seconds +0) == 0){
        minutes -= 1;
        seconds = 59;
      }
      else{    
        seconds -= 1;}
        seconds2 = seconds;
      if (t==timerend){
        co('suivant_game');
      }
      else{
      if (minutes < 10){
        document.getElementById('minutes').innerHTML= "0" + minutes.toString();
        }
    else{
        document.getElementById('minutes').innerHTML=minutes;
        }
      if (seconds < 10){
        document.getElementById('seconds').innerHTML= "0" + seconds.toString();
        }
    else{
        document.getElementById('seconds').innerHTML=seconds;
        }
        setTimeout('showtimer()', 1000);
      }
  }
}

function starttimer(){
    func = 'starttimer()';
    seconds2=seconds;
    seconds0=seconds;

    
  setTimeout('showtimer()', 1000);
}
function starttimer2(){
    func = 'starttimer()';
    seconds2=seconds;
    seconds0=seconds;
  setTimeout('showtimer()', 1000);
}

function changer_1(btn){
	document.getElementById(btn).className='icon2';
}
function changer_2(btn){
	document.getElementById(btn).className='icon';
}
function check(x){
	if(x == 1){
		if(document.getElementById("a").checked == true) {
			document.getElementById("a").checked = false;
			document.getElementById("QA").className = "Q";
		}
		else{
			document.getElementById("a").checked = true;
			document.getElementById("QA").className = "selected";
		}
	}
	if(x == 2){
		if(document.getElementById("b").checked == true) {
			document.getElementById("b").checked =  false;
			document.getElementById("QB").className = "Q";
		}
		else{
			document.getElementById("b").checked = true;
			document.getElementById("QB").className = "selected";
		}
	}
	if(x == 3){
		if(document.getElementById("c").checked == true) {
			document.getElementById("c").checked =  false;
			document.getElementById("QC").className = "Q";
		}
		else{
			document.getElementById("c").checked = true;
			document.getElementById("QC").className = "selected";
		}
	}
	if(x == 4){
		if(document.getElementById("d").checked == true) {
			document.getElementById("d").checked =  false;
			document.getElementById("QD").className = "Q";
		}
		else{
			document.getElementById("d").checked = true;
			document.getElementById("QD").className = "selected";
		}
	}
	if(x == 5){
		if(document.getElementById("e").checked == true) {
			document.getElementById("e").checked =  false;
			document.getElementById("QE").className = "Q";
		}
		else{
			document.getElementById("e").checked = true;
			document.getElementById("QE").className = "selected";
		}
	}
}

function com(){
var myajax=ajaxpack.ajaxobj;
var myfiletype=ajaxpack.filetype;
if (myajax.readyState == 4){ 
if (myajax.status==200 || window.location.href.indexOf("http")==-1){
	if (myfiletype=="txt"){

                txt =  myajax.responseText;
}
	else {

                txt =  myajax.responseXML;
}
if (txt.search("Votre test est termin") != -1){func = ""; document.getElementById("minutes").innerHTML="Test"; document.getElementById("seconds").innerHTML = "termin&#233;";document.getElementById("btn_rc4").disabled = true; document.getElementById("here").innerHTML = txt;}
else{
    liste = txt.split("&&T");
    document.getElementById("here").innerHTML = liste[0];
    if (liste.length == 2){if(liste[1] == "CCQ0"){minutes = 2;}else{minutes= 1; }}else{minutes= 1; }
};
if (func == "starttimer()"){document.getElementById("btn_rc4").disabled = false;seconds = 0; setTimeout('starttimer2()', 1000);};
}
}
}

function raz_creer(){
	document.getElementById("ca").checked = false;
	document.getElementById("cb").checked = false;
	document.getElementById("cc").checked = false;
	document.getElementById("cd").checked = false;
	document.getElementById("ce").checked = false;
	document.getElementById("a").value = "";
	document.getElementById("b").value = "";
	document.getElementById("c").value = "";
	document.getElementById("d").value = "";
	document.getElementById("e").value = "";
	document.getElementById("enonce").value = "";
	document.getElementById("commentaire").value = "";
}

function raz(){
	document.getElementById("a").checked = false;
	document.getElementById("b").checked = false;
	document.getElementById("c").checked = false;
	document.getElementById("d").checked = false;
	document.getElementById("e").checked = false;
}
function co(fonction){
mon_cookie = document.getElementById("nom_session").value;

if (fonction == 'vote'){
var poststr =  "&id=" + encodeURI(document.getElementById("i0").value) + "&reponse=" + encodeURI(document.getElementById("reponse").value) + "&modifier=" + encodeURI(document.getElementById("modifier").value) + "&nom_session=" +encodeURI(mon_cookie);
ajaxpack.postAjaxRequest("/QCM/vote" ,poststr,com,"txt");
}
else{
    if (fonction == 'load2'){

    var poststr =  "&methode=" + encodeURI("ajax") + "&num=" + encodeURI(document.getElementById("num").value) + "&nom_session=" +encodeURI(mon_cookie);
    ajaxpack.postAjaxRequest("/QCM/" + fonction,poststr,com,"txt");
    raz();
    }
    else{
    var l_ajax = 1;
    var poststr =  "&methode=" + encodeURI("ajax")  + "&nom_session=" +encodeURI(mon_cookie);
    nu = parseInt(document.getElementById("num").value);
    //~ module = module.replace("&#44;",",");
    if (fonction == "suivant"){
    if (num_qcm == 0){
        l_ajax = 0;
        //~ window.alert(document.title);
        if (document.title.search("Recherche") == -1){
            document.getElementById("suiv").href = "/QCM/" + module + "/" + (nu + 1);
            //~ window.alert("yee");
            //~ document.getElementById("forme").action = "/QCM/" + module + "/" + (nu + 1);
            //~ document.getElementById("forme").submit();
            num_qcm = 0;
        }
        else{
            document.getElementById("suiv").href = "/QCM/suivant";
        }
    }
    else{
        num_qcm += 1;
    }
    document.getElementById("num").value = parseInt(document.getElementById("num").value) + 1;
    }
    if (fonction == "precedent"){
    if (num_qcm == 0){
        l_ajax = 0;
        if (document.title.search("Recherche") == -1){
            document.getElementById("prec").href = "/QCM/" + module + "/" + (nu - 1);
            //~ window.alert("yee");
            //~ document.getElementById("forme").action = "/QCM/" + module + "/" + (nu + 1);
            //~ document.getElementById("forme").submit();
            num_qcm = 0;
        }
        else{
            document.getElementById("prec").href = "/QCM/precedent";
        }
        //~ document.getElementById("prec").href = "/QCM/" + module + "/" + (nu - 1);
        //~ document.getElementById("forme").action = "/QCM/" + module + "/" + (nu - 1);;
        //~ document.getElementById("forme").submit();
        //~ num_qcm = 0;
    }
    else{
        num_qcm += 1;
    }
    if (parseInt(document.getElementById("num").value) > 1){
        document.getElementById("num").value = parseInt(document.getElementById("num").value) - 1;
        }
    else{
        document.getElementById("num").value = 1;
    }
    }
    if (fonction == "test"){
        var poststr = poststr + "&methode=" + encodeURI("ajax")
        if(document.getElementById("a").checked){
        poststr =  poststr + "&a=1";
        }
        if(document.getElementById("b").checked){
        poststr =  poststr + "&b=1";
        }
        if(document.getElementById("c").checked){
        poststr =  poststr + "&c=1";
        }
        if(document.getElementById("d").checked){
        poststr =  poststr + "&d=1";
        }
        if(document.getElementById("e").checked){
        poststr =  poststr + "&e=1";
        }
    }
    if (fonction == "suivant_game"){
        document.getElementById("btn_rc4").disabled = true;
        var poststr = poststr + "&methode=" + encodeURI("ajax")
        if(document.getElementById("a").checked){
        poststr =  poststr + "&a=1";
        }
        if(document.getElementById("b").checked){
        poststr =  poststr + "&b=1";
        }
        if(document.getElementById("c").checked){
        poststr =  poststr + "&c=1";
        }
        if(document.getElementById("d").checked){
        poststr =  poststr + "&d=1";
        }
        if(document.getElementById("e").checked){
        poststr =  poststr + "&e=1";
        }
        document.getElementById("num").innerHTML = parseInt(document.getElementById("num").innerHTML) + 1;
        document.getElementById('minutes').innerHTML="Veuillez";
        document.getElementById('seconds').innerHTML="Patienter";
        if (minutes == -1){poststr = poststr + "&minutes=" + encodeURI(0)+ "&seconds=" + encodeURI(0);}
        else{poststr = poststr + "&minutes=" + encodeURI(minutes)+ "&seconds=" + encodeURI(seconds);}
        seconds = 10;
    }
    if (l_ajax == 1){
        ajaxpack.postAjaxRequest("/QCM/" + fonction,poststr,com,"txt");
    }
    }
    raz();
}
}


function com_new(){
var myajax=ajaxpack.ajaxobj;
var myfiletype=ajaxpack.filetype;
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")==-1){
	if (myfiletype=="txt"){
                txt =  myajax.responseText;
                window.alert(txt);
}
	else {
                txt =  myajax.responseXML;
}
    if (txt.search("OK") != -1){
        document.getElementById("numero").value = parseInt(document.getElementById("numero").value) + 1;
        type = document.getElementById("type").value;
        raz_creer();
        if (type == "CCQ"){
            No += 1;
            No_QCM += 1;
            No_QCM_user += 1;
        }
        else{
            No_QCM += 1;
            No_QCM_user += 1;
        }
    }
}
}
}

function com_villes(){
var myajax=ajaxpack.ajaxobj;
var myfiletype=ajaxpack.filetype;
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")==-1){
	if (myfiletype=="txt"){

		document.getElementById("here").innerHTML = myajax.responseText;

                txt =  myajax.responseText;
}
	else {
		document.getElementById("ville0").innerHTML = myajax.responseXML;
                txt =  myajax.responseXML;
}

}
}
}



function send(fonction){
    mon_cookie = document.getElementById("nom_session").value;
    reponse = "";

    if (document.getElementById("ca").checked){
        reponse += "&ca=1";
    }            
    if (document.getElementById("cb").checked){
        reponse +="&cb=1";
    }            
    if (document.getElementById("cc").checked){
        reponse +="&cc=1";
    }            
    if (document.getElementById("cd").checked){
        reponse +="&cd=1";
    }            
    if (document.getElementById("ce").checked){
        reponse +="&ce=1";
    }
    if (fonction == "save_modif"){

        var poststr =    "&modifier=" + encodeURI(document.getElementById("modifier").value) + "&a=" + encodeURI(document.getElementById("a").value) +"&b=" + encodeURI(document.getElementById("b").value) +"&c=" + encodeURI(document.getElementById("c").value) +"&d=" + encodeURI(document.getElementById("d").value) +"&e=" + encodeURI(document.getElementById("e").value)  + reponse + "&commentaire=" + encodeURI(document.getElementById("commentaire").value) + "&enonce=" + encodeURI(document.getElementById("enonce").value) + "&nom_session=" +encodeURI(mon_cookie);
        ajaxpack.postAjaxRequest("/QCM/" + fonction ,poststr,com_page,"txt");
    }
    else if (fonction == "save_modif_new"){
    //~ window.alert(document.getElementById("numero").value);

        var poststr =  "&Id=" + encodeURI(document.getElementById("Id0").value) +"&ville=" + encodeURI(document.getElementById("ville").value) +"&pays=" + encodeURI(document.getElementById("pays").value) +"&annee=" + encodeURI(parseInt(document.getElementById("annee").value)) +"&session=" + encodeURI(document.getElementById("session").value) +"&module=" + encodeURI(document.getElementById("module").value) +"&numero=" + encodeURI(document.getElementById("numero").value) +"&type_epreuve=" + encodeURI(document.getElementById("type_epreuve").value) +"&type=" + encodeURI(document.getElementById("type").value) +"&a=" + encodeURI(document.getElementById("a").value) +"&b=" + encodeURI(document.getElementById("b").value) +"&c=" + encodeURI(document.getElementById("c").value) +"&d=" + encodeURI(document.getElementById("d").value) +"&e=" + encodeURI(document.getElementById("e").value)  + reponse + "&commentaire=" + encodeURI(document.getElementById("commentaire").value) + "&enonce=" + encodeURI(document.getElementById("enonce").value) + "&nom_session=" +encodeURI(mon_cookie);
        ajaxpack.postAjaxRequest("/QCM/" + fonction ,poststr,com_page,"txt");
    }
    else{

        var poststr =  "&no=" + encodeURI(No)+"&no_qcm=" + encodeURI(No_QCM)+  "&no_qcm_user=" + encodeURI(No_QCM_user)+  "&no_ccq_user=" + encodeURI(No_CCQ_user)+  "&modifier=" + encodeURI(document.getElementById("modifier").value) +"&ville0=" + encodeURI(document.getElementById("ville0").value) +"&pays0=" + encodeURI(document.getElementById("pays0").value)+"&ville=" + encodeURI(document.getElementById("ville").value) +"&pays=" + encodeURI(document.getElementById("pays").value) +"&annee=" + encodeURI(parseInt(document.getElementById("annee").value)) +"&session=" + encodeURI(document.getElementById("session").value) +"&module=" + encodeURI(document.getElementById("module").value) +"&numero_ccq=" + encodeURI(document.getElementById("numero_ccq").value) +"&numero=" + encodeURI(document.getElementById("numero").value) +"&type_epreuve=" + encodeURI(document.getElementById("type_epreuve").value) +"&type=" + encodeURI(document.getElementById("type").value) +"&a=" + encodeURI(document.getElementById("a").value) +"&b=" + encodeURI(document.getElementById("b").value) +"&c=" + encodeURI(document.getElementById("c").value) +"&d=" + encodeURI(document.getElementById("d").value) +"&e=" + encodeURI(document.getElementById("e").value)  + reponse + "&commentaire=" + encodeURI(document.getElementById("commentaire").value) + "&enonce=" + encodeURI(document.getElementById("enonce").value) + "&nom_session=" +encodeURI(mon_cookie);
        ajaxpack.postAjaxRequest("/QCM/" + fonction ,poststr,com_new,"txt");
    }


}

function autre(chose){

    if (chose == 'pays'){
        pays0 = document.getElementById("pays0").value;

        if (pays0 == "Autre"){
            document.getElementById("pays").className = "letexte";
            document.getElementById("ville").className = "letexte";
            document.getElementById("ville0").value = "Autre";
        }
        else{
            document.getElementById("pays").className = "invisible";
            var poststr =  "&pays=" + encodeURI(pays0)+"&autre=yes";

            ajaxpack.postAjaxRequest("/QCM/villes" ,poststr,com_villes,"txt");
        }
    }
    else{
        ville0 = document.getElementById("ville0").value;
        if (ville0 == "Autre"){
            document.getElementById("ville").className = "letexte";
        }
        else{
            document.getElementById("ville").className = "invisible";
        }
    }
}

function autre_see(chose){

    if (chose == 'pays'){
        pays0 = document.getElementById("pays0").value;

        if (pays0 == "Autre"){

            document.getElementById("ville0").value = "Autre";
        }
        else{

            var poststr =  "&pays=" + encodeURI(pays0)+"&autre=no";

            ajaxpack.postAjaxRequest("/QCM/villes" ,poststr,com_villes,"txt");
        }
    }
    else{
        ville0 = document.getElementById("ville0").value;
        if (ville0 == "Autre"){

        }
        else{

        }
    }
}

function select(){
    type = document.getElementById("type").value;
    if (type == "CCQ"){
        if (last == "QCM"){
            ka = window.confirm("Voulez vous commencer un nouveau CCQ?");
            if (ka == true){
                if (No == 0){No_CCQ += 1; No_CCQ_user +=1;}
                window.alert("Vous devez donner comme premiÃ¨re question une question sans propositions, elle aura le numÃ©ro 0. Si la premiÃ¨re question de votre cas clinique contient des propositions, essayez de la diviser en 2 questions (l'une contenant la plus grande partie de l'Ã©noncÃ©(NÂ°0) et l'autre le reste de l'Ã©noncÃ© et les propositions(NÂ°1))");
                document.getElementById("numero_ccq").value = No_CCQ;
                document.getElementById("numero_ccq").className = "letexte";
                document.getElementById("new_cc").className = "letexte";
                document.getElementById("numero").value = 0;
                last = "CCQ";
            }
            else{document.getElementById("type").value = "QCM";}
        }
        else{

            document.getElementById("numero").value = No;
        }
    }
    else{
        if (last == "CCQ"){
            if (No == 1){window.alert("Vous avez dÃ©jÃ  ajoutÃ© l'Ã©noncÃ© d'un CCQ, vous risquez d'Ãªtre puni si vous vous arrÃªtez lÃ. Veuillez ajouter d'autres QCMs ");}
            kb = window.confirm("Voulez vous terminer le CCQ qui contient " + No + " questions?");

            if (kb == true){
                last = "QCM";
                if (No == 0){No_CCQ -= 1; No_CCQ_user -=1} 

                No = 0;
                document.getElementById("numero_ccq").className = "invisible";
                document.getElementById("new_cc").className = "invisible";
                document.getElementById("numero").value = No_QCM;
            }
            else{document.getElementById("type").value = "CCQ";}
        }
    }
}
function new_ccq(){
        kc = window.confirm("Voulez vous vraiment commencer un nouveau CCQ ?");

            if (kc == true){
                window.alert("Vous devez donner comme premiÃ¨re question une question sans propositions, elle aura le numÃ©ro 0. Si la premiÃ¨re question de votre cas clinique contient des propositions, essayez de la diviser en 2 questions (l'une contenant la plus grande partie de l'Ã©noncÃ©(NÂ°0) et l'autre le reste de l'Ã©noncÃ© et les propositions(NÂ°1))");
                if (No > 1){
                    last = "CCQ";
                    No_CCQ += 1;
                    No_CCQ_user += 1;
                    document.getElementById("numero_ccq").value = No_CCQ;
                    No = 0;
                    document.getElementById("numero").value = No;
                    }
            }
    }

function new_sujet(){
        kd = window.confirm("Voulez vous vraiment commencer un nouveau sujet, tous les numÃ©ros vont Ãªtre remis a 0?");

            if (kd == true){
                if (No > 1){
                    last = "QCM";
                    No_CCQ = 0;

                    No_QCM = 1;
                    document.getElementById("numero_ccq").value = No_CCQ;
                    document.getElementById("numero_ccq").className = "invisible";
                    document.getElementById("new_cc").className = "invisible";
                    No = 0;
                    document.getElementById("numero").value = No_QCM;
                    document.getElementById("type").value = "QCM";
                    }
            }
    }

function verifier(fonction){
    if (fonction == "save_modif"){
            a = document.getElementById("a").value;
            numero = document.getElementById("numero").value;
            enonce = document.getElementById("enonce").value;
            if (enonce!=""){
                    if (a == ""){
                        if (numero + 0 != 0){
                            window.alert("Vous devez taper les propositions dans les champs a,b,c,d, et e ");
                            }
                        else{send(fonction);
                        }
                        }
                    else{
                            send(fonction);
                            }
                }
        else{window.alert("vous devez taper l'Ã©noncÃ© de la question");}

        }
    else if (fonction == "save_modif_new"){
            a = document.getElementById("a").value;
            numero = document.getElementById("numero").value;
            enonce = document.getElementById("enonce").value;
            if (enonce!=""){
                    if (a == ""){
                        if (numero + 0 != 0){
                            window.alert("Vous devez taper les propositions dans les champs a,b,c,d, et e ");
                            }
                        else{send(fonction);
                        }
                        }
                    else{
                            send(fonction);
                            }
                }
        else{window.alert("vous devez taper l'Ã©noncÃ© de la question");}

        }
    else {
        a = document.getElementById("a").value;
        b = document.getElementById("b").value;
        numero = document.getElementById("numero").value;
        enonce = document.getElementById("enonce").value;
        annee = document.getElementById("annee").value;
        type = document.getElementById("type").value;
        if (enonce!=""){
            if (annee != ""){
                if (parseInt(annee)){
                    if (parseInt(annee) > 1970){
                        if (parseInt(annee)< 2020){
                            if (a != ""){
                                if (numero + 0 == 0){
                                    window.alert("Vous devez taper un numÃ©ro autre que 0 (QCM). Si c'est la premiÃ¨re question d'un CCQ, elle ne doit pas contenir de propositions.");
                                    }
                                else{send(fonction);
                                }
                                }
                            else{
                                if (numero + 0 != 0){
                                    window.alert("Vous devez taper 0 dans numÃ©ro (CCQ) ou taper les propositions dans les champs a,b,c,d, et e (QCM)");
                                    }
                                else if (type == "QCM"){
                                    window.alert("vous devez choisir CCQ dans Type et 0 dans numÃ©ro pour commencer un cas clinique");
                                    }
                                else{

                                    send(fonction);
                                    }
                                }
                            }
                            else{window.alert("Veuillez taper une annÃ©e correcte");}
                        }
                        else{window.alert("Veuillez taper une annÃ©e correcte");}
                    }
                else{window.alert("Veuillez taper une annÃ©e correcte");}
                }
                else{window.alert("Veuillez taper une annÃ©e correcte");}
            }
        else{window.alert("vous devez taper l'Ã©noncÃ© de la question");}
        }
    }

function disp_mod(id){
    z = liste_mod.length;

    ka = 0;
    navigateur = navigator.userAgent ;
    //~ window.alert(id);
    if (document.getElementById(id).style.display != "block"){

        while (ka < z){document.getElementById(liste_mod[ka]).style.display='none';ka+=1;if (navigateur.search("MSIE 6.0") != -1){document.getElementById("cache2").style.display = 'none';}}
        le_top = 140;
        le_left = 60;

        document.getElementById(id).style.top=le_top ;
        document.getElementById(id).style.left=le_left ;
        document.getElementById(id).style.visibility = 'hidden' ;
        document.getElementById(id).style.display = "block";
        if (navigateur.search("MSIE 6.0") != -1){

            document.getElementById("cache2").style.top = le_top;
            document.getElementById("cache2").style.left = le_left;
            document.getElementById("cache2").style.width = document.getElementById(id).clientWidth;
            document.getElementById("cache2").style.height = document.getElementById(id).clientHeight;
            document.getElementById("cache2").style.display = 'block';
            

        };
        document.getElementById(id).style.visibility = 'visible' ;
    }
    else{document.getElementById(id).style.display='none';if (navigateur.search("MSIE 6.0") != -1){document.getElementById("cache2").style.display = 'none';}}
}

function load_page(page){

    mon_cookie = document.getElementById("nom_session").value;
    var poststr = "nom_session=" + encodeURI(mon_cookie);
    ajaxpack.getAjaxRequest(page ,poststr,com_page,"txt");
}

function cacher(id){
    document.getElementById(id).style.display='none';
    if (navigateur.search("MSIE 6.0") != -1){
        document.getElementById("cache").style.display = 'none';
    }
}

function load_pub(){
    mon_cookie = document.getElementById("nom_session").value;
    var poststr =  "&nom_session=" + encodeURI(mon_cookie)
    ajaxpack.postAjaxRequest("/QCM/pub",poststr,com_pub,"txt");
    setTimeout('load_pub()', 90000);
};


function com_pub(){
var myajax=ajaxpack.ajaxobj;
var myfiletype=ajaxpack.filetype;
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")==-1){
	if (myfiletype=="txt"){
		document.getElementById("Pub").innerHTML = myajax.responseText;
                txt =  myajax.responseText;
}
	else {
		document.getElementById("Pub").innerHTML = myajax.responseXML;
                txt =  myajax.responseXML;
}

}
}
}

function com_page(){
var myajax=ajaxpack.ajaxobj;
var myfiletype=ajaxpack.filetype;
if (myajax.readyState == 4){
if (myajax.status==200 || window.location.href.indexOf("http")==-1){
    navigateur = navigator.userAgent ;
    if (navigateur.search("MSIE") == -1){
        window_height = window.innerHeight;
        window_width = window.innerWidth;
        scroll_top = window.pageYOffset;
        scroll_left = window.pageXOffset;
    }
    else{
        window_height = document.body.clientHeight;
        window_width = document.body.clientWidth;
        //~ scroll_top = document.documentElement.scrollTop;
        //~ scroll_left = document.documentElement.scrollLeft;        
        scroll_top = document.body.scrollTop;
        scroll_left = document.body.scrollLeft;
    }
    largeur = (window_width / 2) + scroll_left;
    if (largeur < 400){largeur = 400};    
    hauteur =  (window_height / 2) + scroll_top;

    
	if (myfiletype=="txt"){
                document.getElementById("pages").innerHTML = myajax.responseText;  
                document.getElementById("pages").style.visibility='hidden';                
                document.getElementById("pages").style.display='block';                
                d_h = document.getElementById("pages").clientHeight;
                d_w = document.getElementById("pages").scrollWidth;    
       
                _top = (hauteur-(d_h/ 2));
                _left = (largeur -(d_w/ 2));                   
   
                if (navigateur.search("MSIE 6.0") != -1){
                    document.getElementById("pages").className = "page3";
                    document.getElementById("cache").style.top =_top;
                    document.getElementById("cache").style.left =_left   
                    document.getElementById("cache").style.width=d_w;
                    document.getElementById("cache").style.height=d_h;    
                    document.getElementById("cache").style.display='block';   
                }
                document.getElementById("pages").style.top=_top;
                document.getElementById("pages").style.left=_left;   

                document.getElementById("pages").style.visibility='visible';
                if (navigateur.search("MSIE 6.0") == -1){Nifty("div#pages");};
}
	else {
		document.getElementById("pages").innerHTML = myajax.responseXML;
                document.getElementById("pages").style.display='block';
}

}
}
}

function check_dispo(page){

    annee = document.getElementById("annee").value;

    if (parseInt(annee) > 1970){
        numero = document.getElementById("numero").value;
        pays0 = document.getElementById("pays0").value;
        ville0 = document.getElementById("ville0").value;
        if (pays0 != "Autre"){pays = pays0}else{pays = document.getElementById("pays").value;}
        if (ville0 != "Autre"){ville = ville0}else{ville = document.getElementById("ville").value;}
        type_epreuve = document.getElementById("type_epreuve").value;
        var poststr = "numero=" + encodeURI(numero) + "&pays=" + encodeURI(pays) + "&ville=" + encodeURI(ville) + "&annee=" + encodeURI(annee) + "&type_epreuve=" + encodeURI(type_epreuve);

        ajaxpack.getAjaxRequest(page ,poststr,com_page,"txt");
    }
    else{
        window.alert("Donnez une annÃ©e correcte s'il vous plait");
    }
}


/*
fichier ajax.js
*/

function createAjaxObj(){
var httprequest=false;
if (window.XMLHttpRequest){
httprequest=new XMLHttpRequest();
if (httprequest.overrideMimeType){httprequest.overrideMimeType('text/xml');};
}
else if (window.ActiveXObject){
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){};
};
};
return httprequest;
};

var ajaxpack=new Object();
ajaxpack.basedomain="http://"+window.location.hostname;
ajaxpack.ajaxobj=createAjaxObj();
ajaxpack.filetype="txt";
ajaxpack.addrandomnumber=0 ;

ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpack.ajaxobj=createAjaxObj() ;
if (ajaxpack.addrandomnumber==1){var parameters=parameters+"&ajaxcachebust="+new Date().getTime();};
if (this.ajaxobj){
this.filetype=filetype;
this.ajaxobj.onreadystatechange=callbackfunc;
this.ajaxobj.open('GET', url+"?"+parameters, true);
this.ajaxobj.send(null);
};
};
ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
ajaxpack.ajaxobj=createAjaxObj();
if (this.ajaxobj){
this.filetype=filetype;
this.ajaxobj.onreadystatechange = callbackfunc;
this.ajaxobj.open('POST', url, true);
this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
this.ajaxobj.setRequestHeader("Content-length", parameters.length);
this.ajaxobj.setRequestHeader("Connection", "close");
this.ajaxobj.send(parameters);
};
};

/*
fichier menu_tree.js
*/

img_parent = "";
img_parent_ancien = "";
img_enfant = "";
img_enfant_ancien = "";
_menu = "m_020";
s_menu = "m_020";
function disp_t(id1,id2){
    valeur = document.getElementById(id2).style.display;
    if (valeur=="block"){
        document.getElementById(id2).style.display="none";
        document.getElementById(id1).src = "/images/plus.ico";
    }
    else{
        document.getElementById(id2).style.display="block";
        document.getElementById(id1).src = "/images/minus.ico";
    };
};

function fenetre_fixe(source,contenu){
    valeur = document.getElementById(contenu).style.display;

    window_height = document.body.offsetHeight;
    window_width = document.body.offsetWidth;
    largeur = (window_width / 2);
    if (largeur < 400){largeur = 400};    
    hauteur =  (window_height / 2);
    

    menu_parent = _menu;
    menu_enfant = s_menu;
    document.getElementById(menu_enfant).style.display = "none";
    document.getElementById(menu_parent).style.display = "none";

    window_top = (window_height / 4);
    window_left = (window_width / 4);    
    if ((window_left + largeur) > window_width){ le_left = (window_width - 30) - largeur;}else{le_left = window_left};
    if ((window_top + hauteur) > window_height){ le_top = window_top - 50 - hauteur;}else{ le_top = window_top};

    if (le_top < 100){le_top = 100};

    if (valeur=="block"){
        document.getElementById(contenu).style.display="none";
        document.getElementById(source).src = "/images/plus.ico";
    }
    else{
        document.getElementById(contenu).style.top=le_top ;
        document.getElementById(contenu).style.left=le_left ;
        document.getElementById(contenu).style.width= largeur;
        document.getElementById(contenu).style.display="block";
        document.getElementById(source).src = "/images/minus.ico";
    };
};
function disp_info(id1,id2){
    valeur = document.getElementById(id2).style.display;
    window_height = document.body.offsetHeight;
    window_width = document.body.offsetWidth;
    largeur = (window_width / 3);
    if (largeur < 310){largeur = 310};    
    hauteur =  (window_height / 5);
    

    menu_parent = _menu;
    menu_enfant = s_menu;
    document.getElementById(menu_enfant).style.display = "none";
    document.getElementById(menu_parent).style.display = "none";

    

    window_top = (document.getElementById(id1).offsetHeight) + (document.getElementById(id1).offsetTop);
    window_left = (document.getElementById(id1).offsetLeft) + (document.getElementById(id1).offsetWidth);    
    if ((window_left + largeur) > window_width){ le_left = (window_width - 30) - largeur;}else{le_left = window_left};
    if ((window_top + hauteur) > window_height){ le_top = window_top - 50 - hauteur;}else{ le_top = window_top};

    if (valeur=="block"){
        document.getElementById(id2).style.display="none";
        document.getElementById(id1).src = "/images/plus.ico";
    }
    else{
        document.getElementById(id2).style.top=le_top ;
        document.getElementById(id2).style.left=le_left ;
        document.getElementById(id2).style.width= largeur;
        document.getElementById(id2).style.display="block";
        document.getElementById(id1).src = "/images/minus.ico";
    };
};
function menu(ident,ident2){
    //~ window.alert(document.body.clientHeight);
    //~ window.alert(document.body.clientWidth);
    //~ window.alert(window.innerHeight);
    img_parent = ident + "img";

    menu_top = (document.getElementById(ident).offsetHeight) + (document.getElementById(ident).offsetTop) + (document.getElementById("t_menu").offsetTop);
    menu_left = (document.getElementById(ident).offsetLeft) + (document.getElementById("t_menu").offsetLeft);    


    if (_menu != ""){
        menu_parent = _menu;
        menu_enfant = s_menu;
        if (menu_parent != ident2){document.getElementById(menu_enfant).style.display = "none";
        document.getElementById(menu_parent).style.display = "none";
        if (img_parent_ancien != ""){document.getElementById(img_parent_ancien).src="/images/down_red.ico"};
        if(img_enfant_ancien != ""){document.getElementById(img_enfant_ancien).src="/images/right_red.ico"};
        };
    };

    document.getElementById(ident2).style.top = menu_top;
    document.getElementById(ident2).style.left = menu_left;
    if (document.getElementById(ident2).style.display=="block"){document.getElementById(ident2).style.display="none";document.getElementById(menu_enfant).style.display = "none";document.getElementById(img_parent).src="/images/down_red.ico";document.getElementById(img_enfant_ancien).src="/images/right_red.ico"}
    else{document.getElementById(ident2).style.display="block";document.getElementById(img_parent).src="/images/up_red.ico"};
    _menu = ident2;
    img_parent_ancien = img_parent;
};
function ss_menu(ident,ident2){
    img_enfant = ident + "img";
    longueur = ident.length;
    le_parent = ident.substr(0,longueur-1);
    menu_top =  (document.getElementById(ident).offsetTop) + (document.getElementById("t_menu").offsetTop) + (document.getElementById("t_menu").offsetHeight);
    menu_left = (document.getElementById(ident).offsetWidth) + (document.getElementById(ident).offsetLeft)+ ( (document.getElementById(le_parent).offsetLeft)); 
    if (s_menu != ""){
        menu_enfant = s_menu;
        if (menu_enfant != ident2){document.getElementById(menu_enfant).style.display = "none";
        if(img_enfant_ancien != ""){document.getElementById(img_enfant_ancien).src="/images/right_red.ico"};
        };
    };
    document.getElementById(ident2).style.top = menu_top;
    document.getElementById(ident2).style.left = menu_left;
    if (document.getElementById(ident2).style.display=="block"){document.getElementById(ident2).style.display="none";document.getElementById(img_enfant).src="/images/right_red.ico"}
    else{document.getElementById(ident2).style.display="block";document.getElementById(img_enfant).src="/images/left_red.ico"};
    s_menu = ident2
    img_enfant_ancien = img_enfant;
};
function efface_menu(){
    menu_parent = _menu;
    menu_enfant = s_menu;
    document.getElementById(menu_enfant).style.display = "none";
    document.getElementById(menu_parent).style.display = "none";
    if (img_parent_ancien != ""){document.getElementById(img_parent_ancien).src="/images/down_red.ico"};
    if(img_enfant_ancien != ""){document.getElementById(img_enfant_ancien).src="/images/right_red.ico"};
};
function clr_btn(id1){
    document.getElementById(id1).style.color = "red";
};
function unclr_btn(id1){
    document.getElementById(id1).style.color = "#000000";
};
function disp(){
    document.getElementById("e1").style.display="block";
    };
function disp_n(){
    document.getElementById("e1").style.display="none";
    };

/*
fichier niftycube.js
*/

/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
if(typeof(oldonload)=='function')
    window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","/styles/niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}
