<!--
function hide(n) {
document.getElementById(n).style.display = 'none';
}

function show(m) {
document.getElementById(m).style.display = '';
}
//-->

<!--
function switch_spoiler(div2)
{
var divs = div2.getElementsByTagName('div');
var div3 = divs[0];
	if (div3.style.visibility == 'visible')
	div3.style.visibility = 'hidden';
	else
	div3.style.visibility = 'visible';
return true;
}
//-->


function file(fichier,fct){//ajax function
var loginRequest = null; 
if (window.XMLHttpRequest)
{
loginRequest = new XMLHttpRequest();
if (loginRequest.overrideMimeType) 
{
loginRequest.overrideMimeType('text/xml');
}
} 
else if (window.ActiveXObject) 
{
try {
		loginRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e)	{
			try {
				loginRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
 }

loginRequest.onreadystatechange = function()
{
if(loginRequest.readyState == 4)
{
if(loginRequest.status==200)
{
if(fct==1)
{
reception1(loginRequest.responseText);
}
else if(fct==9)
{
notereception(loginRequest.responseText);
}
else if(fct=='illusion')
{
illusion_hasard_raffraichir_reception(loginRequest.responseText);
}
else if(fct=='image')
{
image_hasard_raffraichir_reception(loginRequest.responseText);
}
else if(fct=='char')
{
char_hasard_raffraichir_reception(loginRequest.responseText);
}
else if(fct=='image2')
{
receptionimage(loginRequest.responseText);
}
else if(fct=='critique_hasard')
{
critique_hasard_actu_reception(loginRequest.responseText);
}
else if(fct=='messagerie')
{
messageriereception(loginRequest.responseText);
}
else
{

}
}
else
{
return false;
}
}
else
{
return false;
}
}

loginRequest.open("GET", fichier, true); 
loginRequest.send(null); 
}

var id2 = new Array();
var id3;
var id4;

function star_over(score,id) {
	id3 = id;
	
	id2[0] = document.images['star1' + id].src;
	id2[1] = document.images['star2' + id].src;
	id2[2] = document.images['star3' + id].src;
	id2[3] = document.images['star4' + id].src;
	id2[4] = document.images['star5' + id].src;

    fill_stars(score,id);
}

function star_out(score,id) {
	document.images['star1' + id3].src = id2[0];
	document.images['star2' + id3].src = id2[1];
	document.images['star3' + id3].src = id2[2];
	document.images['star4' + id3].src = id2[3];
	document.images['star5' + id3].src = id2[4];
}

function fill_stars(score,id) {
    if ('undefined' == typeof(document.images))
        return;

    var delta = 5 / (5 * 2 + 1);
    var pos = 0;
    for (var i = 1; i <= 5; i++) {
        var src = "etoile-vide.gif";
        pos += delta;
        if (score > pos)
            src = "etoile-moitier.gif";
        pos += delta;
        if (score > pos)
            src = "etoile-pleine.gif";
        document.images['star' + i + id].src = src;
    }
}

function notereception(ajax) {
if(ajax==1)
{
document.getElementById("message"+id4).innerHTML="Note enregistré!";
}
else
{
document.getElementById("message"+id4).innerHTML="Vous avez déjà voter!";
}
}

function illusion_hasard_raffraichir(){
	file('illusion-raffraichir=id='+Math.random()+'.html','illusion');
}

function messageriereception(ajax){
show("recherche");
if(ajax==0)
{
hide("recherche");
}
else
{
document.getElementById("membre_messagerie").innerHTML=ajax;
}
}

function illusion_hasard_raffraichir_reception(ajax){
document.getElementById("illusion_hasard_raffraichir_block").innerHTML=ajax;
}

function image_hasard_raffraichir(){
	file('image-raffraichir=id='+Math.random()+'.html','image');
}

function image_hasard_raffraichir_reception(ajax){
document.getElementById("image_hasard_raffraichir_block").innerHTML=ajax;
}

function char_hasard_raffraichir(){
	file('char-raffraichir=id='+Math.random()+'.html','char');
}

function char_hasard_raffraichir_reception(ajax){
document.getElementById("char_hasard_raffraichir_block").innerHTML=ajax;
}

function critique_hasard_actu(){
	file('critique-raffraichir=id='+Math.random()+'.html','critique_hasard');
}

function critique_hasard_actu_reception(ajax){
document.getElementById("critique_hasard").innerHTML=ajax;
}


//correteur
isIE=0;
if((navigator.appName.indexOf("Internet Explorer") != -1) && 
(parseInt(navigator.appVersion) >= 4)) isIE=1;

function on_key_press(key_press)
{
  if(is_ok){
    var kC;
    var cK;
    var kM;
    if(window.event){kC=window.
	event.keyCode;cK=window.event.ctrlKey;kM=2;}
    else
      if(parent&&parent.event){kC=parent.event.keyCode;cK=parent.event.ctrlKey;kM=2;}
      else{kC=key_press.keyCode;cK=key_press.ctrlKey;
        if(key_press.modifiers!=undefined){kM=key_press.modifiers;cK=2;kC=key_press.which;}
        else kM=2;
      }
    if(cK&&kM==2&&(kC==13||kC==10))send_error();
  }
}


function send_error(){
	if(isIE==1){
		gettmvv=document.selection.createRange().text;
	}else if(document.getSelection){
		gettmvv=document.getSelection();
	}
if (gettmvv!=''){
		document.url_text = document.location;
		document.error_text = gettmvv;		
		ErrWin = window.open("correcteur.php","","alwaysRaised=yes,height=500,width=700,menubar=no,toolbar=no,resizable=yes,status=no,scrollbars=yes");
 }
}

if(parent)parent.document.onkeypress=on_key_press;
document.onkeypress=on_key_press;
is_ok=true;
