//******************** COMMANDES ******************************
var path	= "images/";
var recap	= "page2.htm";
var fen_src = "fen_choix.htm";
var datas	= new Array("heros", "depart", "arrivee", "motifs", "epreuves", 
						"signe", "persben", "persmal", "objmag", "morale");						

var Conte 	= new ConteDeFee();

function ConteDeFee() {
this.heros		= getCookie('heros')	?getCookie('heros')		:-1;
this.depart		= getCookie('depart')	?getCookie('depart')	:-1;
this.arrivee	= getCookie('arrivee')	?getCookie('arrivee')	:-1;
this.motifs		= getCookie('motifs')	?getCookie('motifs')	:-1;
this.epreuve1	= getCookie('epreuve1')	?getCookie('epreuve1')	:-1;
this.epreuve2	= getCookie('epreuve2')	?getCookie('epreuve2')	:-1;
this.epreuve3	= getCookie('epreuve3')	?getCookie('epreuve3')	:-1;
this.signe		= getCookie('signe')	?getCookie('signe')		:-1;
this.persben	= getCookie('persben')	?getCookie('persben')	:-1;
this.persmal	= getCookie('persmal')	?getCookie('persmal')	:-1;
this.objmag		= getCookie('objmag')	?getCookie('objmag')	:-1;
this.recomp		= getCookie('recomp')	?getCookie('recomp')	:-1;
this.morale		= getCookie('morale')	?getCookie('morale')	:-1;

this.elements	= new Array("heros", "depart", "arrivee", "motifs", "epreuve1", "epreuve2", "epreuve3", 
						"signe", "persben", "persmal", "objmag", "morale");
		
this.complet	= 0;
this.Selection 	= function (choix) {
					if (this.heros < 0) { fen(fen_src+'?msg=0'); return; }
					Enregistre(choix, "-1");
					fen(fen_src+"?choix="+choix);
				   }
}

function Enregistre(ch, val) {
eval("Conte."+ch+"="+val);
	if (getCookie(ch)) deleteCookie(ch);
setCookie(ch,val);
}

function box_off(nm_img) {
document.images[nm_img].src=path+'box_off.gif';
}

function box_on(nm_img) {
document.images[nm_img].src=path+'box_on.gif';
}

function getValue(ch) {
return eval("Conte."+ch);
}

function checkValeurs() {
var notfound = null;
var s = document.forms[0].select1;
var tmp = Conte.elements;

	if (s.options[s.selectedIndex].value != "#") Enregistre('heros',s.options[s.selectedIndex].value); //fixe le bug de reload
	else Enregistre('heros', '-1');
			
	for (i=0; i<= tmp.length-1; i++) { 
	var obj = eval("Conte."+tmp[i]);
	var imgname="";
		if (new String(tmp[i]).indexOf('epreuve')>=0) imgname="epreuves";
		else imgname=tmp[i]; 

		if (obj >= 0) {
		box_on(imgname);
		}
		else { 
			if (tmp[i] != "epreuve3") { notfound	= 1; box_off(imgname); }
		}
	}
	if (notfound == 1) Conte.complet = 0;
	else Conte.complet = 1;
}

function fen(source) {
window.open(source, "Lais", "width=467, height=249, toolbar=no, status=no, location=no, menubar=no,scrollbars=no,resizable=no, navigationbar=no" );
}
