//-------------------------------------------------------------------------------
// Title: COOLjsMenuPRO
// URL: http://javascript.cooldev.com/scripts/coolmenupro/
// Version: 1.8
// Last Modify: 01-14-2002
// Author: Sergey Nosenko <darknos@cooldev.com>
// Notes: Registered version.
// Copyright (c) 2001-2002 by CoolDev.Com
// Copyright (c) 2001-2002 by Sergey Nosenko
//-------------------------------------------------------------------------------
window.CMenus=[];
var BLANK_IMAGE="img/b.gif";

function COOLjsMenuPRO(name, items, a_target){
	this.bw=new bw_check(); this.bi=new Image(); this.bi.src=BLANK_IMAGE;
	if (this.bw.ns4) window.onresize=resizeHandler;
	window.CMenus[name]=this; 
	window.CMenuHideTimers[name]=null;
	this.name=name; 
	this.rel=items[0].pos=="relative"; 
	this.root=[]; 
	this.root.par=null;
	this.root.cd=[];
	this.root.fmt=items[0]; 
	this.root.pos=this.rel?[0,0]:items[0].pos; 
	this.root.fmt.pos=this.root.pos;
	this.root.frameoff=items[0].pos ? items[0].pos : [0,0];
    this.root.orient = items[0].orient ? items[0].orient : "horiz"; // par défaut, le menu est horizontal

    this.items=[];
    this.keys = new Object(); 
    this.root.lvl = new CMenuLevel(this, this.root);
    
    // level courant ouvert
    this.curLevel = null;
    
    this.target = a_target;		// target général pour tout le menu (sauf surcharge par item)

	this.loadItems(items);
}
/**
 * Charge les items spécifiés.
 * @param a_items   tableau contenant la description des items
 */
COOLjsMenuPRO.prototype.loadItems = function(a_items) {
	for (var i = 1; i < a_items.length; i++) {
		if (!und(a_items[i])) {
			new CMenuItem(this, this.root, a_items[i], 
						  und(a_items[i].format) ? a_items[0] : a_items[i].format);
		}
	}
}

COOLjsMenuPRO.prototype.drawTop=function(){
	var s="";
	for (var i=0;i<this.items.length;i++) if (this.items[i].par==this.root) s+=this.items[i].draw();
	if (this.rel && und(this.rel_div)){
		var w=0; var h=0;
		for (var i=0;i<this.root.cd.length;i++) {
			var n=this.root.cd[i];
			if (n.pos[1]+n.size[0]>h) h=n.pos[1]+n.size[0];
			if (n.pos[0]+n.size[1]>w) w=n.pos[0]+n.size[1];
		}
		s=this.bw.ns4
				?'<ilayer id="cm'+this.name+'_" >' + s + '</ilayer>'
				:'<div id="cm'+this.name+'_" style="position:relative;left:0px;top:0px;width:'+w+'px;height:'+h+'px;">' + s +'</div>';
	}
	return s;
}

COOLjsMenuPRO.prototype.drawOther=function(){
	var s="";
	for (var i=0;i<this.items.length;i++) if (this.items[i].par!=this.root) s+=this.items[i].draw();
	return s;
}
COOLjsMenuPRO.prototype.initTop=function() {
	// on regarde si le div principal existe déjà
	if (this.rel_div) {
		// oui -> on écrit directement dedans
		xbSetInnerHTML(this.rel_div, this.drawTop());
	} else {
		// on écrit dans le document
		document.write(this.drawTop());
		this.rel_div = this.get_div('cm'+this.name+'_');
	}
}
COOLjsMenuPRO.prototype.init=function() {
	// on regarde si le div principal existe déjà
	if (this.other_div) {
		// oui -> on écrit directement dedans
		xbSetInnerHTML(this.other_div, this.drawOther());
	} else {
		// on écrit dans le document
		document.write('<div id="cmo' + this.name + '_">' + this.drawOther() + '</div>');
		this.other_div = this.get_div('cmo'+this.name+'_');
	}
}

/**
 * Recharge les items spécifiés.
 * @param a_items   tableau contenant la description des items
 */
