function lib_bwcheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	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.ie7=(this.ver.indexOf("MSIE 7")>-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=new lib_bwcheck()

function largeurEcran()
{

	if (bw.ie5 || bw.ie6 || bw.ie7)
	{
		largeur = document.body.offsetWidth;
		//alert(largeur);
	}
	else if (bw.ns4 || bw.ns6)
	{
		largeur = window.innerWidth;
	}
	else if (bw.ie4)
	{
	window.resizeTo(1000,780);
	largeur = 1000;
	}
return largeur;
}

function placeDiv(Div, Left)
{
	var largeur=0;
	largeur = largeurEcran();
	largeur = Math.ceil(((largeur - 960)/2));
	
	var pix=0;
	pix=(bw.ie5 && !bw.mac)?-11:(bw.ie6)?0:(bw.ns6)?-1:(bw.ie5 && bw.mac)?0:(bw.ns4 && bw.mac)?-10:(bw.ns4)?-9:(bw.ie4)?-14:0;
	if (largeur+pix<8 && !(bw.ie4)){
	largeur=0;
	pix=0;
	}	
	if (bw.dom) {
	document.getElementById(Div).style.left = Left+(largeur+pix) + "px";
	document.getElementById(Div).style.visibility = "visible";
} else if (bw.ns4) {
	document.layers[Div].left = Left+largeur+pix;
	document.layers[Div].visibility = "visible";
	} else if (bw.ie4) {
	document.all[Div].style.left= Left+largeur+pix;
	document.all[Div].style.visibility = "visible";
	}
}
function showContenu()
{
	
	if (bw.dom) {
	document.getElementById("Contenu").style.visibility = "visible";
	} else if (bw.ns4) {
	document.layers["Contenant"].document.layers["Contenu"].visibility = "visible";
	} else if (bw.ie4) {
	document.all["Contenu"].style.visibility = "visible";
	}
}


var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);

function getRef(id)
{
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
}

function getSty(id)
{
 return (isNS4 ? getRef(id) : getRef(id).style);
} 


function scrLoad(name) { with (this)
{
 if (!name) return;
 var path = location.href.substring(0, location.href.lastIndexOf('/') + 1);

 if (isDOM || isIE4)
 {
  oldLoc = bufRef.location.href;
  if ((name.substring(0, 5) != 'http:') && (name.substring(0, 5) != 'file:'))
   name = path + name;
  if (isDOM && !document.all) setTimeout(myName + '.bufRef.document.readyState="complete"', 5000);

  if (oldLoc != name)
  {
   bufRef.location.href = name;
   checkBuffer(oldLoc);
  }
  else checkBuffer('dummyLocation');
 }
 else
 {
  divRef.onload = new Function(myName + '.fileLoaded()');
  divRef.load(name, cWidth);
 }
}}

function scrCheckBuffer(oldLoc) { with (this)
{
 if ((bufRef.location.href == oldLoc) || (bufRef.document.readyState != 'complete'))
  setTimeout(myName + '.checkBuffer(\'' + oldLoc + '\')', 50);
 else
 {
  divRef.innerHTML = bufRef.document.body.innerHTML;
  bufRef.location.href = 'about:blank';
  setTimeout(myName + '.fileLoaded()', 1);
 }
}}

function scrFileLoaded() { with (this)
{
 activeScr = null;
 scrollBy(-100000);
 for (count = 0; count < divs.length; count++)
  getSty(divs[count][0]).visibility = 'visible';
}}

