addOnload(rolloverInit);
addOnload(survolInit);
addOnload(newWinLinks);

/**************addOnload*******************
Cete fonction permet de definir plusieurs script 
sur une même page, afin de réaliser difféntes opérations
lorsque la page se charge
*****************************************/


	function addOnload(newFunction) {
		var oldOnload = window.onload;
		
		if (typeof oldOnload == "function") {
			window.onload = function () {
					if (oldOnload) {
						oldOnload();
					}
					newFunction ();
			}
		}
		else {
			window.onload = newFunction;
		}
	}

/*************************rollOverInit******************************/	
function rolloverInit() {
	for (var i=0; i<document.links.length; i++) {
		var linkObj = document.links[i];
		if (linkObj.className) {
			var imgObj = document.getElementById(linkObj.className);
			if (imgObj) {
				setupRollover(linkObj,imgObj);
			}
		}
	}
}

function setupRollover(thisLink,textImage) {
	thisLink.imgToChange = new Array;
	thisLink.outImage = new Array;
	thisLink.overImage = new Array;

	thisLink.imgToChange[0] = textImage;
	thisLink.onmouseout = rollOut;
	thisLink.onmouseover = rollOver;	
	
	thisLink.outImage[0] = new Image();
	thisLink.outImage[0].src = textImage.src;

	thisLink.overImage[0] = new Image();
	thisLink.overImage[0].src = "images/aqua/" + thisLink.id + "Text.jpg";
	
	var rolloverObj = document.getElementById(thisLink.id + "Img");
	if (rolloverObj) {
		thisLink.imgToChange[1] = rolloverObj;

		thisLink.outImage[1] = new Image();
		thisLink.outImage[1].src = rolloverObj.src;
	
		thisLink.overImage[1] = new Image();
		thisLink.overImage[1].src = "images/aqua/" + thisLink.id + "_on.jpg";
	} 
}

function rollOver() {
	for (var i=0;i<this.imgToChange.length; i++) {
		this.imgToChange[i].src = this.overImage[i].src;
	}
}

function rollOut() {
	for (var i=0;i<this.imgToChange.length; i++) {
		this.imgToChange[i].src = this.outImage[i].src;
	}
}
/******************************SurvolInit*********************************/
function survolInit() {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].parentNode.tagName == "A") {
			setupSurvol(document.images[i]);
		}
	}
}

function setupSurvol(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = dehors;

	thisImage.overImage = new Image();
	thisImage.overImage.src = "images/boutons/" + thisImage.id + "_on.jpg";
	thisImage.onmouseover = dessus;	
}

function dessus() {
	this.src = this.overImage.src;
}

function dehors() {
	this.src = this.outImage.src;
}

	/**************************************NewWinLinks****************************************/

function newWinLinks () {
	for (var i=0; i<document.links.length; i++) {
		if (document.links[i].className=="newWin"){
			document.links[i].onclick = newWindow;
		}
	}
}

function newWindow(){
	var videoWindow = window.open(this.href, "newWin", "resizable=no,width=500, height=600" );
	videoWindow.focus();
	return false;
}
