function retaille(){
	obj=document.getElementById("offset");
	h=obj.offsetHeight;
	document.getElementById("c3").style.height=h+"px";
	document.getElementById("c4").style.height=h+"px";
	document.getElementById("c5").style.height=h+"px";
	
	window.setInterval("resa_blk()",500);
	
}

var resa_blink=0;

function resa_blk(){
	resa_blink=1-parseInt(resa_blink);
	if(resa_blink==1){
		document.getElementById('resa_titre').style.opacity="0.1";
		document.getElementById('resa_titre').style.filter="alpha(opacity:10)";
	}
	else{
		document.getElementById('resa_titre').style.opacity="1";	
		document.getElementById('resa_titre').style.filter="alpha(opacity:100)";
	}
}




function fusion(){
	document.getElementById("c3").style.display="none;"
}

function test_aj_comm(){
var flag=0;
	for(var i=1;i<5;i++){
		var champ=document.getElementById("ch"+i);
		champ.style.background="#ffffff";
		if (champ.value==""){
			champ.style.background="#f0a8a8";
			flag=1;
		}
		if(i==2){
			var mail=champ.value;
			var exp= new RegExp("^[a-zA-Z0-9]+[a-zA-Z0-9\._-]*@[a-zA-Z0-9\._-]+[a-zA-Z]{1,3}$","g");
			if (!exp.test(mail)){
				champ.style.background="#f0a8a8";
				flag=1;
			}
		}
	}
	if(flag==0){
		document.form_aj_comm.submit();
	}
	else{
		alert("Veuillez renseigner les champs en rouge.");
	
	}
}




function voir_menu(n){
	document.getElementById(n).style.display='block';
}

function cache_menu(n){
	document.getElementById(n).style.display='none';
}


//________________________________________________________________________________________

function test_message(){
flag=0;
	for(i=1;i<5;i++){
		document.getElementById('i'+i).style.background="#f0f6e5";
			if(document.getElementById('i'+i).value==''){
				document.getElementById('i'+i).style.background="#f03333";
				flag=1;
			}
			
	}
	
	if(flag==1){
		alert('Les éléments marqués en rouge requièrent une attention particulière');
	}
	else{
		document.form_message.submit();
	}
}

//________________________________________________________________________________________

function tester_insc_newletter(){
	v=document.getElementById('champ_insc_newsletter').value;
		if(v!=''){
			document.form_insc_newsletter.submit();
		}
}

//________________________________________________________________________________________

