/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
|
|		Copyright (c) 2007 France Galop
|		Design + HTML/CSS/DOM JavaScript : Smart Agence
|		http://www.smartagence.com/
|
\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */


/* ______________________[ 01 | Interactivité des menus (menus horizontaux) ]________________________ */

/* A special thanks goes to Eric Shepherd for his ALA article about “Hybrid CSS Dropdowns”: http://www.alistapart.com/articles/hybrid/
and to Patrick Griffiths and Dan Webb for their htmldog.com article “Sons of Suckerfish”: http://www.htmldog.com/articles/suckerfish/ */

function SmartHover() {
	var args=SmartHover.arguments;
	for (n=0;n<args.length;n++) {
		if (document.getElementById&&document.getElementsByTagName&&document.getElementById(args[n])) {
			navRoot=document.getElementById(args[n]).getElementsByTagName("LI");
			for (i=0;i<navRoot.length;i++) {
				node=navRoot[i];
				node2=navRoot[i].getElementsByTagName("UL");
				if (document.all) {
					if(node.id=="") {
						node.onmouseover=function() {this.id="over";}
						node.onmouseout=function() {this.id=this.id.replace("over", "");}
					} else {
						node.onmouseover=function() {this.className+=" over";}
						node.onmouseout=function() {this.className=this.className.replace(" over", "");}
					}
				}
				for (j=0;j<node2.length;j++) {
					node.className="gen";
				}
			}
		}
	}
}

function SmartHover2() {
	var args=SmartHover2.arguments;
	for (n=0;n<args.length;n++) {
		if (document.getElementById&&document.getElementsByTagName&&document.getElementById(args[n])) {
			navRoot=document.getElementById(args[n]).getElementsByTagName("LI");
			for (k=0;k<navRoot.length;k++) {
				nodeS=navRoot[k];
				var nodeS2=navRoot[k].getElementsByTagName("UL");
				if (document.all) {
					nodeS.onmouseover=function() {this.className+=" over";}
					nodeS.onmouseout=function() {this.className=this.className.replace(" over", "");}
				}
				if (nodeS2[0]) {
					var pos=document.all?nodeS2[0].offsetHeight-25:nodeS2[0].offsetHeight-10;
					nodeS2[0].style.marginTop="-"+pos+"px";
					var pos2=document.all?nodeS2[0].parentNode.firstChild.offsetWidth+162:162;
					nodeS2[0].style.marginLeft="-"+pos2+"px";
				}
			}
		}
	}
}

function SmartPos() {
	var args=SmartPos.arguments;
	for (m=0;m<args.length;m++) {
		if (document.getElementById&&document.getElementsByTagName&&document.getElementById(args[m])) {
			navBase=document.getElementById(args[m]).getElementsByTagName("UL");
			navLI=navBase[0].childNodes;r=0;
			var pos=navBase[0].offsetHeight+79;
			navBase[0].style.margin="-"+pos+"px 0 0 0";
		}
	}
}


/* ______________________[ 02 | Lancement d’une impression pour les navigateurs compatibles ]________________________ */

function DirectPrint() {
	if (window.print) self.print();
}


/* ______________________[ 03 | Gestion de la taille du texte d’un article ]________________________ */

/* Ce script modifie la taille du texte contenu dans <div id="bloc_txt"/>. Si JavaScript n’est pas activé ou si les méthodes
ne sont pas supportées, il ne se passera rien mais cela ne provoquera pas d’erreur. */

function SmartSize() {
	if (document.getElementById&&document.getElementById("TaillePlus")&&document.getElementById("TailleMoins")&&document.getElementById("ColContenu")) {
		var cibleplus=document.getElementById("TaillePlus");
		var ciblemoins=document.getElementById("TailleMoins");
		var cibletxt=document.getElementById("ColContenu");
		cibleplus.onclick=function() {
			var sizestr=cibletxt.style.fontSize.substring(0,cibletxt.style.fontSize.length-2);
			var sizeinter=cibletxt.style.lineHeight.substring(0,cibletxt.style.lineHeight.length-2);
			sizestr=sizestr!=""?parseInt(sizestr):11;
			sizeinter=sizeinter!=""?parseInt(sizeinter):15;
			if (sizestr<40) {
			cibletxt.style.fontSize=sizestr+1+"px";
			cibletxt.style.lineHeight=sizeinter+1+"px";
			}
		}
		ciblemoins.onclick=function() {
			var sizestr=cibletxt.style.fontSize.substring(0,cibletxt.style.fontSize.length-2);
			var sizeinter=cibletxt.style.lineHeight.substring(0,cibletxt.style.lineHeight.length-2);
			sizestr=sizestr!=""?parseInt(sizestr):11;
			sizeinter=sizeinter!=""?parseInt(sizeinter):15;
			if (sizestr!=0) {
			cibletxt.style.fontSize=sizestr-1+"px";
			cibletxt.style.lineHeight=sizeinter-1+"px";
			}
		}
	}
}