COOLjsMenuPRO.prototype.reloadData = function(a_items) {
	// on nettoie le menu courant
    this.items=[]; 
    this.root.lvl = new CMenuLevel(this, this.root);
	this.root.cd=[];
    this.keys = new Object(); 
    
    // level courant ouvert
    this.curLevel = null;
	// on recharge les items
	this.loadItems(a_items);
	// on réaffiche
	this.initTop();
	this.init();
	this.show();
}

COOLjsMenuPRO.prototype.hide=function(){
	if (this.root.fmt.popup) 
		this.root.lvl.vis(0);
	else {
		for (var i=0;i<this.root.cd.length;i++) if (this.root.cd[i].lvl) this.root.cd[i].lvl.vis(0);
		this.root.lvl.a=null;
		this.root.lvl.draw();
		if (this.root.fmt.hidden_top) this.root.lvl.vis(0);
	}
	this.curLevel = null;
}
COOLjsMenuPRO.prototype.mpopup=function(ev,offX,offY){
	var x=ev.pageX?ev.pageX:(this.bw.opera?ev.clientX:this.bw.ie4?ev.clientX+document.body.scrollLeft:ev.x+document.body.scrollLeft);
	var y=ev.pageY?ev.pageY:(this.bw.opera?ev.clientY:this.bw.ie4?ev.clientY+document.body.scrollTop:ev.y+document.body.scrollTop);
	var po=this.root.fmt.popupoff;
	y += offY?offY:po?po[0]:0;
	x += offX?offX:po?po[1]:0;
	this.popup(x, y);
}
COOLjsMenuPRO.prototype.popup=function(x,y){
	this.moveXY(x,y);
	this.root.lvl.a=null;
	this.root.lvl.vis(1);
	mEvent(this.name,0,'t');
	mEvent(this.name,0,'0');
}
COOLjsMenuPRO.prototype.moveXY=function(x,y){
	if (!this.root.pos || this.root.pos[0] != x || this.root.pos[1] != y) {
		this.root.pos=[x,y]; this.root.loff=[0,0]; this.root.ioff=[0,0];
		for (var i=0;i<this.items.length;i++){
			this.items[i].setPosFromParent();
			this.items[i].move(this.items[i].pos[0],this.items[i].pos[1]);
		}
	}
}
COOLjsMenuPRO.prototype.show=function(){
	if (this.rel) this.move();
	this.root.lvl.vis(1)
}
COOLjsMenuPRO.prototype.move=function(){
	if (!this.rel) return;
	this.rel_div=this.rel_div||this.get_div('cm'+this.name+'_');
	var x = this.bw.ns4 ? this.rel_div.pageX : COOLjsMenuPRO.domPageX(this.rel_div); 
	var y = this.bw.ns4 ? this.rel_div.pageY : COOLjsMenuPRO.domPageY(this.rel_div);
	if (this.root.pos.x==x && this.root.pos.y==y) return;
	this.root.pos=[x,y];
	for (var i=0;i<this.items.length;i++){
		this.items[i].setPosFromParent();
		if (this.items[i].par !== this.root) 
			this.items[i].move(this.items[i].pos[0],this.items[i].pos[1]);
	}
}
COOLjsMenuPRO.prototype.get_div=function(name){return this.bw.ns4?document.layers[name]:document.getElementById?document.getElementById(name):document.all[name];}

/**
 * Désactive l'item spécifié par sa clé
 * @param a_key    (String) 	clé de l'item
 * @param a_state  (boolean)	true si l'item doit être désélectionné, false sinon
 */
COOLjsMenuPRO.prototype.setDisabled = function(a_key, a_state) {
	// on recherche le bon item par sa clé
	var l_item = this.keys[a_key];
	if (l_item != null) {
		if (und(a_state)) {
			// par défaut, on désactive
			a_state = true;
		}
		l_item.setDisabled(a_state ? 'yes' : 'no');
	}
}


/**
 * Sélectionne l'item spécifié par sa clé
 * @param a_key    (String) 	clé de l'item
 */
COOLjsMenuPRO.prototype.selectItem = function(a_key) {
	return this.setSelected(a_key);
}

/**
 * Sélectionne l'item spécifié par sa clé
 * @param a_key    (String) 	clé de l'item
 */