function diaporama(){

	this.cont_diapo=document.getElementById('cont_diapo');
	this.tactile=0;
	this.mode='init';
	this.buffer=0
	
	this.n=0;
	this.oldn=0;
	this.delay=0;
	this.url='';
	
	this.promo=3;
	
	this.sequence= new Array();
	this.sequence_l=0;
	
	id=new Array();
	id[0]=this;
	
	s='';
	s+='<img src="" id="diapo_pic_1" style="position:absolute;top:0px;left:0px;z-index:1;opacity:0;filter:alpha(opacity:0);" onClick="diapo.go()" onLoad="diapo.complete()">' ;
	s+='<img src="" id="diapo_pic_2" style="position:absolute;top:0px;left:0px;z-index:2;opacity:0;filter:alpha(opacity:0);" onClick="diapo.go()" onLoad="diapo.complete()">' ;
	s+='<div id="diapo_tactile" style="width:100%;height:100%;background:#000000;opacity:0;filter:alpha(opacity:0);z-index:5;" onClick="alert(\'ok\')"></div>';
	
	this.cont_diapo.innerHTML=s;
	
	this.pic1=document.getElementById('diapo_pic_1');
	this.pic2=document.getElementById('diapo_pic_2');
	
	this.alpha=new Array();
	this.alpha[0]=0;
	this.alpha[1]=0;
	
	this.pics=new Array();
	this.pics[0]=document.getElementById('diapo_pic_1');
	this.pics[1]=document.getElementById('diapo_pic_2');
	
	//_______________________________________
	
	this.moteur=function(){
		switch(this.mode){
		
			case('init'):
				this.mode='run000';
				this.pic1.style.opacity="0";
				this.pic1.style.filter="alpha(opacity:0)";
				this.pic2.style.opacity="0";
				this.pic2.style.filter="alpha(opacity:0)";
				this.n=Math.round(Math.random()*(this.sequence_l-1));
			break;
			
			case('run000'):
				
				
				this.n+=1;
				
					if(this.n>this.sequence_l){
						this.n=0;
					}
				
				/*this.promo+=1;
				
					if(this.promo==5){
						this.n=0;
						this.promo=0;
					}
				
					if(this.n==this.oldn){
						this.mode='run000';
					}
					else{
						this.mode='run001';
						this.oldn=this.n;
					}*/
				this.mode='run001';
			break;
			
			case('run001'):
			
				this.buffer=1-this.buffer;
				this.pics[this.buffer].style.opacity='0';
				this.pics[this.buffer].style.filter='alpha(opacity:0)';
				this.pics[this.buffer].style.zIndex='3';
				this.buffer=1-this.buffer;
				this.pics[this.buffer].style.zIndex='2';
				this.buffer=1-this.buffer;
				this.mode='run002';
			break;
			
			case('run002'):
				this.mode='w';
				this.delay=this.sequence[(this.n*3)+1];
				this.delay*=1000;
				this.alpha[this.buffer]=0;
				this.url=this.sequence[(this.n*3)+2];
				nom='diapo/'+this.sequence[this.n*3];
				this.pics[this.buffer].src=nom;
			break;
			
			
			case('run003'):
				
				this.alpha[this.buffer]+=10;
					if(this.alpha[this.buffer] > 100){
						this.alpha[this.buffer]=100;
						this.mode='run004';
					}
				this.pics[this.buffer].style.opacity=''+this.alpha[this.buffer]/100;
				this.pics[this.buffer].style.filter='alpha(opacity:'+this.alpha[this.buffer]+')';
			break;
			
			case('run004'):
			
				this.delay-=33;
					if(this.delay<0){
						this.mode='run000';
					}
			break;
			
		}
	}
	
	//_______________________________________
	
	this.charge=function(chaine){
	
		this.sequence=chaine.split('$');
		this.sequence_l=this.sequence.length/3;
		this.sequence_l-=1;
		this.timer=window.setInterval('id[0].moteur()',33);
	}
	
	//_______________________________________
	
	this.off=function(){
		window.clearInterval(this.timer);
	}
	
	//_______________________________________
	
	this.complete=function(){
			
			this.mode='run003';
			
	}

	//_______________________________________
	
	this.go=function(){
		if(this.url !=''){
			window.location.replace(this.url);
		}
	}
	
}

//_________________________________________________________________________________________________________ 

function voir(n){

	document.getElementById('fader').style.display="block";
	document.getElementById('cont_photo').style.display="block";
	document.getElementById('photo').src=n;
}

//_______________________________

function cache(n){
	document.getElementById('fader').style.display="none";
	document.getElementById('cont_photo').style.display="none";
	document.getElementById('photo').src="pics/progress.gif";
}

//_________________________________________________________________________________________________________

