﻿// PARAMETRES PERSONNALISABLES ====
timSpeed = 10;
nbscroll = 0;
// ================================

ie = document.all ? 1 : 0;
n = document.layers ? 1 : 0;
n7 = document.getElementById ? 1 : 0;


contHeight = new Array();
premiere = new Array();
oScroll = new Array();
var scrollTim;

function scroll(i, speed) {
	sp = speed;
	if (!ie) { speed = speed * 2; sp = speed / 2; }
	clearTimeout(scrollTim);
	way = speed > 0 ? 1 : 0;
	if ((!way && oScroll[i].top(premiere[i]) > -oScroll[i].scrollHeight + contHeight[i]) || (oScroll[i].top(premiere[i]) < 0 && way)) {
		oScroll[i].css.top = parseInt(oScroll[i].top(premiere[i])) + speed + ((n7 && !ie) ? 'pt':'');
		scrollTim = setTimeout("scroll(" + i + "," + sp + ")", timSpeed);
		premiere[i] = false;
	}
}
function noScroll() { clearTimeout(scrollTim); }


function scrollInit(nb, numero) {
	setTimeout("scrollInitInterne(" + nb + ", " + numero + ");", 250);
}
function scrollInitInterne(nb, numero) {
	if (nb == undefined) nb = nbscroll;
	nbscroll = nb;
	if (numero == undefined) {
		numero = 1;
	} else {
		nb = numero;
	}
	for (i = numero; i <= nb; i++) {
		oScroll[i] = new makeScrollObj('divScroll' + i, 'divCont' + i);
		oScroll[i].css.visibility = 'visible';
		if (ie) { contHeight[i] = document.all['divCont' + i].offsetHeight; } else { contHeight[i] = document.getElementById('divCont' + i).offsetHeight; }
		premiere[i] = true;
		// Masquage des flèches inutiles
		if (oScroll[i].scrollHeight <= contHeight[i]) {
			if (ie) { document.all['divControl' + i].style.display = "none"; } else { document.getElementById('divControl' + i).style.display = "none"; }
		} else {
			if (ie) { document.all['divControl' + i].style.display = "block"; } else { document.getElementById('divControl' + i).style.display = "block"; }
		}
		oScroll[i].css.top = 0;
	}
	detecteReinitScroll();
}
function makeScrollObj(obj, nest) {
	nest = (!nest) ? '' : (ie) ? 'document.' + nest + '.' : 'document.getElementById("' + nest + '").';
	this.css = (n) ? eval(nest + 'document.' + obj) : (ie) ? eval('document.all.' + obj + '.style') : eval('document.getElementById("' + obj + '").style');
	this.scrollHeight = n ? this.css.document.height : (ie) ? eval('document.all.' + obj + '.offsetHeight') : eval('document.getElementById("' + obj + '").offsetHeight');
	this.top = b_gettop;
	return this;
}
function b_gettop(prem) {
	var gtop = (n) ? eval(this.css.top) : (ie) ? eval(this.css.pixelTop) : eval(parseInt(this.css.top));
	if (n7 && prem) gtop = 0;
	return gtop;
}


function detecteReinitScroll() {
    majSpan1();
	if (document.getElementById("reinitScroll").value == "1") {
		document.getElementById("reinitScroll").value = "0";
		scrollInit(nbscroll, 1);
	} else {
		setTimeout("detecteReinitScroll();", 250);
	}
}


function majSpan1() {
    var nb = 0;

    var Span1 = document.getElementById("Span1");
    if (Span1 != undefined) {
        Span1.innerHTML = '';
    }


//    if (nb < 10) {
//        nb = nb + 1;
//        setTimeout("Attente();", 500);
//    }
}