COOLjsMenuPRO.prototype.setSelected = function(a_key) {
	// on recherche le bon item par sa clé
	var l_item = this.keys[a_key];
	if (l_item != null) {
		// on désélectionne l'éventuel item précédemment sélectionné
		if (this.selectedItem) {
			this.selectedItem.setSelected('no');
		}
		// on sélectionne l'item
		l_item.setSelected('yes');
		// on conserve la sélection
		this.selectedItem = l_item;
		
		// on renvoie l'item sélectionné
		return l_item;
	}
	// on renvoie aucun item
	return l_item;
}

function CMenuLevel(menu, par){
	this.menu=menu;
	this.par=par;
	this.v=0;
}
CMenuLevel.prototype.vis=function(s){
	if (s&&this.menu.root.lvl!=this&&this.menu.rel) {this.menu.move()};
	var ss=this.v;
	this.v=s; 
	var l=this.par.cd.length;
	if (this.menu.onlevelshow) this.menu.onlevelshow(this);
	for (var i=0;i<l;i++){
		var n=this.par.cd[i];
		if ( n.hc() && n.lvl.v && !s ) n.lvl.vis(s);
        n.vis(s);
	}
	if (!s) this.a=null;
	if (this.v!=ss&&this.menu.onlevelshow) this.menu.onlevelshow(this);
}
CMenuLevel.prototype.setA=function(idx,s){
	var n=this.menu.items[idx];
	if (nn(this.a)&&n.par.lvl!=this.a.par.lvl) return;
	if(s&&n.hc())n.lvl.vis(1);
	if( s && n!= this.a && nn(this.a) && this.a.hc() && this.a.lvl.v ) this.a.lvl.vis(0);
	this.a=n;
	this.draw();
}
CMenuLevel.prototype.draw=function(){
	if (this.menu.root.lvl==this&&this.menu.root.fmt.hidden_top) {
		return;
	}
	for (var i=0;i<this.par.cd.length;i++) {
		if (this.par.cd[i]==this.a) {
			this.par.cd[i].setVis('o'); 
		} else {
			this.par.cd[i].setVis('n');
		}
	}
}

/**
 * Définition d'un item de menu
 */
function CMenuItem(menu, par, item, format){
	if (und(item)) return;
	this.lvl=null;
	this.par=par;
	this.code=item.code;
	if (und(this.code) || (this.code.length == 0)) {
		this.code = '&nbsp;';
	}
	this.ocode=item.ocode || this.code;
	
	this.key = item.key;
	if (und(this.key) || (this.key.length == 0)) {
		this.key = this.code;
	}

	// on regarde le target
	if (und(item.target) && item.url) {
		// pas de target défini et url définie -> on récupère le target éventuel du père
		item.target = menu.target;
	}
	this.targ=und(item.target) ? "" : 'target="'+item.target+'" ';

	this.url= item.url || "javascript:none()";
	this.url = (this.url) == "sep" ? "" : this.url;
	
	this.fmt=format;
	this.menu=menu;
	this.bw=menu.bw;
	this.cd=[];
	this.divs=[];
	this.index=menu.items.length;
	menu.items=menu.items.concat([this]);
	menu.keys[this.key] = this;
	this.pindex=par.cd.length;
	par.cd=par.cd.concat([this]);
	this.id="cmi"+this.menu.name+"_"+this.index;
	this.v=0;
	this.state='n';
	this.offset = 0;
	this.diva=["b","s","o","n","e"];
	this.visDiv=this.bw.ns4? visDivNS:visDivDom;
	this.ioff=this.getf(this, "itemoff");
	this.loff=this.getf(this, "leveloff");
	this.imgsize=this.getf(this, "imgsize");
	this.arrsize=this.getf(this, "arrsize");
	this.image=this.getf(this, "image");
	this.oimage=this.getf(this, "oimage") || this.image;
	this.arrow=this.getf(this, "arrow");
	this.oarrow=this.getf(this, "oarrow") || this.arrow;
	this.style=this.getf(this, "style");

	this.setDisabled(this.getf(this, "disabled"));
	this._setSelected(this.getf(this, "selected"));

	this.size=this.getSize();
	this.orient = this.getOrient(this, "orient");
	
	if (this.it()) this.fmt.pos = this.getf(this, "pos");
	this.prev= (this.pindex == 0) ? null : this.par.cd[this.pindex-1];


	this.setPos();
	this.sub=item.sub;
	if (!und(this.sub) && !und(this.sub.length)&& this.sub.length>0){
		this.lvl=new CMenuLevel(menu, this);
		for (var i=1;i<this.sub.length;i++)
			if (!und(this.sub[i])) new CMenuItem(this.menu, this, this.sub[i], und(this.sub[i].format)?this.sub[0]: this.sub[i].format);
	}
	return this;
}

