// JavaScript Document

	function lib_bwcheck(){ //Browsercheck (needed)
		this.ver=navigator.appVersion
		this.agent=navigator.userAgent
		this.dom=document.getElementById?1:0
		this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
		this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
		this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
		this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
		this.ie=this.ie4||this.ie5||this.ie6
		this.mac=this.agent.indexOf("Mac")>-1
		this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
		this.ns4=(document.layers && !this.dom)?1:0;
		this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
		return this;
	}

	// If NS -- that is, !IE -- then set up for mouse capture
	var IE = document.all?true:false;
	//var Navig=navigator.appName;

	function RefreshPub()
	{
	
		 if(document.all)
		 {
			 //var iecontent = document.all[calque].innerHTML;
			 var iecontent = document.all.Layer_Pub.innerHTML;
			 //document.all[calque].innerHTML = iecontent;
			 document.all.Layer_Pub.innerHTML = iecontent;
		 }else{
		 
			 var nscontent = document.getElementById("Layer_Pub").innerHTML;
			 document.getElementById("Layer_Pub").innerHTML = nscontent;

		 }
	
	}

	//window.setInterval("RefreshPub()",20000); // 20 * 1000ms = 20 sec.
	function addFav(surl, stitre)
	{
		nav = navigator.appName;
		if (nav.substring(0,9)=="Microsoft") 
		window.external.AddFavorite(surl, stitre);
		else
		window.alert ("Pressez CTRL+D pour ajouter a vos favoris sous Mozilla/Netscape !");
	}	
	
	function OuvrePopup(nUrl){
		
		if (ns6 || ie56)  
	    	document.getElementById("Layer_Popup").style.visibility="visible";
		else if (ie4 || ie56) 
			document.all.Layer_Popup.style.visibility="visible";
		else if (ns4) 
			document.Layer_Popup.visibility="visible";

		var w = 400;
		var h = 400;
		var nScroll = 0;

		if (ns6 || ie56)  
	    	document.getElementById("Layer_Popup").resizeBy(w,h);
		else if (ie4 || ie56) 
			document.all.Layer_Popup.resizeBy(w,h);
		else if (ns4) 
			document.Layer_Popup.resizeBy(w,h);//ca cest le bon

	  // Centrer le popUp
		var x //= (screen.width) ? (screen.width-w)/2 : 0;
		var y //= (screen.height) ? (screen.height-h)/2 : 0;
		
		if (ns6 || ns4) {
			x = (window.innerWidth-w)/2;
			y = (window.innerHeight-h)/2;
          } else if (ie4 || ie56) {
			x = (screen.availWidth-w)/2; 
			y = (screen.availHeight-w)/2;
          }
		  
		if (ns6 || ie56) { 
            document.getElementById("Layer_Popup").style.left=x;
            document.getElementById("Layer_Popup").style.top=y;
          } else if (ie4) {
            document.all.Layer_Popup.style.left=x;
            document.all.Layer_Popup.style.left=y;
          } else if (ns4){ 
            document.Layer_Popup.left=x;  
            document.Layer_Popup.top=y; 
          }

		if (ns6 || ie56)  
	    	document.getElementById("Layer_Popup").load(nUrl,w);
		else if (ie4 || ie56) 
			document.all.Layer_Popup.load(nUrl,w);
		else if (ns4) 
			document.Layer_Popup.load(nUrl,w); //Ca cest le bon

	}
	
	function FermePopup(){
	
		if (ns6 || ie56)  
	    	document.getElementById("Layer_Popup").style.visibility="hidden";
		else if (ie4 || ie56) 
			document.all.Layer_Popup.style.visibility="hidden";
		else if (ns4) 
			document.Layer_Popup.visibility="hidden";
	}


	function openWin(nUrl,nNom)
	{
		var w = 400;
		var h = 400;

		if (nNom=='Diapo'){
			w = 700;
			h = 525;
		}
		if (nNom=='AddClient'){
			w = 750;
			h = 600;
		}
		if (nNom=='BureauVirtuel'){
			w = 1024;
			h = 768;
		}

		var nScroll = 0;
	
	  // Centrer le popUp
	  var winl = (screen.width) ? (screen.width-w)/2 : 0;
	  var wint = (screen.height) ? (screen.height-h)/2 : 0;
	  var options = 'width='+w+',height='+h+',top='+wint+',left='+winl+',scrollbars='+nScroll+',resizable=no';
	
	  // Ouvrir le popUp
		idFen=window.open(nUrl,nNom,options);
	
	  // Forcer le focus sur un PopUp déjà ouvert
	  if(idFen.window.focus){idFen.window.focus();}
//'resizable=yes,menubar=no,locationbar=no,toolbar=no,statusbar=no,directories=no,scrollbars=yes,width=375,height=350,top=25,left=25';
	}
	
	//	if (!IE) document.captureEvents(Event.MOUSEMOVE);


