
function SmartOuverture(who,Brothers,ClickFx) {
	if (who.nextSibling.nodeName=="DD") {var Sister=who.nextSibling;}
	else if (who.nextSibling.nextSibling.nodeName=="DD") {var Sister=who.nextSibling.nextSibling;}
	if (ClickFx==1) {
	 if(document.all){
	  who.onmouseover=function() {this.className+=" over";}
	  who.onmouseout=function() {this.className=this.className.replace(" over", "");}
	 }
		who.onclick=function() {
			who.className=who.className=="on"?"off":"on";
			Sister.className=Sister.className=="on"?"off":"on";
		}
	} else {
		who.onclick=function() {
			for (a=0;a<Brothers.length;a++) {
				if (Brothers[a].nodeName=="DT") {Brothers[a].className="";}
				else if (Brothers[a].nodeName=="DD") {Brothers[a].className="off";}
			}
			who.className="on";
			Sister.className=(Sister.className=="on"||Sister.className==" on")?"":"on";
		}
	}
}	

/* ______________________[ 06 | Gestion de l’ouverture/fermeture d’une liste « <dl/> » ]________________________ */

/* Ce script est utilisé lorsque chaque « <dt/> » à l’intérieur d’un onglet doit ouvrir/fermer le « <dd/> » correspondant.
Il y a une gestion d’état « on ». Deux fonctionnalités cohabitent : par exemple « SmartDL("listeDynamique",0,"FAQ",0,"Guides",1); » 
le premier argument de cette fonction est l’ID de la <dl/> à rendre interactive, le chiffre qui suit (0 ou 1) définit le type de fonctionnalité :
pour « 0 », un clic sur un <dt/> provoque l’ouverture du <dd/> associé ET la fermeture de tous les autres <dd/>. Pour « 1 », un clic sur
un <dt/> provoque l’ouverture/fermeture du <dd/> associé selon son état au moment du clic, les autres <dd/> ne bougent pas. */

function SmartDL() {
	var args=SmartDL.arguments;
	for (n=0;n<args.length;n+=2) {
		var ClickFx=args[n+1];
		if (document.getElementById&&document.getElementById(args[n])) {
			var root=document.getElementById(args[n]).childNodes;
			for (a=0;a<root.length;a++) {
				if (root[a].nodeName=="DT"&&root[a].className!="on") {
					if (root[a].nextSibling.nodeName=="DD") {var Sister=root[a].nextSibling;}
					else if (root[a].nextSibling.nextSibling.nodeName=="DD") {var Sister=root[a].nextSibling.nextSibling;}
					Sister.className="off";
				}
				if (root[a].nodeName=="DT"&&root[a].className=="on") {
					if (root[a].nextSibling.nodeName=="DD") {var Sister=root[a].nextSibling;}
					else if (root[a].nextSibling.nextSibling.nodeName=="DD") {var Sister=root[a].nextSibling.nextSibling;}
					Sister.className="on";
				} 
			}
			for (a=0;a<root.length;a++) {
				if (root[a].nodeName=="DT") {SmartOuverture(root[a],root,ClickFx);}
			}
		}
	}
}


function textePlus(){
	var main_element = null;
	if( document.getElementById){
		main_element = document.getElementById("wrapper");
	}else if( document.all){
		main_element = document.all["wrapper"];
	}
	if (main_element!=null) {
		var sizestr=main_element.style.fontSize.substring(0,main_element.style.fontSize.length-1);
		sizeInt = sizestr!=""?parseInt(sizestr):100;
		sizeInt += 10;
		main_element.style.fontSize=""+sizeInt+"%";
	}
}
function texteMoins(){
	var main_element = null;
	if( document.getElementById){
		main_element = document.getElementById("wrapper");
	}else if( document.all){
		main_element = document.all["wrapper"];
	}
	if (main_element!=null) {
		var sizestr=main_element.style.fontSize.substring(0,main_element.style.fontSize.length-1);
		sizeInt = sizestr!=""?parseInt(sizestr):100;
		sizeInt -= 10;
		main_element.style.fontSize=""+sizeInt+"%";
	}
}
function directPrint(){
	if (window.print) self.print();
}


/* ______________________[ 06 | Interactivité carte du département ]________________________ */