/* ______________________[ 04 | Miscellaneous ]________________________ */

function OpenPopup(url,nom,option) {
	window.open(url,nom,option);
}

/* */
function SmartNavTd() {
	if (document.getElementById&&document.getElementsByTagName&&document.getElementById("NavigationSecondaire")) {
		var sfEls=document.getElementById("NavigationSecondaire").getElementsByTagName("TD");
		for (var i=0;i<sfEls.length;i++) {
			if (sfEls[i].className=="last_nav2"||sfEls[i].className=="last_nav2 on") {
				sfElsUL=sfEls[i].getElementsByTagName("UL");
				for (var j=0;j<sfElsUL.length;j++) {
					sfElsUL[j].style.marginLeft=document.all?"-"+(sfElsUL[j].offsetWidth-sfEls[i].offsetWidth+1)+"px":"-"+(sfElsUL[j].offsetWidth-sfEls[i].offsetWidth)+"px";
				}
			}
			if (document.all) {
				sfEls[i].onmouseover=function() {
					this.className+=" over";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

	/*************************************************************************
		  This code is from Dynamic Web Coding at www.dyn-web.com
		  Copyright 2001-4 by Sharon Paine
		  See Terms of Use at www.dyn-web.com/bus/terms.html
		  regarding conditions under which you may use this code.
		  This notice must be retained in the code as is!
		*************************************************************************/
		function initScrollLayer() {
			// arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll,
			// if horizontal scrolling, id of element containing scrolling content (table?)
			var wndo = new dw_scrollObj('wn', 'lyr1');

			// bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
			// wndo.bSizeDragBar = false;

			// arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
			// (x/y offsets of dragBar in track)
			wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);

			// pass id('s) of scroll area(s) if inside table(s)
			// i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
			dw_scrollObj.GeckoTableBugFix('wn');
			/*if (document.getElementById&&document.getElementById('lyr1')&&document.getElementById('lyr1').offsetHeight<=155) {
				document.getElementById('scrollbar').style.display="none";
			}*/
		}

		function initScrollLayer2() {
			var wndo = new dw_scrollObj('wn2', 'lyr2');
			wndo.setUpScrollbar("dragBar2", "track2", "v", 1, 1);
			dw_scrollObj.GeckoTableBugFix('wn2');
			/*if (document.getElementById&&document.getElementById('lyr2')&&document.getElementById('lyr1').offsetHeight<=155) {
				document.getElementById('scrollbar').style.display="none";
			}*/
		}

/* ______________________[ 05 | Scroll ]________________________ */

/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-4 by Sharon Paine
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/
function initScrollLayer() {
	// arguments: id of layer containing scrolling layers (clipped layer), id of layer to scroll,
	// if horizontal scrolling, id of element containing scrolling content (table?)
	var wndo = new dw_scrollObj('wn', 'lyr1');

	// bSizeDragBar set true by default (explained at www.dyn-web.com/dhtml/scroll/ )
	// wndo.bSizeDragBar = false;

	// arguments: dragBar id, track id, axis ("v" or "h"), x offset, y offset
	// (x/y offsets of dragBar in track)
	wndo.setUpScrollbar("dragBar", "track", "v", 1, 1);

	// pass id('s) of scroll area(s) if inside table(s)
	// i.e., if you have 3 (with id's wn1, wn2, wn3): dw_scrollObj.GeckoTableBugFix('wn1', 'wn2', 'wn3');
	dw_scrollObj.GeckoTableBugFix('wn');
	/*if (document.getElementById&&document.getElementById('lyr1')&&document.getElementById('lyr1').offsetHeight<=155) {
		document.getElementById('scrollbar').style.display="none";
	}*/
}

function initScrollLayer2() {
	var wndo = new dw_scrollObj('wn2', 'lyr2');
	wndo.setUpScrollbar("dragBar2", "track2", "v", 1, 1);
	dw_scrollObj.GeckoTableBugFix('wn2');
	/*if (document.getElementById&&document.getElementById('lyr2')&&document.getElementById('lyr1').offsetHeight<=155) {
		document.getElementById('scrollbar').style.display="none";
	}*/
}

/* ______________________[ 06 | Plan du site "tout afficher / tout masquer" ]________________________ */


function SmartOpenClose(){
  var args=SmartOpenClose.arguments;
  var uls = document.getElementsByTagName('ul');
  var lis = document.getElementsByTagName('li');

  for (n=0;n<args.length;n++) {
    if (document.getElementById&&document.getElementsByTagName&&document.getElementById(args[n])) {
  	navRoot=document.getElementById(args[n]).getElementsByTagName("A");
  	 for (z=0;z<navRoot.length;z++) {
      navRoot[z].onclick = function () {
          for(var i = 0; i < uls.length; ++i){
    				if (uls[i].className=='treeview'){
    				  navChildren=uls[i].getElementsByTagName("LI");
  				    for(e= 0; e < navChildren.length; e++){
                if (navChildren[e].className!=="aq3bullet"){
                  navChildren[e].className=this.className=="all"?"aq3open":"aq3closed";
                }
              }
            }
          }
        }
      }
    }
  }
}


/* ______________________[ 07 | Lancement des scripts ]________________________ */

window.onload=function() {
	SmartSize();
	SmartHover("NavigationPrincipale", "NavPrincipaleAccueil", "NavigationSecondaire");
	SmartPos("NavItem3","NavItem103","NavItem2");
	SmartHover2("menuInterneA", "menuInterneB");
	SmartNavTd("NavigationSecondaire");
	SmartOpenClose("PlanAll");
	if(document.getElementById&&document.getElementById('lyr1')) initScrollLayer();
	if(document.getElementById&&document.getElementById('lyr2')) initScrollLayer2();
}


/* ______________________[ 08 | blocage du patch Internet Explorer ActiveX update (bordure grise sous IE autour de l'animation flash)  ]________________________ */

function flash(tag) {
	document.write(tag);
}

/* ______________________[ 09 | Plan du site ]________________________ */

/*
aqtree3clickable.js

Converts an unordered list to an explorer-style tree, with clickable
icons

To make this work, simply add one line to your HTML:
<script type="text/javascript" src="aqtree3clickable.js"></script>

and then make the top UL of your nested unordered list of class
"aqtree3clickable".

That's it. No registration function, nothing.

http://www.kryogenix.org/code/browser/aqlists/

Stuart Langridge, November 2002
sil@kryogenix.org

Inspired by Aaron's labels.js (http://youngpup.net/demos/labels/) and Dave Lindquist's menuDropDown.js (http://www.gazingus.org/dhtml/?id=109)

*/

addEvent(window, "load", makeTreesC);

function makeTreesC() {
     // We don't actually need createElement, but we do
    // need good DOM support, so this is a good check.
    if (!document.createElement) return;

    uls = document.getElementsByTagName("ul");
    for (uli=0;uli<uls.length;uli++) {
        ul = uls[uli];
        if (ul.nodeName == "UL" && ul.className == "treeview") {
            processULELC(ul);
        }

	 }
}

function processULELC(ul) {
    if (!ul.childNodes || ul.childNodes.length == 0) return;
    // Iterate LIs
    for (var itemi=0;itemi<ul.childNodes.length;itemi++) {
        var item = ul.childNodes[itemi];
        if (item.nodeName == "LI") {
            // Iterate things in this LI
            var a;
            var subul;
	    subul = "";
            for (var sitemi=0;sitemi<item.childNodes.length;sitemi++) {
                var sitem = item.childNodes[sitemi];
                switch (sitem.nodeName) {
                    case "A": a = sitem; break;
                    case "UL": subul = sitem;
                               processULELC(subul);
                               break;
                }
            }
            if (subul) {
                associateELC(a,subul);
            } else {
                a.parentNode.className = "aq3bullet";
            }
        }
    }
}

function associateELC(a,ul) {

     if (a.parentNode.className.indexOf('aq3open') == -1)
      a.parentNode.className = 'aq3closed';
    a.onclick = function () {
        this.parentNode.className = (this.parentNode.className=='aq3open') ? "aq3closed" : "aq3open";
        return false;
	 }
}

/*              Utility functions                    */

function addEvent(obj, evType, fn){
  /* adds an eventListener for browsers which support it
     Written by Scott Andrew: nice one, Scott */
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
  } else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
	return false;
  }
}

function SelectVisible(v,elem) {
  var agt = navigator.userAgent.toLowerCase();
  var isMac = (agt.indexOf('mac') != -1);
  var isOpera = (agt.indexOf('opera') != -1);
  var IEver = parseInt(agt.substring(agt.indexOf('msie ') + 5));
  var isIE = ((agt.indexOf('msie')!=-1 && !isOpera && (agt.indexOf('webtv')==-1)) && !isMac);
  var isIE5win = (isIE && IEver >= 5);
  var isIE5mac = ((agt.indexOf('msie') != -1) && isMac);
  var isSafari = (agt.indexOf('safari') != -1);

   if (isIE||isIE5win)
      for (var i=0;i<elem.length;i++) elem[i].style.visibility=v;
}

$(document).ready(function() {
	if( $('#lyr1').height() < 305 ) {
		$('#scrollLinks').hide();
	}
});