function actu(){
	
var xhr=0;	

	id2=new Array();
	id2[0]=this;

this.timer=0;

this.liste=new Array();
this.nombre=0;
this.position=0;

this.trigger=0;

this.pan_1_x=0;
this.pan_2_x=0;

this.pan_1=0;
this.pan_2=0;

this.pos=0;
this.dest=0;
this.delta=0;

this.contenu=new Array();

	//________________________________
		
	this.init=function(){
		this.pan_1_x=0;
		this.pan_2_x=400;
		
		this.pan_1=document.getElementById('actu_pan_1');
		this.pan_2=document.getElementById('actu_pan_2');
	
		if (window.XMLHttpRequest){                 
		    xhr = new XMLHttpRequest();     
		} 
		else
		if (window.ActiveXObject){
			  xhr = new ActiveXObject("Microsoft.XMLHTTP");   
		}
	}

	//________________________________

	this.liste=function(){
		xhr.open("GET","ajaxreq.php?v=0",false);
		xhr.send(null);
		result=xhr.responseText;
		this.liste=result.split('$');
		this.nombre=this.liste.length-1;
	}
	
	//________________________________
	
	this.premiere=function(){
		xhr.open("GET","ajaxreq.php?v=1&n="+this.liste[0],false);
		xhr.send(null);
		result=xhr.responseText;
		this.contenu=result.split('$');
		todo='<span class="actu_titre">'+this.contenu[0]+'</span><br/><span class="actu_date">'+this.contenu[1]+'</span><br/><span class="actu_texte">'+this.contenu[2]+'(...)</span>';
		todo+='<br/><span class="actu_suite" onClick="voiractu('+this.liste[0]+')" style="cursor:pointer" >Lire la suite</span><div class="spacer"></div>';
		document.getElementById("actu_pan_1").innerHTML=todo;
	}
	
	//________________________________
	
	this.suivante=function(){

		if ( this.position < this.nombre-1) {
		
			clearInterval(this.timer);	
			
			if ( this.trigger == 0 ) {
				dest = document.getElementById('actu_pan_2');
				
				this.pan_1_x=0;
				this.pan_2_x=400;
				
			}
			else {
				dest = document.getElementById('actu_pan_1');
				
				this.pan_2_x=0;
				this.pan_1_x=400;
				
			}
		
		xhr.open("GET","ajaxreq.php?v=1&n="+this.liste[this.position + 1],false);
		xhr.send(null);
		result=xhr.responseText;	
		
		this.contenu=result.split('$');
		todo='<span class="actu_titre">'+this.contenu[0]+'</span><br/><span class="actu_date">'+this.contenu[1]+'</span><br/><span class="actu_texte">'+this.contenu[2]+'(...)</span>';
		todo+='<br/><span class="actu_suite" onClick="voiractu('+this.liste[this.position+1]+')">Lire la suite</span><div class="spacer"></div>';
		dest.innerHTML=todo;
		
		this.pos=0;
		this.dest=400;
		this.delta=0;
		this.position+=1;
		
		this.testbt();

		this.timer=window.setInterval("id2[0].moteur()",33);
				
		}
	}
	
	//________________________________
	
	this.precedente=function(){

		if ( this.position > 0) {
		
			clearInterval(this.timer);	
			
			if ( this.trigger == 0 ) {
				dest = document.getElementById('actu_pan_2');
				
				this.pan_1_x=0;
				this.pan_2_x=-400;
				
			}
			else {
				dest = document.getElementById('actu_pan_1');
				
				this.pan_2_x=0;
				this.pan_1_x=-400;
				
			}

		xhr.open("GET","ajaxreq.php?v=1&n="+this.liste[this.position - 1],false);
		xhr.send(null);
		result=xhr.responseText;	
		
		this.contenu=result.split('$');
		todo='<span class="actu_titre">'+this.contenu[0]+'</span><br><span class="actu_date">'+this.contenu[1]+'</span><br/><span class="actu_texte">'+this.contenu[2]+'(...)</span>';
		todo+='<br/><span class="actu_suite" onClick="voiractu('+this.liste[this.position-1]+')">Lire la suite</span><div class="spacer"></div>';
		dest.innerHTML=todo;
		
		this.pos=0;
		this.dest=400;
		this.delta=0;
		this.position-=1;
		
		this.testbt()
		
		this.timer=window.setInterval("id2[0].moteur2()",33);
				
		}
	}
	

	this.moteur=function(){
		this.delta= ( this.dest - this.pos ) / 5 ;
		this.pos+=this.delta;
		
			if(this.trigger == 0){
				this.pan_1_x=0 - this.pos;
				this.pan_2_x=400 - this.pos;
			}
			else
			{
				this.pan_2_x=0 - this.pos;
				this.pan_1_x=400 - this.pos;
			}
			
			this.pan_1.style.left=this.pan_1_x+"px";
			this.pan_2.style.left=this.pan_2_x+"px";
						
			if(Math.round(this.pos) == 399){
				clearInterval(this.timer);
				
				if(this.trigger==0){
					this.pan_1_x=400;
					this.pan_2_x=0;
				}
				else{
					this.pan_2_x=400;
					this.pan_1_x=0;
				}
							
				this.trigger=1-this.trigger;
			}
	}
	
	//_____________________________________
	
	this.moteur2=function(){
		this.delta= ( this.dest - this.pos ) / 5 ;
		this.pos+=this.delta;
		
			if(this.trigger == 0){
				this.pan_1_x=0 + this.pos;
				this.pan_2_x=-400 + this.pos;
			}
			else
			{
				this.pan_2_x=0 + this.pos;
				this.pan_1_x=-400 + this.pos;
			}
			
			this.pan_1.style.left=this.pan_1_x+"px";
			this.pan_2.style.left=this.pan_2_x+"px";
								
			if(Math.round(this.pos) == 400){
				clearInterval(this.timer);
				
				if(this.trigger==0){
					this.pan_1_x=400;
					this.pan_2_x=0;
				}
				else{
					this.pan_2_x=400;
					this.pan_1_x=0;
				}
							
				this.trigger=1-this.trigger;
			}
	}
	
	//_____________________________________
	
	this.testbt=function(){
		
		if(this.position+1 == this.nombre ) {
			document.getElementById("actu_fleche_droite").style.opacity="0.3";
			document.getElementById("actu_fleche_droite").style.filter="alpha(opacity:30)";
		}
		else{
			document.getElementById("actu_fleche_droite").style.opacity="1";
			document.getElementById("actu_fleche_droite").style.filter="alpha(opacity:100)";
		}
		
		if(this.position == 0 ) {
			document.getElementById("actu_fleche_gauche").style.opacity="0.3";
			document.getElementById("actu_fleche_gauche").style.filter="alpha(opacity:30)";
		}
		else{
			document.getElementById("actu_fleche_gauche").style.opacity="1";
			document.getElementById("actu_fleche_gauche").style.filter="alpha(opacity:100)";
		}
	}
}