CMenuItem.prototype.hc=function(){return this.cd.length > 0}; 
CMenuItem.prototype.hac=function(){return this.hc()&&this.cd[0].vis}; 
CMenuItem.prototype.it=function(){return this.par == this.menu.root};
CMenuItem.prototype.div=function(n){
	return und(this.divs[n]) ?
			this.divs[n] = this.get_div(this.id+n) : 
			this.divs[n];}

CMenuItem.prototype.gen_divCode=function(a_state) {
	var l_suffixe = (this.selected) ? "_SEL" : (this.disabled) ? "_DIS" : "";
	var l_cssOff = this.style.css["OFF" + l_suffixe];
	var l_cssOver = this.style.css["OVER" + l_suffixe];
	
	return '<div class="'+(a_state=='n' ? l_cssOff : l_cssOver)+'">'+(a_state=='n'?this.code:this.ocode)+'</div>';
}

CMenuItem.prototype.gen_code=function(state, off){
	if (!und(off)) {
		this.offset = parseInt(off);
	}
	var res='';
	var table=(nn(this.arrow) && this.hc()) || nn(this.image);
	var image=nn(this.image);
	var arrow=nn(this.arrow)&& this.hc();
	if (table) res += '<table cellpadding="0" cellspacing="0" width="100%" height="'+(parseInt(this.size[0])-this.offset)+'" border=0><tr>';														   
	if (image) res += '<td class="'+(state=='n' ? this.style.css.ON_IMG:this.style.css.OVER_IMG)+'" width='+this.imgsize[1]+'><img src="'+(state=='n'?this.image:this.oimage)+'" width='+this.imgsize[1]+' height='+this.imgsize[0]+'/></td>';
	if (table) res += '<td width="100%">';

	res += this.gen_divCode(state);
	if (table) res += '</td>';
	if (arrow) res += '<td width='+this.arrsize[1]+'><img src="'+(state=='n'?this.arrow:this.oarrow)+'" width='+this.arrsize[1]+' height='+this.arrsize[0]+'/></td>';
	if (table) res += '</tr></table>';
	return res;
}
CMenuItem.prototype.draw=function(){	
	var bl = bt = br = bb = 0;
	if (!und(this.style.border) && !und(this.style.borders)) {
		bl=bt=this.style.border;
		br=bb=this.style.border*2;

		bl=this.style.borders[0];
		bt=this.style.borders[1];
		br=this.style.borders[2]+bl;
		bb=this.style.borders[3]+bt;
	}
	var l_color = this.style.color;
	var s=this.style.shadow;
	var z=(!this.style.shadow?"":adiv(this.menu.bw, this.id+"s", this.z, this.pos[0]+s, this.pos[1]+s, this.size[1], this.size[0], (l_color) ? l_color.shadow : null, "", ""))+
			(!this.style.border?"":adiv(this.menu.bw, this.id+"b", this.z, this.pos[0], this.pos[1], this.size[1], this.size[0], (l_color) ? l_color.border : null, "", ""))+
			adiv(this.menu.bw, this.id+"n", this.z, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, (l_color) ? l_color.bgON : null, this.gen_code('n', parseInt(bt)+parseInt(bb)))+
			adiv(this.menu.bw, this.id+"o", this.z, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, (l_color) ? l_color.bgOVER : null,this.gen_code('o', bt+bb));

	if (!this.disabled) {
		var l_code = '<a href="'+this.url+'" '+this.targ+'onclick="mEvent(\''+this.menu.name+'\','+this.index+',\'c\');">'+'<img src="'+this.menu.bi.src+'" width="'+this.size[1]+'" height="'+this.size[0]+'"/></a>';
		var l_other = 'onmouseover="mEvent(\''+this.menu.name+'\','+this.index+',\'o\');" onmouseout="mEvent(\''+this.menu.name+'\','+this.index+',\'t\');"';
	
		z += adiv(this.menu.bw, this.id+"e", this.z, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, "", l_code,'',l_other);
	}
	return z;
}
CMenuItem.prototype.vis=function(s){
		if (this.style.shadow) this.visDiv("s",s);
		if (this.style.border) this.visDiv("b",s);
		if (!s) {
			this.visDiv("o",0);
			this.visDiv("n",0);
			this.state="n";
		}else if (this.state=="n")
			this.visDiv("n",1);
		else 
			this.visDiv("o",1);
		if (!this.disabled) {
			this.visDiv("e",s);
		}
}
CMenuItem.prototype.setVis = function (n){
	if (this.state!=n)
		switch (n){
			case "n":
				this.visDiv("n",1);this.visDiv("o",0);
				break;
			case "o":
				this.visDiv("n",0);this.visDiv("o",1);
				break;
		}
	this.state=n;
}
CMenuItem.prototype.getf=function(obj, name){
	if (!und(obj) && nn(obj) && !und(obj.fmt)) {
		if (!und(obj.fmt[name]))
			return obj.fmt[name];
		if (obj.par!=this.menu.root && obj.par && obj.par.sub && obj.par.sub[0][name]) 
			return obj.par.sub[0][name];
		return this.getf(obj.par, name);
	}
	return;
}
CMenuItem.prototype.getSize = function() {
	var l_size = this.getf(this, "size");
	if (l_size && (l_size[1] == -1)) { // largeur non définie
		// on renvoie celle du 'parent'
		var l_parWidth;
		if (this.par != this.menu.root && this.par && this.par.sub && this.par.sub[0]["size"]) { 
			l_parWidth = this.par.sub[0]["size"][1];
		} else {
			l_parWidth = this.getf(this.par, "size")[1];
		}
		
		// attention : on renvoie bien un nouveau tableau, pour ne pas modifier le tableau 
		// de définition de l'item lui-même
		return [l_size[0], l_parWidth];
	}
	return l_size;
}

