/*-------------------------------------------------------------------
Espace Dynamique templates engine
Front-office pages
Javascript functions
---------------------------------------------------------------------
20070213 - ESPACE DYNAMIQUE - ADH V1.00
---------------------------------------------------------------------*/
// Global variables
var d = document;
var bNavNS = navigator.appName.substring(0, 3) == "Net"; // FF / IE;
var x = 0, y = 0;
/*-------------------------------------------------------------------
20061207
---------------------------------------------------------------------*/
function getFirstByClass(Obj, Cl) {
	var aChild = Obj.childNodes;
	for (var i = 0; i < aChild.length; i++) {
		if (aChild[i].className == Cl) {
			return aChild[i];
		}
	}
	return false;
}
/*-------------------------------------------------------------------
20061207
Open or close block of containers
---------------------------------------------------------------------*/
function OCBlock(Obj) {
	var oPar = Obj.parentNode;
	var oPar2 = oPar.parentNode;
	var bRoot = false;
	var bOpened = false;
	oNode = getFirstByClass(oPar, 'Node');
	if (!oNode) {
		oNode = getFirstByClass(oPar, 'Root');
		bRoot = true;
	}
	if (!oNode) return; // pb 
	var s = oNode.style;
	if (s.backgroundPosition == '') { // default : root opened, other opened
		bOpened = true;
		s.backgroundPosition = '-20px 0px';
	}
	else if (s.backgroundPosition != '-20px 0px') {
		bOpened = true;
		s.backgroundPosition = '-20px 0px';
	}
	else {
		s.backgroundPosition = '0px 0px';
	}
	switch (oPar2.className) {
//		case 'Choice': Target = 'Firm'; break;
//		case 'Cat': Target = 'Firm'; break;
//		default: Target = 'Art'; break;
		case 'Firm': Target = 'Art'; break;
		default: Target = 'Firm'; break;
	}
	var aChild = oPar2.childNodes;
	for (var i = 0; i < aChild.length; i++) {
		if ((aChild[i].className == Target) ||
		((bRoot) && (aChild[i].className == 'Art Edito'))) {
			aChild[i].style.height = (bOpened) ? '0' : 'auto';
			aChild[i].style.visibility = (bOpened) ? 'hidden' : 'visible';
		}
	}
}
/*-------------------------------------------------------------------
20061201
---------------------------------------------------------------------*/
function Init() {
	if (window.XMLHttpRequest) // FF 
		xhrObj = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // IE 
		xhrObj = new ActiveXObject('Microsoft.XMLHTTP'); 
	else { // XMLHttpRequest non supporté
		alert('Votre navigateur ne supporte pas le fonctionnement asynchrone...'); 
		return; 
	}
	// catch events
	if(bNavNS) d.captureEvents(Event.MOUSEMOVE);
	d.onmousemove = GetMouse;
	// specific treatments
	if (d.getElementById('DBType')) {
		var Cmd = 'ManageBp' + d.getElementById('DBType').value + '("First", d.body)';
		eval (Cmd);
	}
	// search plugin initialisation (if any)
	for (i = 0; i < d.getElementsByName('PluginInit').length; i++) {
		Cmd = d.getElementsByName('PluginInit')[i].value;
		eval (Cmd);
	}
}
/*-------------------------------------------------------------------
20050825
Catch mouse events
---------------------------------------------------------------------*/
function GetMouse(e) {
	x = (bNavNS) ? e.pageX : event.x + document.body.scrollLeft;
	y = (bNavNS) ? e.pageY : event.y + document.body.scrollTop;
	return false;
}

