function dumpXML(Pxml) {
	var fTexteCont = document.createElement("p");
	var fTexte = document.createTextNode("");
	fTexteCont.appendChild(fTexte);
	var Fstr = '';
	Fstr = doNode(Pxml, Fstr);
	return Fstr;
	
	function doNode(Pnode, Pstr) {
		var Ftype = Pnode.nodeType;
		if (Ftype == 1) {
			var Ftagname = Pnode.tagName.toLowerCase();
			Pstr += '<' + Ftagname;
			var Fatt = Pnode.attributes;
			for (var i=0; i < Fatt.length; i++) {
				var Latt = Fatt.item(i);
				var Lval = Latt.nodeValue;
				if (Lval == null || Lval.toString().length == 0) continue;
				var Lname = Latt.nodeName.toLowerCase();
				if (Lname == "style") continue;
				//if (Lname == "href") alert(Lval);
				fTexte.nodeValue = Lval;
				Lval = fTexteCont.innerHTML;
				Pstr += ' ' + Lname + '="' + Lval + '"';
			}
			if (Ftagname == "img") {
				//Pnode.src = "blank.gif";
				Pnode.removeAttribute('src');
			}
			if (Pnode.style.cssText != null && Pnode.style.cssText.toString().length > 0) Pstr += ' style="' + Pnode.style.cssText + '"';
			
			var Fchilds = Pnode.childNodes;
			if (Fchilds.length == 0) {
				if (Ftagname == "title") {
					Pstr += ">" + Pnode.innerHTML + "</title>"; // another wonderful ie6 bug...
				} else Pstr += ' />';
			} else {
				Pstr += '>';
				for (var i = 0; i < Fchilds.length; i++) {
					Pstr = doNode(Fchilds.item(i), Pstr);
				}
				Pstr += '</' + Ftagname + '>';
			}
		} else if (Ftype == 3) {
			Pstr += Pnode.nodeValue;
		}
		return Pstr;
	}
}

function flashLoaded() {
}

function getQuery() {
	var fLoc = document.location.toString();
	var fParams = {};
	var fStart = fLoc.indexOf("?");
	if (fStart < 0) return fParams;
	var fEnd = fLoc.indexOf("#");
	if (fEnd < 0) fEnd = fLoc.length;
	var fQuery = fLoc.substring(fStart+1, fEnd);
	var fSplit = fQuery.split("&");
	for (var i=0; i < fSplit.length; i++) {
		var lSplit = fSplit[i].split("=");
		var lLeft = decodeURIComponent(lSplit[0]);
		if (lSplit.length == 2) fParams[lLeft] = decodeURIComponent(lSplit[1]);
		else fParams[lLeft] = true;
	}
	return fParams;
}

function goFlash(pForce) {
	var fLoc = document.location.toString();
	var fForceflash = fLoc.indexOf("forceflash=");
	if (pForce == true && fForceflash < 0) {
		var fDiese = fLoc.indexOf("#");
		if (fDiese > 0) {
			fLoc = fLoc.substring(0, fDiese);
			fDiese = fLoc.substring(fDiese);
		} else fDiese = "";
		var fParam = fLoc.indexOf('noflash=');
		if (fParam > 0) {
			fParam += 8;
			fLoc = fLoc.substring(0, fParam) + "0" + fLoc.substring(fParam+1);
		} else if (fLoc.indexOf("?") > 0) {
			fLoc += "&noflash=0";
		} else {
			fLoc += "?noflash=0";
		}
		document.location = fLoc + fDiese;
		return;
	}

	var fCookie = document.cookie.toString();
	var fNoflash = 0;
	try {
		if (isAdmin()) fNoflash = 1;
		else if (fCookie != null && fCookie.length > 0) {
			fPos = fCookie.indexOf("noflash");
			if (fPos >=0 ) {
				fNoflash = parseInt(fCookie.charAt(fPos+8));
			}
		}
	} catch (e) {
			
	}
	
	if (fForceflash > 0) fNoflash = parseInt(fLoc.charAt(fForceflash + 11));
	
	if (fNoflash == 0) {
		var Fversionfull = swfobject.getFlashPlayerVersion();
		var Fversion = Fversionfull['major'];
		if (Fversion < 6) return;
		if (Fversion >= 10) {
			gFlashStarted = true;
			var Fflashcontent = document.getElementById("content");
			try {
				if (window.stop !== undefined) window.stop();
				else if (document.execCommand !== undefined) document.execCommand("Stop", false);
				if (window.status !== undefined) window.status = "";
			} catch (e) {}
			var Fdata = dumpXML(document.documentElement);
			Fflashcontent.innerHTML = "<div id='htmlRender'></div>";
			var fFlashvars = {
				'flashData' : encodeURIComponent(Fdata),
				'siteVersion' : gSiteVersion,
				'documentLocation' : encodeURIComponent(fLoc),
				'cookie' : encodeURIComponent(document.cookie)
			};
			var fParams = {
				'bgcolor' : "#FFFFFF",
				'scale' : "noscale",
				'salign' : "TL",
				'allowScriptAccess' : "always"
			};
			var fAttributes = {
				'SWLIVECONNECT' : "true"
			};
			swfobject.embedSWF("htmlRender.swf", "htmlRender", "100%", "100%", "10.0.0", "expressInstall.swf", fFlashvars, fParams, fAttributes);
			// htmlRender will manage scrollbar, so hide it.
			document.body.style.overflow = "hidden";
			EdaHistory.start(callFlash);
		} else {
			var fPlease = document.getElementById("updateFlash");
			fPlease.insertBefore(document.createTextNode(Fversion), fPlease.lastChild.previousSibling);
			fPlease.style.display = "block";
		}
	} else {
		// call stats...
		
	}
}