CMenuItem.prototype.getOrient=function(obj, name){
	if (!und(obj) && nn(obj) && !und(obj.fmt)) {
		if (!und(obj.fmt[name])) {
			return obj.fmt[name];
		}
		if (obj.par && obj.par.sub && obj.par.sub[0][name]) {
			return obj.par.sub[0][name];
		} else {
			if (obj.par != this.menu.root) {
				// on regarde le grand pere
				if (obj.par.par == this.menu.root) {
					// pas de définion pour le premier sous-menu -> vertical par défaut
					return "vert";
				} else {
					// on remonte
					return this.getOrient(obj.par, name);
				}
			} else {
				// on récupère l'orientation du menu
				return this.menu.root.orient;
			}
		}
	}
	// a priori, pas beaucoup de chance d'arriver là
	alert("getOrient() pas défaut !!!");
	return "horiz";
}

/**
 * Active / désactive l'item.
 * @param a_disabled  (String)  'yes' si désactivé
 */
CMenuItem.prototype.setDisabled = function(a_disabled) {
	// si le paramètre n'est pas fourni, false par défaut
	this.disabled = und(a_disabled) ? false : a_disabled == 'yes';
	if (this.disabled) {
		this.url = "javascript:none()";
	}
}

/**
 * Sélectionne / désélectionne l'item, sans mettre àjour la partie graphique.
 * @param a_selected  (String)  'yes' si sélectionné
 */
CMenuItem.prototype._setSelected = function(a_selected) {
	// si le paramètre n'est pas fourni, false par défaut
	this.selected = und(a_selected) ? false : a_selected == 'yes';
	if (this.selected) {
		this.url = "javascript:none()";
	}
}

/**
 * Sélectionne / désélectionne l'item, en mettant à jour la partie graphique
 * @param a_selected  (String)  'yes' si sélectionné
 */
CMenuItem.prototype.setSelected = function(a_selected) {
	this._setSelected(a_selected);

	// on met à jour les 2 div
	xbSetInnerHTML(this.div('n'), this.gen_code('n'));
	xbSetInnerHTML(this.div('o'), this.gen_code('o'));
}

