// Différentes fonctions pour gérer des calques

var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var NS6 = (document.getElementById && !document.all) ? 1 : 0;
var mylayer = null;
var timerID = null;
var position = 0;
var initialtop = null;
var currenttop = null;
var currentheight = null;
var pixelsinterval = 1;

function showLayer(calque) {
	if (NS4) {
		document.layers[calque].visibility = "show";
	} else {
		if (NS6) {
			document.getElementById(calque).style.visibility = "visible";
		} else {
			document.all[calque].style.visibility = "visible";
		}
	}
}

function hideLayer(calque) {
	if (NS4) {
		document.layers[calque].visibility = "hide";
	} else {
		if (NS6) {
			document.getElementById(calque).style.visibility = "hidden";
		} else {
			document.all[calque].style.visibility = "hidden";
		}
	}
}

function moveTopLayer(){
	if (NS4) {
		mylayer.top = currenttop;
		mylayer.height = currentheight;
		mylayer.clip.top = position;
		mylayer.clip.bottom = currentheight;
	} else {
		mylayer.style.top = currenttop;
		mylayer.style.height = currentheight;
		mylayer.style.clip = "rect(" + position + "px, " + mylayer.style.width + ", " + currentheight + "px, 0px)";
	}
	currentheight = currentheight + pixelsinterval;
	currenttop = currenttop - pixelsinterval;
	position = position + pixelsinterval;
}

function moveDownLayer(){
	if (initialtop - currenttop < 0) {
		clearInterval(timerID);
	} else {
		if (NS4) {
			mylayer.top = currenttop;
			mylayer.height = currentheight;
			mylayer.clip.top = position;
			mylayer.clip.bottom = currentheight;
		} else {
			mylayer.style.top = currenttop;
			mylayer.style.height = currentheight;
			mylayer.style.clip = "rect(" + position + "px, " + mylayer.style.width + ", " + currentheight + "px, 0px)";
		}
		currentheight = currentheight - pixelsinterval;
		currenttop = currenttop + pixelsinterval;
		position = position - pixelsinterval;
	}
}

function startScrollText(curlayer, speed, top, height, direction, pixint) {
	clearInterval(timerID);
	pixelsinterval = pixint;
	if (initialtop == null) {
		initialtop = top;
	}
	if (currenttop == null) {
		currenttop = top;
	}
	if (currentheight == null) {
		currentheight = height;
	}
	if (NS4) {
		mylayer = document.layers[curlayer];
		mylayer.clip.top = position;
		mylayer.clip.bottom = currentheight;
	} else {
		if (NS6) {
			mylayer = document.getElementById(curlayer);
		} else {
			mylayer = document.all[curlayer];
		}
		mylayer.style.display = "block";
		mylayer.style.overflow = "hidden";
		mylayer.style.clip = "rect(" + position + "px, " + mylayer.style.width + ", " + currentheight + "px, 0px)";
	}
	showLayer(curlayer);
	if (direction == "-") {
		timerID = setInterval ("moveDownLayer()", speed);
	} else {
		timerID = setInterval ("moveTopLayer()", speed);
	}
}

function stopScroll() {
	clearInterval(timerID);
}

function reinitializeScroll(top, height, scrolling) {
	if (mylayer != null) {
		currentheight = height;
		currenttop = top;
		position = 0;
		if (NS4) {
			mylayer.top = currenttop;
			mylayer.height = currentheight;
			mylayer.clip.top = position;
			mylayer.clip.bottom = currentheight;
		} else {
			mylayer.style.top = currenttop;
			mylayer.style.height = currentheight;
			mylayer.style.display = "block";
			mylayer.style.clip = "rect(" + position + "px, " + mylayer.style.width + ", " + currentheight + "px, 0px)";
			mylayer.style.overflow = scrolling;
		}
	}
}