var gFlashUrl;
function setFlashUrl(pUrl, pTitle) {
	var fTitle = decodeURIComponent(decodeURIComponent(pTitle));
	gFlashUrl = decodeURIComponent(decodeURIComponent(pUrl));
	EdaHistory.set(gFlashUrl, fTitle);
}

function callFlash(pUrl) {
	var fSwfObject = window.parent.document.getElementById("htmlRender");
	if (fSwfObject == null) return;
	if (pUrl == null) pUrl = "";
	fSwfObject.SetVariable("gotoURL", pUrl);
	gFlashUrl = pUrl;
}


function getViewport() {
	var viewportwidth;
	var viewportheight;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth;
		viewportheight = window.innerHeight;
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0) {
		viewportwidth = document.documentElement.clientWidth;
		viewportheight = document.documentElement.clientHeight;
	}
	// older versions of IE
	else {
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		viewportheight = document.getElementsByTagName('body')[0].clientHeight;
	}
	return [viewportwidth, viewportheight];
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

function isAdmin() {
	var fCookie = document.cookie.toString();
	var fLogged = false;
	try {
		if (fCookie != null && fCookie.length > 0) {
			var fPos = fCookie.indexOf("admin=");
			if (fPos >= 0) {
				if (parseInt(fCookie.charAt(fPos+6)) > 0) {
					fLogged = true;
				}
			}
		}
	} catch (e) {}
	return fLogged;
}


function showSearchBar(pNode) {
	show('recherche');
	searchFlashInstall();
	captureEnterSearch();
	document.getElementById('searchInput').focus();
	return false;
}

function searchFlashInstall() {
	loadGoogleUDS();
}

function captureEnterSearch() {
	document.onkeydown = function(e) {
		var fCode;
		if (!e) var e = window.event;
		if (e.keyCode) fCode = e.keyCode;
		else if (e.which) fCode = e.which;
		if (fCode == 13) {
			googleSearch();
			return false;
		} else {
			document.getElementById("searchInput").style.backgroundColor = "#FFFFFF";
		}
	}
}

function loadGoogleUDS() {
	var fFrame = document.getElementById("googleFrame");
	if (fFrame != null) return;
	
	fFrame = document.createElement("iframe");
	fFrame.src = "searchframe";
	fFrame.setAttribute('id', "googleFrame");
	fFrame.style.visibility = "hidden";
	fFrame.style.display = "block";
	fFrame.style.position = "absolute";
	fFrame.style.width = "0px";
	fFrame.style.height = "0px";
	fFrame.style.top = "0px";
	fFrame.style.left = "0px";
	document.body.appendChild(fFrame);
}

function tryFlashSearch(pText) {
	try {
		googleFlashSearch(pText);
	} catch (e) {
		alert(e.toString());
	}
}

function trySearch() {
	try {
		googleSearch();
	} catch (e) {
		alert(e.toString());
	}
	return false;
}

function hide(pId) {
	if (typeof(pId) == "string") pId = document.getElementById(pId);
	pId.style.visibility = "hidden";
}

function show(pId) {
	if (typeof(pId) == "string") pId = document.getElementById(pId);
	pId.style.visibility = "visible";
}

function toggleHide(pId, pNum) {
	if (typeof(pId) == "string") pId = document.getElementById(pId);
	var fKey = '_savevisibility' + pNum;
	if (pId[fKey] != null) {
		pId.style.visibility = pId[fKey] ? "visible" : "hidden";
		delete pId[fKey];
	} else {
		pId[fKey] = getVisibility(pId);
		pId.style.visibility = "hidden";
	}
}

function getVisibility(pNode) {
	var fVisible = false;
	if (window.getComputedStyle) {
        if (window.getComputedStyle(pNode, null).visibility == "visible") fVisible = true;
    } else if (pNode.currentStyle) {
		if (pNode.currentStyle['visibility'] == "visible") fVisible = true;
	}
	return fVisible;
}

function toggleShow(pId, pDropdown) {
	if (typeof(pId) == "string") pId = document.getElementById(pId);
	if (!getVisibility(pId)) pId.style.visibility = "visible";
	else pId.style.visibility = "hidden";
}

