var Merlin;
var bAgentActif=false;


function padout(number) { return (number < 10) ? '0' + number : number; }


function ActiveDesactiveAgent() {
	if (bAgentActif==true) {
		Merlin.Hide();
		document.FormValue.agent.src="ressources/activerAgent.jpg";
		document.FormValue.borderProgres.src="ressources/blankProgres.gif";
		document.FormValue.agent.width=199;
		document.FormValue.agent.height=18;
		bAgentActif=false;
		
	} else {
		if (confirm("Attention, l'assistant peut avoir besoin d'installer des librairies; dans ce cas leur installation peut prendre plusieurs minutes...\r\nÊtes-vous sûr de vouloir continuer?")) {
			document.FormValue.agent.width=1;
			document.FormValue.agent.height=18;
			document.FormValue.borderProgres.src="ressources/borderProgres.gif";
			document.FormValue.agent.src='ressources/progres.gif';
			window.parent.agent.location="agent.html";
			window.parent.agent.Step1();
		}
	}
	
}

function startMerlin() {
	window.parent.agent.AgentControl.Connected = true;
	window.parent.agent.AgentControl.Characters.Load("Merlin", "http://agent.microsoft.com//agent2//chars//merlin//merlin.acf");
	Merlin = window.parent.agent.AgentControl.Characters.Character("Merlin");
	Merlin.LanguageID = 0x040C;	//  needed under come conditions, 409 pour l'anglais
	Merlin.Get("state", "Showing, Speaking");
	Merlin.Get("animation", "Greet, GreetReturn, Alert,Write,WriteReturn ,Read,ReadReturn,Congratulate,Congratulate_2");
	Merlin.Show();
	document.FormValue.agent.width=200;
	document.FormValue.agent.height=18;
	
	document.FormValue.blankProgres.width=0;
	document.FormValue.blankProgres.height=18;
	
	setTimeout("document.FormValue.agent.src='ressources/desactiverAgent.jpg';",500);
	setTimeout("document.FormValue.borderProgres.src='ressources/blankProgres.gif';",500);
	setTimeout("document.FormValue.agent.width=230;",500);
	setTimeout("document.FormValue.agent.height=18;",500);
	
	
	Merlin.Get("state", "Hiding");
	Merlin.Play("Greet");
	now = new Date();
	if (padout(now.getHours())>4 && padout(now.getHours())<19) {
		Merlin.Speak("Bonjour!");
	} else {
		Merlin.Speak("Bonsoir!");
	}
	
	Merlin.Play("GreetReturn");
	//Merlin.Speak("Ce site est encore en construction mais il va évoluer très rapidement...");
	//Merlin.Speak("Vous pourrez à tout moment me demander de l'aide sur une fonctionnalité du site, en cliquant sur le point d'interrogation.");
	Merlin.Speak("Je suis votre assistant et je vais vous guider sur le site.")
	bAgentActif=true
	//Merlin.Hide()
}
	
function afficheAlerte(s,al) {
	if (bAgentActif==true) {
		Merlin.Play("Alert");
		Merlin.Speak(s);
	} else {
		if(al==1) {
			alert(s);
		}
	}
}

function afficheMessage(s,al) {
	if (bAgentActif==true) {
		Merlin.Speak(s);
	} else {
		if(al==1) {
			alert(s);
		}
	}
}

function animeAgent(s) {
	if (bAgentActif) {
		Merlin.Play(s);
	}
}