/*
	function lib_bwcheck(){ //Browsercheck (needed)
		this.ver=navigator.appVersion
		this.agent=navigator.userAgent
		this.dom=document.getElementById?1:0
		this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
		this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
		this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
		this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
		this.ie=this.ie4||this.ie5||this.ie6
		this.mac=this.agent.indexOf("Mac")>-1
		this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
		this.ns4=(document.layers && !this.dom)?1:0;
		this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
		return this;
	}
*/	
	var bw=lib_bwcheck();

	/********************************************************************************
	Object code...Object constructors and functions...
	********************************************************************************/
	function makeNewsObj(obj,nest,font,size,color,news,fadespeed,betweendelay,slidespeed,works,newsheight){
		nest=(!nest) ? "":'document.'+nest+'.'
		this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+"document.layers." +obj):0;	
		this.writeref=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj+".document"):0;
		if(font){this.color=new Array(); this.color=eval(color); this.news=new Array(); this.news=eval(news)
			this.font=font; this.size=size; this.speed=fadespeed; this.delay=betweendelay; this.newsheight=newsheight;
			this.fadeIn=b_fadeIn;this.fadeOut=b_fadeOut; this.newsWrite=b_newsWrite; this.y=1
			this.slideIn=b_slideIn; this.moveIt=b_moveIt; this.slideSpeed=slidespeed; this.works=works
			if(bw.dom || bw.ie4){this.css.fontFamily=this.font; this.css.fontSize=this.size; this.css.color=this.color[0]}
		}
		this.obj = obj + "Object"; 	eval(this.obj + "=this"); return this
	}
	
	// A unit of measure that will be added when setting the position of a layer.
	var px = bw.ns4||window.opera?"":"px";
	
	function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x+px; this.css.top=this.y+px;}
	
	function b_newsWrite(num,i){
		if (bw.ns4){
			this.writeref.write("<a href=\""+this.news[num]['link']+"\" target=\"myTarget\" style=\"text-decoration:none; font-size:"+this.size+"px\">"
				+"<font face=\""+this.font+"\" color=\""+this.color[i]+"\">"+this.news[num]['text']+"</font></a>")
			this.writeref.close()
		}else this.writeref.innerHTML = '<a id="'+this.obj+'link' +'" target="myTarget"  style="text-decoration:none; font-size:'+this.size+'px; color:'+this.color[i]+'" href="'+this.news[num]['link']+'">'+this.news[num]['text']+'</a>'
	}
	//Slide in
	function b_slideIn(num,i){
		if (this.y>0){
			if (i==0){this.moveIt(0,this.newsheight); this.newsWrite(num,this.color.length-1)}
			this.moveIt(this.x,this.y-this.slideSpeed)
			i ++
			setTimeout(this.obj+".slideIn("+num+","+i+");",50)
		}else setTimeout(this.obj+".fadeOut("+num+","+(this.color.length-1)+")",this.delay)
	}
	//The fade functions
	function b_fadeIn(num,i){
		if (i<this.color.length){
			if (i==0 || bw.ns4) this.newsWrite(num,i)
			else{
				obj = bw.ie4?eval(this.obj+"link"):document.getElementById(this.obj+"link")
				obj.style.color = this.color[i]
			}
			i ++
			setTimeout(this.obj+".fadeIn("+num+","+i+")",this.speed)
		}else setTimeout(this.obj+".fadeOut("+num+","+(this.color.length-1)+")",this.delay)
	}
	
	function b_fadeOut(num,i){
		if (i>=0){
			if (i==0 || bw.ns4) this.newsWrite(num,i)	
			else{
				obj = bw.ie4?eval(this.obj+"link"):document.getElementById(this.obj+"link")
				obj.style.color = this.color[i]
			}
			i --
			setTimeout(this.obj+".fadeOut("+num+","+i+")",this.speed)
		}else{
			num ++
			if(num==this.news.length) num=0
			works = !this.works?0:this.works==1?1:Math.round(Math.random())
			if(works==0) setTimeout(this.obj+".fadeIn("+num+",0)",500)
			else if (works==1){this.y=1; setTimeout(this.obj+".slideIn("+num+",0)",500)
			}
		}
	}
	/********************************************************************************************
	The init function. Calls the object constructor and set some properties and starts the fade
	*********************************************************************************************/
	function fadeInit(){
		oNews = new makeNewsObj('divNews','divNewsCont',nFont,nFontsize,"nColor","nNews",nFadespeed,nBetweendelay,nSlidespeed,nWorks,nNewsheight)
		oNewsCont = new makeNewsObj('divNewsCont')
		works = !oNews.works?0:oNews.works==1?1:Math.round(Math.random())
		if (works==0) oNews.fadeIn(0,0)
		else if (works==1) oNews.slideIn(0,0)
		oNewsCont.css.visibility = "visible"
	//	setFooter()
	}


	function getWindowHeight() {
	 var windowHeight = 0;
	   if (typeof(window.innerHeight) == 'number') {
			windowHeight = window.innerHeight;
	   }
			else {
			  if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
			else {
			  if (document.documentElement && document.documentElement.clientHeight) {
				windowHeight = document.documentElement.clientHeight;
			  }
			}
	   }
	 return windowHeight;
	}
	
	function setFooter() {
		var hauteur = 85;
	  if (document.getElementById) {
		 var windowHeight = getWindowHeight();
		 if (windowHeight > 0) {
			 var footerElement = document.getElementById('tomber');
			 if (windowHeight - hauteur >= 0) {
			  if ((document.all) && (navigator.appVersion.indexOf("Mac",0)<0)) {
					footerElement.style.position = 'absolute';
					footerElement.style.top = (document.body.scrollTop + windowHeight - hauteur) + 'px';
					}
			  else {
					footerElement.style.position = 'fixed';
					footerElement.style.top = (windowHeight - hauteur) + 'px';
					}
			 }
			 else {
				footerElement.style.position = 'static';
			 }
		 }
	  }
	}