CMenuItem.prototype.setPos=function(){
	if (this.prev == null) {
		// premier item de la liste
		this.z = (this.par == this.menu.root) ? 10000 : this.par.z+10;
//			this.pos = und(this.fmt.pos)
//					? (this.par == this.menu.root ? this.fmt.pos : this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]])
//					: this.fmt.pos;
		if (und(this.fmt.pos)) {
			if (this.par == this.menu.root) {
				this.pos = this.fmt.pos;
			} else {
//					this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]]
				// premier item d'un sous-menu
				if (this.orient == "horiz") {
					// menu parent horizontal
					this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]];
				} else {
					// menu parent vertical
					this.pos=[this.par.pos[0]+ (this.par.size ? this.par.size[1] : 0), 
							 this.par.pos[1]+this.loff[0]];
				}
			}
			
		} else {
			this.pos = this.fmt.pos;
		}
	} else {
		// suivant 
		this.prev.next=this;
		this.z=this.prev.z;
//			this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.ioff[0]];
		if (this.orient == "horiz") {
			// menu horizontal
			this.pos=[this.prev.pos[0]+this.prev.size[1], this.prev.pos[1]+this.ioff[0]];
		} else {
			// menu vertical
			this.pos=[this.prev.pos[0], this.prev.pos[1]+this.prev.size[0]];
		}
	}
}

CMenuItem.prototype.setPosFromParent=function(){
	if (this.index==0&&!this.menu.rel) {
		// premier item du menu principal
		this.pos=[this.menu.root.pos[0], this.menu.root.pos[1]]
	} else if (this.prev==null) {
		// premier item d'un sous-menu
		if (this.par.orient == "horiz") {
			// menu parent horizontal
			this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]];
		} else {
			// menu parent vertical
			this.pos=[this.par.pos[0]+ (this.par.size ? this.par.size[1] : 0), 
					 this.par.pos[1]+this.loff[0]];
		}
	} else {
//		  this.par == this.menu.root 
//		  	? this.pos=[this.prev.pos[0]+this.prev.size[1], this.prev.pos[1]+this.ioff[0]]
////				: this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.ioff[0]];
//				: this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.prev.size[0]];
		if (this.orient == "horiz") {
			// menu parent horizontal
			this.pos=[this.prev.pos[0]+this.prev.size[1], this.prev.pos[1]+this.ioff[0]];
		} else {
			// menu parent vertical
			this.pos=[this.prev.pos[0], this.prev.pos[1]+this.prev.size[0]];
		}
	}
}

CMenuItem.prototype.get_div=function (name){
	if (this.bw.ns4 && this.menu.rel && this.par==this.menu.root) 
		return document.layers["cm"+this.menu.name+"_"].layers[name]
	else
		return this.bw.ns4?document.layers[name]:document.getElementById?document.getElementById(name):document.all[name];
}
CMenuItem.prototype.move=function( x, y ){
	var bl=this.style.border;
	if (und(bl)) {
		bl = 0;
	}
	var bt=bl;
	if (this.style.border && !und(this.style.borders)) {
		bl=this.style.borders[0];
		bt=this.style.borders[1];
	}
	if (this.style.shadow) this.moveTo(x+parseInt(this.style.shadow),y+parseInt(this.style.shadow),"s");
	if (this.style.border) this.moveTo(x,y,"b");
	this.moveTo(x+bl,y+bt,"o");
	this.moveTo(x+bl,y+bt,"n");
	if (!this.disabled) {
		this.moveTo(x+bl,y+bt,"e");
	}
}
CMenuItem.prototype.moveTo=function( x, y, b ){
	if (this.bw.ns4)
		this.div(b).moveTo(x,y);
	else{
		this.div(b).style.left=x;
		this.div(b).style.top=y;
	}
}

function adiv(bw,name,z,left,top,width,height,bgc,code,otherCSS, otherDIV){
	return bw.ns4?
		'<layer id="'+name+'" z-index="'+z+'" left="'+left+'" top='+top+'" width="'+width+'" height="'+height+'"'+(bgc!=""?' bgcolor="'+bgc+'"':'')+(otherCSS?' style="'+otherCSS:'')+'" visibility="hidden" '+(otherDIV?otherDIV:'')+'>'+code+'</layer>\n':
		'<div id="'+name+'" style="position:absolute;clip:rect(0px '+width+'px '+height+'px 0px);z-index:'+z+';left:'+left+'px;top:'+top+'px;width:'+width+'px;height:'+height+'px;visibility:hidden'+(bgc!=""?';background-color:'+bgc+'':'')+';'+(otherCSS?otherCSS:'')+'" '+(otherDIV?otherDIV:'')+'>'+code+'</div>';
}
function visDivNS(d,s){
	this.div(d).visibility=s?'show':'hide';
}
function visDivDom(d,s){
	this.div(d).style.visibility=s?'visible': 'hidden';
}

