var ie = document.all ? true : false;
var ns = (document.getElementById && !document.all)? true : false;
var compte = 0;
var maxx = 0;
var act = "";
var ob=Object;
function GetE( elementId ){
	return document.getElementById( elementId )  ;
}
function onoff(nom){
	if(GetE(nom)){
		if(GetE(nom).style.display=='none'){
			GetE(nom).style.display='block';
		}
		else{
			GetE(nom).style.display='none';
		}
	}
}
function afficheTTP(code){
	for(i=0;i<tabTTP.length;i++){
		if(code==tabTTP[i]){
			GetE('divTTP'+tabTTP[i]).style.display='block'
		}
		else{
			GetE('divTTP'+tabTTP[i]).style.display='none'
		}
	}
}
var act=racine+"img/espaceur.gif"


/*fonction zoom image pleine page*/
	var http;
	var NET = (navigator.userAgent.indexOf("Netscape")>-1) ? 1 : 0;
	var FF = (navigator.userAgent.indexOf("Firefox")>-1) ? 1 : 0;
	var SF = (navigator.userAgent.indexOf("Safari")>-1) ? 1 : 0;
	var IE6 = (navigator.userAgent.indexOf("MSIE 6")>-1) ? 1 : 0;
	var IE7 = (navigator.userAgent.indexOf("MSIE 7")>-1) ? 1 : 0;
	
	function getAbsoluteLeft(oNode){
		// Fonction prise chez microsoft pour ie
		if (IE6 || IE7) {
			var oCurrentNode=oNode;
		   	var iLeft=0;
		   	while(oCurrentNode.tagName!="BODY"){
		    	iLeft+=oCurrentNode.offsetLeft;
		    	oCurrentNode=oCurrentNode.offsetParent;
		  	}
		  	return iLeft;
		} 
		else return oNode.offsetLeft;
	}

	function getAbsoluteTop(oNode){
		// Fonction prise chez microsoft pour ie
		if (IE6 || IE7) {
			var oCurrentNode=oNode;
			var iTop=0;
			while(oCurrentNode.tagName!="BODY"){
		    	iTop+=oCurrentNode.offsetTop;
		    	oCurrentNode=oCurrentNode.offsetParent;
			}
		  	return iTop;
		}
		else return oNode.offsetTop;
	}
	
	function getHTTPObject() {
	  var xmlhttp;
	  // Pour IE
	  /*@cc_on
	  @if (@_jscript_version >= 5)
	    try {
	      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	      } catch (e) {
	      try {
	        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch (E) {
	        xmlhttp = false;
	        }
	      }
	  @else
	  xmlhttp = false;
	  @end @*/
	  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
	  	try {
	    	xmlhttp = new XMLHttpRequest();
	      	if (xmlhttp.overrideMimeType) {
    			 xmlhttp.overrideMimeType("text/xml");
   			}
	    } catch (e) {
	    	xmlhttp = false;
	    }
	  }
	  return xmlhttp;
	}
	var http = getHTTPObject();
	
	var img = document.createElement('img');

	
	function getWindowHeight() {
	    var windowHeight=0;
	    if (typeof(window.innerHeight)=='number') {
	        windowHeight=window.innerHeight;
	    }
	    else {
	     if (document.documentElement&&
	       document.documentElement.clientHeight) {
	         windowHeight = document.documentElement.clientHeight;
	    }
	    else {
	     if (document.body&&document.body.clientHeight) {
	         windowHeight=document.body.clientHeight;
	      }
	     }
	    }
	    return windowHeight;
	}
	
	function getWindowWidth() {
	    var windowWidth=0;
	    if (typeof(window.innerWidth)=='number') {
	        windowWidth=window.innerWidth;
	    }
	    else {
	     if (document.documentElement&&
	       document.documentElement.clientWidth) {
	         windowWidth = document.documentElement.clientWidth;
	    }
	    else {
	     if (document.body&&document.body.clientWidth) {
	         windowWidth=document.body.clientWidth;
	      }
	     }
	    }
	    return windowWidth;
	}
	
	/************************************ zoomMedia *******************************/
	var zoomTimeout = 30000; // Timeout permettant d'arreter le script de zoom si le fichier n'existe pas ou si il met trop de temps à charger;
	var zoomTime = 0;
	
	function onOffImg(onoff, monImage,monTitre,nb) {
		// !!! Ne pas oublier de définir le style de divZoom, divZoomContenu et imgZoom2 dans la css !!!
		if (document.getElementById('divZoom')) nodeZoom = document.getElementById('divZoom');
		else {
			var nodeZoom = document.createElement("div");
			nodeZoom.id = "divZoom";
		}
		if (document.getElementById('divZoomContenu')) nodeZoomContenu = document.getElementById('divZoomContenu');
		else {
			var nodeZoomContenu = document.createElement("div");
			nodeZoomContenu.id = "divZoomContenu";
		}

		nodeZoom.style.display = "block";
		//nodeZoomContenu.style.visibility = "hidden";
		if (IE6) {
			nodeZoom.style.position = "absolute";
			nodeZoomContenu.style.position = "absolute";
		}
		
		nodeZoomContenu.innerHTML = '<a href="#null" onclick="hideZoom();return false;"><img id="imgZoom2" src="'+monImage+'" alt="fermer" border="0"/></a><br /><br /><a href="#null" onclick="hideZoom();return false;">Fermer</a>';
		
		if (FF) nodeZoom.style.top = "0px";
		else nodeZoom.style.pixelTop = 0;
		if (FF) nodeZoomContenu.style.top = "0px";
		else nodeZoomContenu.style.pixelTop = 0;
		nodeZoomContenu.style.textAlign = "center";
		document.body.appendChild(nodeZoom);
		document.body.appendChild(nodeZoomContenu);
		nodeZoom.style.width = "100%";
		nodeZoom.style.height = "100%";
		nodeZoom.style.margin = "0px 0px 0px 0px";
		nodeZoom.style.padding = "10px 0px 0px 0px";
		nodeZoom.onclick = hideZoom;
		setTimeout("_preload()", 100);
	}
	
	function _preload() {
		if (!document.getElementById('imgZoom2').complete){
			zoomTime+=200;
			if (zoomTime<=zoomTimeout) setTimeout("_preload()", 200);
		} else {
			w = document.getElementById('imgZoom2').width;
			h = document.getElementById('imgZoom2').height;
			_resize();
			document.getElementById('divZoomContenu').style.display = "block";
			document.getElementById('divZoomContenu').style.visibility = "visible";
		}
	}
	
	function hideZoom() {
		GetE('divZoom').style.display = "none";
		GetE('divZoomContenu').style.visibility = "hidden";
		GetE('imgZoom2').style.display = "none";
		
	}
	
	function _resize() {
		if (document.getElementById('divZoomContenu') && document.getElementById('divZoom').style.display != "none") {
			document.getElementById('divZoomContenu').style.overflow = 'visible';
			var w = document.getElementById('imgZoom2').width;
			var h = document.getElementById('imgZoom2').height;
			var m = Math.floor(getWindowWidth()/2 - w/2);
			if (m<0) m="0px";
			else m+="px";
			document.getElementById('divZoomContenu').style.marginLeft = m;
			var m2 = Math.floor(getWindowHeight()/2 - h/2);
			if (m2<0) m2="0px";
			else m2+="px";
			document.getElementById('divZoomContenu').style.marginTop= m2;
			// Si l'image dépasse la taille de la page on affiche les scrolls supplémentaires
			if (w > getWindowWidth()) {
				document.getElementById('divZoomContenu').style.overflow = 'scroll';
				document.getElementById('divZoomContenu').style.width = (getWindowWidth()-15)+"px";
			}
			if (h > getWindowHeight()) {
				document.getElementById('divZoomContenu').style.overflow = 'scroll';
				document.getElementById('divZoomContenu').style.height = (getWindowHeight()-15)+"px";
			}
			if (IE6) IE6_resize(h, w);
		}
	}
	
	function IE6_resize(h, w) {
		document.getElementById('divZoom').style.width = getWindowWidth()+document.documentElement.scrollLeft + "px";
		document.getElementById('divZoom').style.height = getWindowHeight()+"px";
		document.getElementById('divZoom').style.top = document.documentElement.scrollTop;
		m = Math.floor(getWindowHeight()/2 - h/2)+document.documentElement.scrollTop;
		if (m<0) m = "0px";
		else m+= "px";
			
		m2 = Math.floor(getWindowWidth()/2 - w/2)+document.documentElement.scrollLeft;
		if (m2<0) m2 = "0px";
		else m2+= "px";
		document.getElementById('divZoomContenu').style.marginTop = m
		document.getElementById('divZoomContenu').style.marginLeft= m2;		
	}
	
	
	window.onresize = _resize;
	if (IE6) window.onscroll = _resize;	
	
	

	/********************************** fin zoomMedia *****************************/