function episode(id){
	location.href="index.php?act=chapitre&idepisode="+id;
}

dojo.addOnLoad(
    	
    	function(){
		dojo.require("dojo.cookie");
		dojo.require("dijit.Tooltip");
		dojo.require("dojo.parser");

		dojo.addOnLoad(
			function(){

				// chargement sondage
				dojo.xhrGet( { // ?
					url: "index.php?act=sondage&ck=" + dojo.cookie("mdlcPoll"), 
					handleAs: "text",
					load: function(response, ioArgs) { 
						dojo.byId('sondage').innerHTML = response;
					}
				});
			}
		);
	}
)

function voter(){
	var kw = {
		url:"index.php?act=voter&ck=" + dojo.cookie("mdlcPoll"),
		form: document.getElementById("MyFormPoll"),
		load:function( data, evt) { 
			t = data.split("|");
			dojo.byId('sondage').innerHTML = t[1];
			dojo.cookie("mdlcPoll", t[0], {expires: 30});
		}
	}
	dojo.xhrPost(kw);

}

function showDiv(m){
	document.getElementById("menu_homme").style.display="none";
	document.getElementById("menu_femme").style.display="none";
	document.getElementById("menu_"+m).style.display="block";

}

function validate_newsletter(){

	if(document.getElementById("nom").value == ''){alert("Veuillez indquer votre nom ");return false;}
	if(!document.getElementById("sexe1").checked &&  !document.getElementById("sexe2").checked){alert("Veuillez indquer votre sexe ");return false;}
	if(document.getElementById("age").value == ''){alert("Veuillez indquer votre age ");return false;}
	if(document.getElementById("email").value == ''){alert("Veuillez indquer votre adresse email ");return false;}
	
	if (!ValidEmail(document.getElementById("email").value)){
		alert('Adresse email incorrecte');
		return false;
	}

}

// Rejects: empty strings or strings full of blanks,
//          strings without @ or without . (dot)
// Rejects: A@, @B, A@B, .A@B, A@B., A@.B
// Accepts: A@B.C, A.B@C.D

function ValidEmail(s) {
var Count;
var s2;
// empty or blank email
if (EmptyString(s) == true) return (false);
// email without @
if (s.indexOf('@') == -1) return (false);
// email with @ as the 1st char
if (s.indexOf('@') == 0) return (false);
// email with @ as the last char
if ((s.indexOf('@')+1) == s.length) return (false);
// email without .
if (s.indexOf('.') == -1) return (false);
// email with . as the 1st char
if (s.indexOf('.') == 0) return (false);
// email with . as the last char
if ((s.indexOf('.')+1) == s.length) return (false);

// Now look for the first . after the first @
// s2 = string after the first @
s2=s.substring(s.indexOf('@')+1,s.length);
// email without a dot after the first @
if (s2.indexOf('.') == -1) return (false);
// email dot right after the first @
if (s2.indexOf('.') == 0) return (false);
return (true);
}

function EmptyString(s) {
var Count;
var Nblank = 0;
if (s.length == 0) return (true); // empty string
// count the number of blank chars
for (Count = 0; Count < s.length; Count++) {
if (s.charAt(Count) == " ") Nblank++;
}
if (Nblank == s.length)
return (true);
else
return (false);
}