function scrScrollBy(amount) { with (this)
{
 if (!isDyn || !loaded) return;

 amount = parseInt(amount);

 divHeight = document.all ? divRef.clientHeight : 
  (isDOM ? divRef.offsetHeight : divRef.document.height);
 if (divHeight == 0) divHeight = 1;

 if ((cBot + amount) > divHeight) amount = divHeight - cBot;
 if ((cTop + amount) < 0) amount = 0 - cTop;

 cTop += amount;
 cBot += amount;
 if (isDOM || isIE4)
  divSty.clip = 'rect(' + cTop + 'px ' + cWidth + 'px ' + cBot + 'px ' + 0 + 'px)';
 else if (isNS4)
 {
  if (isNaN(cTop) || isNaN(cBot) || isNaN(amount)) layout();

  if (cBot < divSty.clip.top) divSty.clip.top = cTop;
  divSty.clip.bottom = cBot;
  divSty.clip.top = cTop;
 }

 divSty.top = eval(divs[0][2]) - cTop;


 thmHeight = Math.ceil(barHeight * ((cBot - cTop) / divHeight));

 if (thmHeight < minThmHeight) thmHeight = minThmHeight;
 if (thmHeight > barHeight) thmHeight = barHeight;

 if (isDOM || isIE4) thmSty.height = thmHeight;
 else if (isNS4) thmSty.clip.height = thmHeight;


 if (activeScr) return;

 fracDivDown = (cTop / (divHeight - (cBot - cTop)));
 thmSty.top = parseInt(barSty.top) + fracDivDown * (barHeight - thmHeight);

 if (loop) setTimeout(myName + '.scrollBy(' + amount + ')', loop);
}}

function scrThumbDown(evt)
{
 activeScr = this;

 if (document.all) scrOffset = event.offsetY;
 else scrOffset = evt.layerY;
 return false;
}

function scrThumbMove(evt)
{
 if (isNS4) document.routeEvent(evt);

 if (!activeScr) return true;
 else { with (activeScr)
 {
  if (isNaN(cTop) || isNaN(cBot)) divLayout();
  if ((cBot > divHeight) || (thmHeight == barHeight)) return;
  if (document.all) newTop = document.body.scrollTop + event.clientY - scrOffset;
  else newTop = evt.pageY - scrOffset;

  var barTop = parseInt(barSty.top);
  if (newTop < barTop) newTop = barTop;
  if (newTop + thmHeight > (barTop + barHeight))
   newTop = (barTop + barHeight) - thmHeight;
  thmSty.top = newTop;

  fracDivDown = cTop / (divHeight - (cBot - cTop));
  fracBarDown = (newTop - barTop) / (barHeight - thmHeight);

  scrollBy((fracBarDown - fracDivDown) * (divHeight - (cBot - cTop)));

  return false;
 }}
}

function scrThumbUp(evt)
{
 if (isNS4) document.routeEvent(evt);
 activeScr = null;
}


function scrBarClick(evt) { with (this)
{
 if (isNS4) document.routeEvent(evt);

 if (document.all) clickPos = document.body.scrollTop + event.clientY;
 else clickPos = evt.pageY;
 
 if (clickPos < parseInt(thmSty.top)) scrollBy(cTop - cBot);
 if (clickPos > (parseInt(thmSty.top) + thmHeight)) scrollBy(cBot - cTop);
}}


function scrLayout() { with (this)
{
 if (!isDyn) return;

 winWidth = document.all ? document.body.clientWidth : window.innerWidth;
 winHeight = document.all ? document.body.clientHeight : window.innerHeight;

 if (isNS4 && (scrFirstWidth != winWidth))
 {
  fileName = location.href;
  if (fileName.indexOf('?') != -1) fileName = fileName.substring(0, fileName.indexOf('?'));
  location.href = fileName + '?loadFile=' + divRef.src;
 }

 if (!loaded) return;

 if (winWidth < minWinWidth) winWidth = minWinWidth;
 if (winHeight < minWinHeight) winHeight = minWinHeight;

 for (count = 0; count < divs.length; count++)
 {
  var tmpObj = getSty(divs[count][0]);
  if (divs[count][1]) tmpObj.left = eval(divs[count][1]);
  if (divs[count][2]) tmpObj.top = eval(divs[count][2]);
  if (divs[count][3])
  {
   var tmpW = eval(divs[count][3]);
   isNS4 ? tmpObj.clip.width = tmpW : tmpObj.width = tmpW;
  }
  if (divs[count][4] && count != 0)
  {
   var tmpH = eval(divs[count][4]);
   isNS4 ? tmpObj.clip.height = tmpH : tmpObj.height = tmpH;
  }
 }

 if ((isDOM || isIE4) && !cTop) cTop = 0;
 if (isNS4) cTop = divSty.clip.top;

 barHeight = eval(divs[1][4]);
 cBot = cTop + eval(divs[0][4]);
 cWidth = eval(divs[0][3]);
 if (isDOM || isIE4) divSty.width = cWidth;

 scrollBy(0);
}}