function mEvent(m, node_index, e) {
	if (nn(window.CMenuHideTimers[m])) {
		window.clearTimeout(window.CMenuHideTimers[m]);
		window.CMenuHideTimers[m]=null;
	}
	var l_menu = window.CMenus[m];
	var l_item = l_menu.items[node_index];
	switch (e){
		case "o":
			if (l_item.it()) {
				// menu prinicipal
				if (nn(l_menu.curLevel)) {
					// un sous-menu est affiché -> on affiche le suivant
					l_item.par.lvl.setA(node_index, 1);
				} else {
					// on surligne simplement la case
					l_item.setVis('o');
				}
			} else {
				l_item.par.lvl.setA(node_index,1);
			}
			if (l_menu.onmouseover) l_menu.onmouseover(l_item);
			break;
		case "c":
			if (!l_item.disabled) {
				if (l_item.it() && l_item.hc()) {
					if (l_menu.curLevel == l_item.lvl) {
						// sous-menu déjà ouvert -> on le ferme
						l_menu.hide();
					} else {
						// on ouvre le sous-menu
						l_item.par.lvl.setA(node_index, 1);
						// on conserve le sous-menu
						l_menu.curLevel = l_item.lvl;
					}
				} else {
					if (l_item.hc()) 
						l_item.lvl.vis(!l_item.lvl.v);
					else
						for (var i=0;i<l_menu.root.cd.length;i++)
							if (nn(l_menu.root.cd[i].lvl)) l_menu.root.cd[i].lvl.vis(0);
				}
						
				if (l_menu.onclick) l_menu.onclick(l_item);
			}
			break;
		case "t":
			if (l_item.it() && !nn(l_menu.curLevel)) {
				l_item.setVis('n');
			}
			window.CMenuHideTimers[m]=setTimeout('window.CMenus["'+m+'"].hide()', und(l_menu.root.fmt.delay)?600:l_menu.root.fmt.delay);
			if (l_menu.onmouseout) l_menu.onmouseout(l_item);
			break;
	}
	return true;
}

COOLjsMenuPRO.domPageX = function(el) {
  var x=el.offsetLeft;
  var parent=el.offsetParent;
  while(parent && parent!=document.body) {
	x += parent.offsetLeft;
	parent=parent.offsetParent;
  }
  return x;
}
COOLjsMenuPRO.domPageY = function(el) {
  var x=el.offsetTop;
  var parent=el.offsetParent;
  while(parent && parent!=document.body) {
	x += parent.offsetTop;
	parent=parent.offsetParent;
  }
  return x;
}
if (und(window.CMenuHideTimers)) window.CMenuHideTimers=[];

window.oldCMOnLoad=window.onload;
function CMOnLoad(){
	var bw=new bw_check();
	if (bw.ns4 || bw.opera){
		window.origWidth=window.innerWidth;
		window.origHeight=window.innerHeight;
		if (bw.opera && !window.operaResizeTimer) resizeHandler();
		if (bw.ns4) window.onresize=resizeHandler;
	}
	if (typeof(window.oldCMOnLoad)=='function') window.oldCMOnLoad();
}
window.onload=new CMOnLoad();
function resizeHandler() {
	if (window.reloading) return;
	var reload=window.innerWidth != window.origWidth || window.innerHeight != window.origHeight;
	window.origWidth=window.innerWidth; window.origHeight=window.innerHeight;
	if (reload) {window.reloading=1;document.location.reload();return};
	if (new bw_check().opera) window.operaResizeTimer=setTimeout('resizeHandler()',500);
}
function CMenuPopUp(menu, evn, offX, offY){window.CMenus[menu].mpopup(evn, offX, offY);}
function CMenuPopUpXY(menu,x,y){window.CMenus[menu].popup(x,y);}
if (new bw_check().ns4) window.onresize=resizeHandler;