//_________________________________________________________________________________________________________

function voiractu(n){
	document.getElementById('cont_cont_voir_actu').style.display="block";
	document.getElementById('fader').style.display="block";
	
	var xhr=0;
	
		if (window.XMLHttpRequest){                 
		    xhr = new XMLHttpRequest();     
		} 
		else
		if (window.ActiveXObject){
			  xhr = new ActiveXObject("Microsoft.XMLHTTP");   
		}
	
		xhr.open("GET","ajaxreq.php?v=2&n="+n,false);
		xhr.send(null);
		result=xhr.responseText;	
		
		param=result.split('|||');
				
		titre=param[0];
		date=param[1];
		texte=param[2];
		pics=param[3];
		var photo=pics.split('$');
		todo="";
		todo+='<span style="padding:3px;background:#ffffff;float:right;cursor:pointer;"  onClick="cacheactu()">X</span>';
		todo+='<div class="spacer"></div><br/>';
		todo+='<div class="cva_img"><img src="photos/mini'+photo[0]+'.jpg" class="cva_mini" onclick="galerie.charge(\''+pics+'\')"><img src="pics/loupe.gif " class="cva_loupe" onclick="galerie.charge(\''+pics+'\')"/></div>';
		todo+='<span class="cva_titre">'+titre+'</span>';
		todo+='<p class="cva_texte">'+texte+'<p>';
		todo+='<div class="spacer"></div>';
		
		document.getElementById('cont_voir_actu').innerHTML=todo;
}
	