function toggleHeight(pId, pHeight) {
	if (typeof(pId) == "string") pId = document.getElementById(pId);
	pHeight = pHeight + "px";
	if (pId.style.height == pHeight) pId.style.height = "0px";
	else pId.style.height = pHeight;
}

function inputSearchFocus(pNode) {
	pNode.select();
}

function inputSearchBlur(pNode) {
	if (pNode.value == "") pNode.value = pNode.defaultValue;
}

function hasClass(pNode, pClass) {
	var fClass = pNode.className.split(" ");
	for (var i=0, n=fClass.length; i <n; i++) {
		if (fClass[i] == pClass) return true;
	}
	return false;
}

function previousSibling(pNode) {
	var fPrev = pNode.previousSibling;
	while (fPrev != null) {
		if (fPrev.nodeType == 1) return fPrev;
		fPrev = fPrev.previousSibling;
	}
	return null;
}
if (!document.getElementsByClassName) document.getElementsByClassName = function(strClassName) {
	var arrElements = document.all;
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for (var i=0,n=arrElements.length; i < n; i++){
		oElement = arrElements[i];
		if (oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}   
	}
	return arrReturnElements;
};

function initSliders() {
	var fSlides = document.getElementsByClassName('slider');
	for (var i=0, n=fSlides.length; i < n; i++) {
		var lSlide = fSlides[i];
		var lPrev = previousSibling(lSlide);
		if (lPrev && hasClass(lPrev, 'slider')) lSlide.style.display = "none";
	}
}

var gMapLocalisation, gMapFrame, gMapDiv;
function loadGoogleMaps(pLat, pLon, pLocalisation) {
	if (!pLocalisation) return;
	gMapLocalisation = [pLat, pLon, pLocalisation];
	if (gMapFrame != null) return;
	else {// refresh map
	}
	gMapFrame = document.createElement("iframe");
	gMapFrame.className = "googleMaps";
	gMapFrame.src = "googleMaps";
	gMapFrame.frameBorder = 0;
	gMapDiv = document.getElementById("googleMap");
	if (gMapDiv != null) {
		updatePositionGoogleMaps();
		window.onresize = updatePositionGoogleMaps;
	}
	document.body.appendChild(gMapFrame);
	var fPosition = "";
	if (window.getComputedStyle){
		fPosition = window.getComputedStyle(gMapFrame, null).position;
	} else if (gMapFrame.currentStyle){
		fPosition = gMapFrame.currentStyle["position"];
	}
	if (fPosition == "fixed") {
		window.onscroll = updatePositionGoogleMapsScroll;
	}
}
function unloadGoogleMaps() {
	if (gMapFrame != null) {
		window.onscroll = null;
		window.onresize = null;
		gMapFrame.parentNode.removeChild(gMapFrame);
		gMapFrame = null;
	}
}
window.top.getMapLocalisation = function() {
	return gMapLocalisation;
};
function positionGoogleMaps(pX, pY) {
	gMapFrame['_absx'] = pX;
	gMapFrame['_absy'] = pY;
	gMapFrame.style.top = pY + "px"; // borders
	gMapFrame.style.left = pX + "px";
}
function updatePositionGoogleMaps() {
	var fPos = getPagePosition(gMapDiv);
	positionGoogleMaps(fPos[0], fPos[1]);
}
function updatePositionGoogleMapsScroll() {
	var fTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	var fLeft = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft;
	gMapFrame.style.top = (gMapFrame['_absy'] - fTop) + "px"; // borders
	gMapFrame.style.left = (gMapFrame['_absx'] - fLeft) + "px";
}

function getPagePosition(pNode) {
	var fX = fY = 0;
	if (pNode.offsetParent) {
		do {
			fX += pNode.offsetLeft;
			fY += pNode.offsetTop;
		} while (pNode = pNode.offsetParent);
	}
	return [fX+1,fY];
}

var gState = 1;
var gSavedLayout = null;
function fixLayout() {
	initSliders();
	var fCenter = document.getElementById('centerv');
	if (gSavedLayout == null) gSavedLayout = {"top":fCenter.style.position, "marginTop":fCenter.style.marginTop, "position":fCenter.style.position};
	fixResize();
	window.onresize = fixResize;
}
function fixResize() {
	var fCenter = document.getElementById('centerv');
	var fContent = document.getElementById('content');
	if (fContent.offsetHeight > fCenter.offsetHeight + 102) { // 2xhauteur non comptée
		if (gState != 1) {
			fCenter.style.position = gSavedLayout.position;
			fCenter.style.marginTop = gSavedLayout.marginTop;
			fCenter.style.top = gSavedLayout.top;
			gState = 1;
		}
	} else {
		if (gState != 2) {
			fCenter.style.position = "relative";
			fCenter.style.marginTop = "0px";
			fCenter.style.top = "51px";
			gState = 2;
		}
	}
}