function SmartCarte(cible) {
	if (document.getElementById&&document.getElementById(cible)) {
		var root=document.getElementById(cible).getElementsByTagName("AREA");
		for (a=0;a<root.length;a++) {
			if (root[a].nodeName=="AREA") {
				root[a].onmouseover=function() {
					var divid="d"+this.id.substring(1,this.id.length);
					SmartShowHide(divid);
				}
				root[a].onmouseout=function() {
					var divid="d"+this.id.substring(1,this.id.length);
					SmartShowHide(divid);
				}
			}
		}
	}
}

function SmartShowHide(who) {
	var div=document.getElementById(who);
	div.className=div.className==""?"over":"";
	if (document.getElementById("arrow")) {
		var pArrow=document.getElementById("arrow");
		pArrow.className=pArrow.className==""?who:"";
	}
}


/* ______________________[ 07 | <select/> au clavier ]________________________ */

/* Thanks goes to Cameron Adams from http://www.themaninblue.com/ */

function initSelect(whichSelect) {
	if (document.getElementById&&document.getElementById(whichSelect)) {
		var theSelect=document.getElementById(whichSelect);
		theSelect.changed=false;
		theSelect.onfocus=selectFocussed;
		theSelect.onchange=selectChanged;
		theSelect.onkeydown=selectKeyed;
		theSelect.onclick=selectClicked;
		return true;
	}
}

function selectChanged(theElement) {
	var theSelect;
	if (theElement&&theElement.value) {
		theSelect=theElement;
	} else {
		theSelect=this;
	}
	if (!theSelect.changed) {
		return false;
	}
	if (theSelect.value&&theSelect.value!="0") window.location=theSelect.value;
	return true;
}

function selectClicked() {
	this.changed=true;
}

function selectFocussed() {
	this.initValue=this.value;
	return true;
}

function selectKeyed(e){
	var theEvent;
	var keyCodeTab="9";
	var keyCodeEnter="13";
	var keyCodeEsc="27";
	if (e) {
		theEvent=e;
	} else {
		theEvent=event;
	}
	if ((theEvent.keyCode==keyCodeEnter||theEvent.keyCode==keyCodeTab)&&this.value!=this.initValue) {
		this.changed=true;
		selectChanged(this);
	} else if (theEvent.keyCode==keyCodeEsc) {
		this.value=this.initValue;
	} else {
		this.changed=false;
	}
	return true;
}

function SmartCarte(cible) {
	if (document.getElementById&&document.getElementById(cible)) {
		var root=document.getElementById(cible).getElementsByTagName("AREA");
		for (a=0;a<root.length;a++) {
			if (root[a].nodeName=="AREA") {
				root[a].onmouseover=function() {
					var divid="d"+this.id.substring(1,this.id.length);
					SmartShowHide(divid);
				}
				root[a].onmouseout=function() {
					var divid="d"+this.id.substring(1,this.id.length);
					SmartShowHide(divid);
				}
			}
		}
	}
}

/* ______________________[ 06 | Interactivité carte du département ]________________________ */

function SmartCarte(cible) {
	if (document.getElementById&&document.getElementById(cible)) {
		var root=document.getElementById(cible).getElementsByTagName("AREA");
		for (a=0;a<root.length;a++) {
			if (root[a].nodeName=="AREA") {
				root[a].onmouseover=function() {
					var divid="d"+this.id.substring(1,this.id.length);
					SmartShowHide(divid);
				}
				root[a].onmouseout=function() {
					var divid="d"+this.id.substring(1,this.id.length);
					SmartShowHide(divid);
				}
			}
		}
	}
}

function SmartShowHide(who) {
	var div=document.getElementById(who);
	div.className=div.className==""?"over":"";
	if (document.getElementById("arrow")) {
		var pArrow=document.getElementById("arrow");
		pArrow.className=pArrow.className==""?who:"";
	}
}

/* ______________________[ 04 | Miscellaneous ]________________________ */

function SmartRescueForm() {
	var args=SmartRescueForm.arguments;
	for (n=0;n<args.length;n++) {
		var cibleSelectName=args[n];
		if (document.getElementById&&document.getElementById(cibleSelectName)) {
			var cibleSelect=document.getElementById(cibleSelectName);
			cibleSelect.className="show";
		}
	}
}
/* ______________________[ 05 | Appel des fonctions dans le onlad de la page ]________________________ */

window.onload=function() {	
	SmartDL("FAQ",1);
	SmartCarte("Map");
	SmartRescueForm("metierSelect","canton","conseiller","adminSelect","cartoSelect");
	initSelect("canton");
	initSelect("conseiller");
}	