function cacheactu(){
	document.getElementById('cont_cont_voir_actu').style.display="none";
	document.getElementById('fader').style.display="none";
}

function voir_offre(n){

	var xhr=0;
	
		if (window.XMLHttpRequest){                 
		    xhr = new XMLHttpRequest();     
		} 
		else
		if (window.ActiveXObject){
			  xhr = new ActiveXObject("Microsoft.XMLHTTP");   
		}
	
		xhr.open("GET","ajaxreq.php?v=3&n="+n,false);
		xhr.send(null);
		result=xhr.responseText;
		
		document.getElementById('cont_offre').innerHTML=result;
		document.getElementById('cont_offre').style.display='block';
		document.getElementById('fader').style.display='block';
}	

function cache_offre(){
	document.getElementById('cont_offre').style.display='none';
	document.getElementById('fader').style.display='none';
}

//___________________________________________________________________________________________________________________________________

function team(){

var teamid = new Array();
teamid[0]=this;
this.longueur=6;
this.actuelle=1;

this.noms=Array ("","Jean Michel","Christel","Michel","Odile","Eric","Andrew");
this.fonction=Array("","Directeur","Directrice","Fondateur","Fondatrice","Chef - cuisinier","Chef - Barman");

	this.init=function(){
		
	}	
	
	//_______________________________
	
	this.preced=function(){
		this.actuelle -= 1;
			if(this.actuelle == 0 ){
				this.actuelle=6;
			}
		this.refresh();	
	}
	
	//_______________________________
	
	this.suivant=function(){
		this.actuelle+=1;
			if(this.actuelle == 7 ){
				this.actuelle=1;
			}
		this.refresh();	
	}
	
	//_______________________________
	
	this.refresh=function(){
		document.getElementById('photo_team').src="pics/team_0"+this.actuelle+".jpg";
		document.getElementById('team_nom').innerHTML=""+this.noms[this.actuelle];
		document.getElementById('team_fonction').innerHTML=""+this.fonction[this.actuelle];
	}
}

//___________________________________________________________________________________________________________________________________

function team_prev_over(){
	document.getElementById('team_prev').style.backgroundPosition="100% 0%";
}
function team_prev_out(){
	document.getElementById('team_prev').style.backgroundPosition="0% 0%";
}

function team_next_over(){
	document.getElementById('team_next').style.backgroundPosition="100% 0%";
}
function team_next_out(){
	document.getElementById('team_next').style.backgroundPosition="0% 0%";
}

//___________________________________________________________________________________________________________________________________

function test_location(){
	var flag=0;
	for(var i=1;i<8;i++){
		document.getElementById('ch'+i).style.background="#ffffff";
			if(document.getElementById('ch'+i).value==""){
				document.getElementById('ch'+i).style.background="#ff8888";
				flag=1;
			}
	}
	
		if(flag==0){
			document.form_pack.submit();
		}
		else{
			alert("Les éléments marqués en rouge requièrent une attention particulière.");
		}
}

//___________________________________________________________________________________________________________________________________

function test_cheques(){
	var flag=0;
	for(var i=1;i<10;i++){
		document.getElementById('ch'+i).style.background="#ffffff";
			if(document.getElementById('ch'+i).value==""){
				document.getElementById('ch'+i).style.background="#ff8888";
				flag=1;
			}
	}
	
		if(flag==0){
			document.form_cheques.submit();
		}
		else{
			alert("Les éléments marqués en rouge requièrent une attention particulière.");
		}
}

//___________________________________________________________________________________________________________________________________

function cachefl(){
	document.getElementById("fl").style.display="none";
}

function voirfl(){
	document.getElementById("fl").style.display="block";
}

