
/******  L'animation des sous menu   ********/

var  frame = 0;         // keep track of what frame of the animation we're on.
var  frame_prev = 1;
var  timeout_id = null; // allows us to stop the animation.
var  AnimTab = new Array(3);


function ConstructAnimateObj(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.changeImg=changeImg; 
    this.show=show; 
    this.hide=hide; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 

function hide(){
	this.css.visibility = 'hidden';
}

function show(){
	this.css.visibility = 'visible';
}
function changeImg(p_src){
	this.el.src = p_src
}


function InitAnimation(p_nb_menu, menu)
{

//	alert("menu = " + menu);

	var nb_menu = p_nb_menu
	for (var j=0; j < nb_menu; j++) {
    	AnimTab[j]=new Object();
		for (var i=0; i<3; i++)
	    	AnimTab[j]['img'+i]=new ConstructAnimateObj(menu + (1+j) + '_' + i);
	}
}



function animate()
{
//  	document[menu_title].src = menu[frame].src;
  AnimTab[menu].img0.hide();
	AnimTab[menu].img1.hide();
	AnimTab[menu].img2.hide();
	AnimTab[menu]['img'+frame].show();
//	(frame == 0) ? AnimTab[menu].img0.show() : ((frame == 1) ? AnimTab[menu].img1.show() : AnimTab[menu].img2.show());
  
	frame = (frame == 0) ? 1 : ((frame == 2) ? 1 : ((frame_prev == 0) ? 2 : 0));
	frame_prev = (frame != 1) ? frame : frame_prev;
	timeout_id = setTimeout("animate()", 150);  // display next frame later
}

function start_animate(p_menu)
{
	if ((timeout_id == null) && (LoadOK == true)) {
	 	loop = true;
		menu = p_menu;
		animate();
	}
}

function stop_animate()
{
	if ((timeout_id != null)&& (LoadOK==true)) {
		 clearTimeout(timeout_id); 
		 AnimTab[menu].img0.hide();
		 AnimTab[menu].img1.show();
		 AnimTab[menu].img2.hide();
		 timeout_id=null;
	}
}

/******* L'animation des sous menu **********/
