// JavaScript Document

// Boucle de validation Newsletter
function validateForm(form) {
		if (isNotEmpty(form.email)) {
                if (isEMailAddr(form.email)) {
							return true;
				}
		}
	return false;
}

// Vérifie si un champ a bien été renseigné
function isNotEmpty(elem) {
	var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        alert("Veuillez indiquer une adresse e-mail.");
        setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}

// Vérifie si l'adresse e-mail est valide
function isEMailAddr(elem) {
	var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("Ce format d'e-mail n'est pas correct. Veuillez corriger votre adresse.");
        setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return false;
    } else {
        return true;
    }
}


// Positionne le curseur dans un champ donné
function focusElement(formName, elemName) {
    var elem = document.forms[formName].elements[elemName];
    elem.focus();
    elem.select();
}


// switch content
function toggleNext(el,tname,first) {
 var abscn="abs";
 var selcn="selected";
 var next=el.nextSibling;
 var tags=el.parentNode.getElementsByTagName(tname);
 while(next.nodeType!=1) next=next.nextSibling;
 next.style.display=((next.style.display=="none") ? "block" : "none");
 var rE = new RegExp("(^|\\s)"+abscn+"(\\s|$)");
 if (rE.test(next.className)==false) {next.className+=" "+abscn;}
 if (first!=1){
  for (i=0; i<tags.length; i++) {
   var tohide=tags[i].nextSibling;
   while(tohide.nodeType!= 1) tohide=tohide.nextSibling;
   if (tohide!=next){tohide.style.display="none";}
   tags[i].className=tags[i].className.replace(new RegExp(selcn+"\\b"), "");
   if (tags[i]==el && next.style.display=="block"){
    var rEx=new RegExp("(^|\\s)"+selcn+"(\\s|$)");
    if (rEx.test(tags[i].className)==false) {tags[i].className+=" "+selcn;}
   }
  }
 }
}



// Gestion des "posters" sur iPhone
function playmovie(posterURL, movieURL, width, height, showcontroller) {
                var ua = navigator.userAgent;
                if ((ua.indexOf("iPhone") > 0) ||(ua.indexOf("iPod") > 0) || (ua.indexOf("iPad") > 0)) {
                        posterimageHTML = "<img src='" + posterURL + "' onclick='document.location=\"" + movieURL + "\"' width='" + width + "' height='" + height +"'>";
                        document.write(posterimageHTML);
                } else {
					document.write("<p>You need <a href='http://get.adobe.com/fr/flashplayer/' target='_blank'>Adobe Flash Player</a> or an iPhone / iPod / iPad to see this content.</p>");
                     //    if (showcontroller == "true") {
                     //          	QT_WriteOBJECT(movieURL, width, height  + 16, '',' controller', 'true','autoplay', 'false');
                      //   } else {
                      //           QT_WriteOBJECT(movieURL, width, height, '',' controller', 'false','autoplay', 'false');
                      //  }
                }
        }
		
		
function playmoviePlaylist(posterURL, movieURL, width, showcontroller) {
                var ua = navigator.userAgent;
                if ((ua.indexOf("iPhone") > 0) ||(ua.indexOf("iPod") > 0) || (ua.indexOf("iPad") > 0)) {
                        posterimageHTML = "<img src='" + posterURL + "' onclick='document.location=\"" + movieURL + "\"' width='" + width*0.5+ "' >";
                        document.write(posterimageHTML);
                } else {
						document.write("<p>You need <a href='http://get.adobe.com/fr/flashplayer/' target='_blank'>Adobe Flash Player</a> or an iPhone / iPod / iPad to see this content.</p>");
                        // if (showcontroller == "true") {
						//		QT_WriteOBJECT(movieURL, width, height  + 16, '',' controller', 'true','autoplay', 'false');
                        // } else {
                      	//           QT_WriteOBJECT(movieURL, width, height, '',' controller', 'false','autoplay', 'false');
                        //}
                }
        }
		
		
function feedback(message) {
	alert (message);
		}
function showRecherche(id) {
			document.getElementById("spectacle").style.display = 'none';
	   		document.getElementById("representation").style.display = 'none';
	    var e = document.getElementById(id);
	  	 e.style.display = 'block';
}
