// JavaScript Document
// 05-11-2003 - francktfr@systeme-d.net
// écrit pour http://www.systeme-d.net
var imgs = new Array()
var CellsDone = 0
var Interval = 2000		//	Temps entre deux images (ms)
//	Définition des images ici	:
AddImage("../images/partenaires/logo_anpfs_120x.jpg")
AddImage("../images/partenaires/logo_nf_120x.jpg")
AddImage("../images/partenaires/logo_afpc_120x.jpg")
AddImage("../images/partenaires/logo_ffe_120.jpg")
AddImage("../images/partenaires/logo_shf_120x120.jpg")
AddImage("../images/partenaires/Haras_Nationaux_120.jpg")
AddImage("../images/partenaires/agriculture_120.jpg")
function Hide(Index){
	CellsDone=0
	for (y=0; y<Cache.rows.length; y++){
		for (x=0; x<Cache.rows[y].cells.length; x++){ setTimeout("HideCell(" + x + "," + y + "," + Index + ")",(Math.random()*300)) }
	}
}
function HideCell( i, j, Index){
	CellsDone++
	Cache.rows[j].cells[i].style.background = "#FFFFFF"
	if (CellsDone >= (Cache.rows.length*Cache.rows[j].cells.length)){
		Cache.style.backgroundImage = "url('" + imgs[Index].src +"')"
		setTimeout("Show("+Index+")",200)
	}
}
function Show(Index){
	CellsDone=0
	for (y = 0; y < Cache.rows.length; y++){
		for (x = 0; x < Cache.rows[y].cells.length; x++){ setTimeout("ShowCell(" + x + "," + y + "," + Index + ")",200+(Math.random()*1000)) }
	}
}
function ShowCell( i, j, Index){
	CellsDone++
	Cache.rows[j].cells[i].style.backgroundColor = "transparent"
	if (CellsDone >= (Cache.rows.length*Cache.rows[j].cells.length)){
		Index < (imgs.length-1) ? Index++ : Index = 0
		setTimeout("Hide("+Index+")",Interval)
	}
}
function AddImage(Source){
	var img = new Image()
	img.src = Source
	imgs.push(img)
}
function CreateTable(Container, Dim){
	var maxx = 0
	var maxy = 0
//	for(i=0; i<imgs.length; i++){
//		if (imgs[i].height > maxy){maxy=imgs[i].height}
//		if (imgs[i].width > maxx){maxx=imgs[i].width}
//	}
		maxy = 150
		maxx = 150
	var str = "<TABLE ID=Cache WIDTH="+maxx+" HEIGHT="+maxy+" CELLSPACING=0 CELLPADDING=0 BORDER=0 STYLE=\"table-layout: fixed; background-position: center center; background-repeat: no-repeat\">"
	var row  ="<TR>"
	for (i=0; i<maxx; i += Dim){
		str += "<COL WIDTH="+Dim+">"
		row += "<TD></TD>"
	}
	row  +="</TR>"
	for (i=0; i<maxy; i += Dim){str += row}
	Container.innerHTML = str + "</TABLE>"
	Hide(0)
}
