// JavaScript Document


function set_opacity(el,opacity) {
opacity =Math.max(0.001,Math.min(	(/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 99.999 : 100,opacity));
el.style["filter"] = "alpha(opacity="+opacity+")";
el.style["-moz-opacity"] = opacity/100;
el.style["-khtml-opacity"] = opacity/100;
el.style["opacity"] = opacity/100; 
}

function change_news(n,lien){
clearTimeout($t_news); // annule temporisation affichage des news
	if(typeof oldnews == 'undefined') oldnews=0;var old=findObj('news'+oldnews), next=findObj('news'+n), oldlien=findObj('btnews'+oldnews);oldlien.className='n-off';lien.className='n-on';old.style.display='none';next.style.display='block';oldnews=n;
}

function diaporama(obj,T1){
findTags(obj,'LI');
var n = obj.LIS.length-1/*le dernier LI contient diapolien */, zind=100, a=findObj('diapolien');
//alert(a);

	for(var i=0; i<n; i++){
	obj.LIS[i].parentElmt=obj;
	findTags(obj.LIS[i],'A');
	obj.LIS[i].diapolien=a;
	obj.LIS[i].a=obj.LIS[i].AS[0];
	obj.LIS[i].opacity=0;
	obj.LIS[i].style.zIndex=zind;
	obj.LIS[i].prevElmt=obj.LIS[Math.max((i==0?n-1:0),i-1)];
	obj.LIS[i].nextElmt=obj.LIS[Math.min((i==n-1?0:n-1),i+1)];
	obj.LIS[i].style.display='none';
	set_opacity(obj.LIS[i],0);
	zind--;
	}
	
	if(n>0){
	// alert(obj.LIS[0].a.title);
	obj.LIS[0].diapolien.href=obj.LIS[0].a.href;
	obj.LIS[0].diapolien.title=obj.LIS[0].a.title;
	obj.LIS[0].opacity=100;
	set_opacity(obj.LIS[0],100);
	obj.LIS[0].nextElmt.opacity=-10;
	obj.LIS[0].nextElmt.style.display=obj.LIS[0].style.display='block';
	obj.LIS[0].style.zIndex=10;
	obj.LIS[0].nextElmt.style.zIndex=12;
	
	set_opacity(obj.LIS[0].nextElmt,0);
	
		oups=function(){
		fondu( obj.LIS[0], obj.LIS[0].nextElmt, 'next');
		//fondu( obj.LIS[0], obj.LIS[0].prevElmt, 'prev');
		}
	setTimeout("oups()",T1);
	}
}

function fondu(sous, sur, sens){
	if(!sens) sens='next';
	
	if(sur.opacity>=100){
	sur.opacity=100;
	set_opacity(sur,100);
	sous.opacity=0;
	sous.style.display='none';
	set_opacity(sous,0);
	sur.style.zIndex=10;
	sous=sur;
	
		if(sens=='next'){
		sur=sous.nextElmt;
		}else{
		sur=sous.prevElmt;
		}
	sur.style.zIndex=12;
	sur.style.display='block';
	
	oups=function(change){
		fondu(sous, sur, sens);
		} // oups
	tdiapo=setTimeout("oups()",4000); //5000 
	}else{
	set_opacity(sur,sur.opacity);
	oups=function(change){
			if(change){
			clearTimeout(tdiapo);
			change_fondu(sous, sur, change);
			return;
			}
		fondu(sous, sur, sens);
		} // oups
			// temps de fondu *50* pour 4 secondes
	tdiapo=setTimeout("oups()",40);
	}
sur.opacity+=5;

	if(sur.opacity>=50){	
	sur.diapolien.href=sur.a.href;
	sur.diapolien.title=sur.a.title;
	}else{
	sous.diapolien.href=sous.a.href;
	sous.diapolien.title=sous.a.title;
	}
}

function change_fondu(sous, sur, sens){

sur.style.display=sous.style.display='none';
sur.opacity=sous.opacity=0;
set_opacity(sur,0);
set_opacity(sous,0);
	if(sens=='next'){
	sous=sur; // sur.nextElmt
	sur=sur.nextElmt; //  sur.nextElmt.nextElmt
	}else{
	sous=sous.prevElmt; // sous.prevElmt;
	sur=sous.prevElmt.prevElmt;  // sous.prevElmt.prevElmt
	}
	
sous.opacity=100;
set_opacity(sous,100);
sur.style.display=sous.style.display='block';
sous.style.zIndex=10;
sur.style.zIndex=12;

sous.diapolien.href=sous.a.href;
sous.diapolien.title=sous.a.title;

changeoups=function(){
	fondu(sous, sur, sens);
	} // changeoups
	// il faut redefinir oups
	oups=function(change){
		clearTimeout(tdiapo);
		change_fondu(sous, sur, change);
		return;
		} // oups
	tdiapo=setTimeout("changeoups()",4000);

return;
}


function findObj(n,c)			{var x,d=c?c.document:document; if(!(x=d[n])&&d.all) x=d.all[n];if(!x && d.getElementById) x=d.getElementById(n);return x;}

function findTags(obj,tag,arr)	{if(tag=='*'){obj.ALLS = obj.all||obj.getElementsByTagName(tag);}else{obj[tag+"S"] = obj.all?obj.all.tags(tag):obj.getElementsByTagName(tag);};if(arr)return obj.ALLS || obj[tag+"S"] || [];}

function getBounds(obj)			{obj.X=obj.offsetLeft;obj.Y=obj.offsetTop;obj.W=obj.offsetWidth;obj.H=obj.offsetHeight;var tempObj=obj;while(tempObj=tempObj.offsetParent){if (isNaN(tempObj.offsetTop)) break;obj.X+=tempObj.offsetLeft;obj.Y+=tempObj.offsetTop; }return obj;}

function findRealParent(obj)	{return obj.parentNode||obj.parentElement;}

String.prototype.trim = function() {return this.replace(/(^\s*)|(\s*$)/g,'');}
/* ajouter arondi monetaire */
function ismail(mail){return (/^([a-z_0-9\.-]+)@([a-z_0-9\.-]+)\.([a-z]{2,5})$/).test(mail);}
function Fwrite(str){document.write(str);}
function change_url(str){location=str;}


function defil(maxscroll) {

var obj=findObj('zmllmz');
//return;
		if(!maxscroll){ // il faut le definir en poussant le scroll a donf et il retournera sa valeur maxi
		obj.scrollLeft=20000;
		t_defil=setTimeout('defil('+findObj('zmllmz').scrollLeft+')',10);
		// on rembobine :)
		obj.scrollLeft=0;
		return;
		}
		
	clearTimeout(t_defil);
	var decal=2 , delai=25 ; ;
		if(document.all) delai= Math.round(delai*0.78);
	var scrollLeft=obj.scrollLeft;
		if(scrollLeft>=maxscroll){
		obj.scrollLeft=0;
		} else {
		obj.scrollLeft=scrollLeft+decal;
		}
	
	t_defil=setTimeout('defil('+maxscroll+')',delai);

}

function newslettre(){
var o=document.newsletter;
o.new_email.value=o.new_email.value.trim();
	if(ismail(o.new_email.value)){
	o.submit();
	}else{
	alert(o.new_email_error.value);
	}
}

function quick(idTheme){
var o=document.quickCherche;
o.reset();
o.idTheme.value=idTheme;
o.onsubmit();
o.submit();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

function calculResultat(){
	//return;
	var n_idFormat=0;
	if (document.getElementById('idFormat1').checked==true){ var idFormat1=document.getElementById('idFormat1').value; n_idFormat++;}else{ var idFormat1='';}
	if (document.getElementById('idFormat2').checked==true){ var idFormat2=document.getElementById('idFormat2').value; n_idFormat++;}else{ var idFormat2='';}
	if (document.getElementById('idFormat3').checked==true){ var idFormat3=document.getElementById('idFormat3').value; n_idFormat++;}else{ var idFormat3='';}
	if (document.getElementById('idFormat4').checked==true){ var idFormat4=document.getElementById('idFormat4').value; n_idFormat++;}else{ var idFormat4='';}
	if (document.getElementById('idFormat5').checked==true){ var idFormat5=document.getElementById('idFormat5').value; n_idFormat++;}else{ var idFormat5='';}
	if (document.getElementById('idFormat6').checked==true){ var idFormat6=document.getElementById('idFormat6').value; n_idFormat++;}else{ var idFormat6='';}
	if (document.getElementById('idFormat7').checked==true){ var idFormat7=document.getElementById('idFormat7').value; n_idFormat++;}else{ var idFormat7='';}
		
		if(n_idFormat==0){
		idFormat1=document.getElementById('idFormat1').value;
		idFormat2=document.getElementById('idFormat2').value;
		idFormat3=document.getElementById('idFormat3').value;
		idFormat4=document.getElementById('idFormat4').value;
		idFormat5=document.getElementById('idFormat5').value;
		idFormat6=document.getElementById('idFormat6').value;
		idFormat7=document.getElementById('idFormat7').value;
		}

	if (document.getElementById('idArtisteTemp').value!=''){ var idArtisteTemp=document.getElementById('idArtisteTemp').value;}else{ var idArtisteTemp='';}
	if (document.getElementById('idBudgetTemp').value!=''){ var idBudgetTemp=document.getElementById('idBudgetTemp').value;}else{ var idBudgetTemp='';}
	if (document.getElementById('idPtsVenteTemp').value!=''){ var idPtsVenteTemp=document.getElementById('idPtsVenteTemp').value;}else{ var idPtsVenteTemp='';}
	if (document.getElementById('listFormats').value!=''){ var listFormats=document.getElementById('listFormats').value;}else{ var listFormats='';}
	
	// nouveau
	if (document.getElementById('formatSection').value!=''){ var formatSection=document.getElementById('formatSection').value;}else{ var formatSection='';}
	if (document.form.idTheme.value!=''){ var idTheme=document.form.idTheme.value;}else{ var idTheme='';}

	document.getElementById('nbrResultat').src='iframe.php?idFormat1='+idFormat1+'&idFormat2='+idFormat2+'&idFormat3='+idFormat3+'&idFormat4='+idFormat4+'&idFormat5='+idFormat5+'&idFormat6='+idFormat6+'&idFormat7='+idFormat7+'&idArtisteTemp='+idArtisteTemp+'&idBudgetTemp='+idBudgetTemp+'&idPtsVenteTemp='+idPtsVenteTemp+'&listFormats='+listFormats+'&formatSection='+formatSection+'&idTheme='+idTheme;

}

function xmlhttp(){
var request=false;
try{request=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){try{request=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{request=new XMLHttpRequest();}catch(e){request=false;}}}
return request;
}

function getFormats(){
var format1=document.getElementById('idFormat1');
var format2=document.getElementById('idFormat2');
var format3=document.getElementById('idFormat3');
var format4=document.getElementById('idFormat4');
var format5=document.getElementById('idFormat5');
var format6=document.getElementById('idFormat6');
var format7=document.getElementById('idFormat7');
var listFormats=document.getElementById('listFormats');
var identifiants='';
	if(format1.checked){identifiants=identifiants+'+'+format1.value;}
	if(format2.checked){identifiants=identifiants+'+'+format2.value;}
	if(format3.checked){identifiants=identifiants+'+'+format3.value;}
	if(format4.checked){identifiants=identifiants+'+'+format4.value;}
	if(format5.checked){identifiants=identifiants+'+'+format5.value;}
	if(format6.checked){identifiants=identifiants+'+'+format6.value;}
	if(format7.checked){identifiants=identifiants+'+'+format7.value;}
	
	if(identifiants==''){
	identifiants='+'+format1.value+'+'+format2.value+'+'+format3.value+'+'+format4.value+'+'+format5.value+'+'+format5.value+'+'+format6.value+'+'+format7.value;
	}
	
var xml=xmlhttp();
	if(!xml){
	alert("XmlHttpRequest non supporté");
	}else{
		xml.onreadystatechange=function(){
			if(xml.readyState==4){
			var opt=eval("("+xml.responseText+")");
			listFormats.length=0;
				for(var n=0;n<opt.formats.tailles.length;n++){
				listFormats.length++;
				listFormats.options[listFormats.length-1].text=opt.formats.tailles[n].texte;
				listFormats.options[listFormats.length-1].value=opt.formats.tailles[n].value;
				}
			document.getElementById('chargement').style.display='none';
			}
		}
	document.getElementById('chargement').style.display='block';
	xml.open('GET',"./get_formats.php?id="+identifiants.substring(1,identifiants.length),true);
	xml.send(null);
	}
}
