function addmailing(email, lang){
	if(validMail(email.value)){
		killAjax();
		ret = function() {
			if(ajaxOk()){
				document.getElementById('liste').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=mailing&courriel='+email.value+'&lang='+lang,ret,null);
	}
	else{
		email.focus();
		email.select();
		alert('Veuillez entrer une adresse de courriel valide.');
	}
}

function addcomment(lang, post){
	if(validForm(post)){
		killAjax();
		ret = function(){
			if(ajaxOk()){
				document.getElementById('comment_form').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=comment&lang='+lang,ret,null,post);
	}
}

// Dropdown menu ...
var currMenu = null;
function mainmenu(sender,classe){
	sender = document.getElementById(sender);
	if(sender){
		sender = (sender.tagName=="UL") ? sender : sender.childNodes[0];
		sender = (sender && sender.tagName=="UL") ? sender : sender.nextSibling;
		if(sender){
			if(sender.tagName=="UL"){
				if(classe!=""){
					var uls = sender.getElementsByTagName("UL");
					for(i=0;i<uls.length;i++){
						if(uls[i].className==classe) currMenu = uls[i].parentNode;
					}
					if(currMenu) currMenu.className+=" shover";
				}
				var lis = sender.getElementsByTagName("LI");
				for(i=0;i<lis.length;i++){
					if(lis[i].className!="vide"){
						lis[i].onmouseover=function() {
							if(currMenu) currMenu.className=currMenu.className.replace("shover", "");
							this.className+=" shover";
							//if(document.all) this.style.zIndex=100;
						}
						lis[i].onmouseout=function() {
							this.className=this.className.replace("shover", "");
							if(currMenu) if(currMenu.className.indexOf("shover")==-1) currMenu.className+=" shover";
							//if(document.all) this.style.zIndex=1;
						}
					}
				}
			}else{
				alert("Le sender n\'est pas un UL");
			}
		}
	}
}

function changeSizeTxt(plus){
	if(document.getElementById("contenu") && document.getElementById("msize") && document.getElementById("psize")){
		var cH = (document.getElementById("contenu"));
		var mA = document.getElementById("msize");
		var pA = document.getElementById("psize");
		
		if(!cH.style.fontSize) cH.style.fontSize = "12px";
		var fSize = parseInt(cH.style.fontSize.replace("px",""));
		
		mA.className = "";
		pA.className = "";
		
		if(plus){
			if(fSize<17){
				fSize++;
				cH.style.fontSize = fSize+"px";
			}
		}else{
			if(fSize>10){
				fSize--;
				cH.style.fontSize = fSize+"px";
			}
		}
		
		if(fSize>=17) pA.className = "hidden";
		if(fSize<=10) mA.className = "hidden";
	}
	return false;
}

function printPage(){
	window.print();
	return false;
}

function togglemp3(hndl){
	mp3 = hndl.getAttribute('rel');
	if(hndl.className=='extrait'){
		resetplayicon();
		clearInterval(adnInterval['sScroll']);
		adnInterval['sScroll'] = "stopped";
		hndl.className='pause';
		getplayerhndl().SetVariable("method:setUrl", "/spectacles/"+mp3);
		getplayerhndl().SetVariable("method:play", "");
		getplayerhndl().SetVariable("enabled", "true");
	}else{
		hndl.className='extrait';
		getplayerhndl().SetVariable("method:stop", "");
		if($("#sScroll").length>0) startTapis();
	}
}

var myListener = new Object();
myListener.onInit = function(){this.position = 0;};
myListener.onUpdate = function(){
	if(this.isPlaying != "true"){
		resetplayicon();
	}
};

function getplayerhndl(){return document.getElementById("playerhndl");}

function writemp3player(){
	document.write('<object class="playerpreview" id="playerhndl" type="application/x-shockwave-flash" data="/js/sound.swf" width="1" height="1">    <param name="movie" value="/js/sound.swf" />    <param name="AllowScriptAccess" value="always" />    <param name="FlashVars" value="listener=myListener&amp;interval=500" /></object>');
}

function resetplayicon(){
	//items = document.getElementsByClassName('pause');
	if(adnInterval['sScroll']=="stopped" && $("#sScroll").length>0) startTapis();
	items = $(".pause");
	for(i=0;i<items.length;i++){
		items[i].className='extrait';
	}
}

function redirectSaison(hndl){
	document.location='/spectacle/prog_'+hndl.options[hndl.selectedIndex].value;
}

function addmembre(hndl){
	if(validForm(hndl)){
		jQuery.post("/scripts/membre.php",jQuery("#formmembre").serialize(),function(data){jQuery("#formulaire").html(data);});
		
	}
	return false;
}

function refreshReservation(hndl){
	idshow=hndl.options[hndl.selectedIndex].value;
	jQuery.get("/scripts/refreshshow.php?id="+idshow, function(data){eval(data);});
}

function adddemande(hndl){
	if(validForm(hndl)){
		jQuery.post("/scripts/demande.php",jQuery("#formmembre").serialize(),function(data){jQuery("#formulaire").html(data);});
		
	}
	return false;
}

function startTapis(){
	tapis("top",".spectacle","sScroll",8000,4000,4,4)
}