function scrSetup() { with (this)
{
 if (!isDyn) return;

 divRef = getRef(divs[0][0]);
 divSty = getSty(divs[0][0]);
 barSty = getSty(divs[1][0]);
 thmSty = getSty(divs[2][0]);
 barRef = getRef(divs[1][0]);
 thmRef = getRef(divs[2][0]);
 
 if (isNS4)
 {
  barRef.captureEvents(Event.CLICK);
  thmRef.captureEvents(Event.MOUSEDOWN);
  document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
 }

 barRef.onclick = new Function('evt', 'return ' + myName + '.barClick(evt)');
 thmRef.onmousedown = new Function('evt', 'return ' + myName + '.thumbDown(evt)');
 document.onmousemove = scrThumbMove;
 document.onmouseup = scrThumbUp;

 if (document.all) document.onselectstart = new Function('if (activeScr) return false');
 else if (isDOM) document.onselect = new Function('if (activeScr) return false');

 loaded = true;
 layout();

 fileLoaded();
}}


function DHTMLScroller(myName)
{
 this.divRef = null;
 this.divSty = null;
 this.barSty = null;
 this.thmSty = null;

 // Array of objects to move when the window is resized (e.g. scrollbar, arrows).
 this.divs = new Array();
 
 // Store the ID's of these objects here for now. Convert to references later...
// this.loadSty = loadMess;
 this.bufRef = null;//bufferID;
  
 // Properties.
 this.myName = myName;
 this.loaded = false;
 // A non-zero value for loop will cause a scrollBy call to repeat after that many milliseconds.
 this.loop = 0;
 // Minimum height of scrollbar thumb - defaults to 20, set to something else if you want.
 this.minThmHeight = 5;

 this.divHeight = 0;
 this.barHeight = 0;
 this.thmHeight = 0;
 this.cTop = 0;
 this.cBot = 0;
 this.cWidth = 0;

 // Methods - bind to functions above.
 this.load = scrLoad;
 this.checkBuffer = scrCheckBuffer;
 this.fileLoaded = scrFileLoaded;
 this.scrollBy = scrScrollBy;
 this.thumbDown = scrThumbDown;
 this.barClick = scrBarClick;
 this.setup = scrSetup;
 this.layout = scrLayout;
}

// Some global variables for the scroller code - scrFirstWidth is only for NS4 resize bug.
var activeScr = null, scrOffset = 0, winWidth, winHeight, scrFirstWidth = window.innerWidth;

var Photo;

// Minimum window sizes - script will use these if actual sizes are too low.
var minWinWidth = 500, minWinHeight = 300;

Agr = new DHTMLScroller('Agr');

with (Agr)
{
 // divs[number] = new Array('id of div below', 'x', 'y', 'width', 'height');
 // Dimensions are evaluable strings so they can include variables. Null strings are skipped.
 // Div 0 is the main scroller, 1=Bar, 2=Thumb.
 divs[0] = new Array('mainAgr', '', '100', '470', '295');
 divs[1] = new Array('scrollBarAgr', '', '100', '10', '301');
 
// Don't bother passing Y and Height parameters for the thumb.
 divs[2] = new Array('scrollThumbAgr', '', '', '6', '');

 // Anything past that is not special, just moved/sized with the window. Add extra divs!
 divs[3] = new Array('upArrowsAgr', '', '92', '10', '8');
 divs[4] = new Array('downArrowsAgr', '', '398', '10', '8');
}
