// JavaScript Document

data = new Array();

data[0] = new Array();
data[0][0] = new Array("index_top.jpg","index_top.jpg","","","Test");
data[0][1] = new Array("index_top.jpg","index_top.jpg","","","Vue générale des travaux de démantèlement des dortoirs.");
data[0][2] = new Array("index_top.jpg","index_top.jpg","","","Vue générale du site du pont au PK 124 du chemin des passes dangereuses.");
data[0][3] = new Array("index_top.jpg","index_top.jpg","","","Vue générale du campement où le démantèlement des dortoirs a débuté.");

var len_;
var sect_;
var offset_ = 0;
var pointeurStart = 0;
var plist;

function tab(fiche) {
	document.location =  fiche + "_" + (Number(sect_)+1) + ".html";
}

function picToShow(list,id) {
	pict.hide();
	tempPic = '<table width="356" border="0" cellspacing="0" cellpadding="0"><tr><td><img src="img/' + data[list][id][1] + '" width="450" height="275" border="0"></td></tr>';
	if(data[list][id][2])
		tempPic += '<tr><td class="txt-petit" align="right"><img src="img/i_icone_zoom.gif" border="0" width="19" height="12" alt="" align="top"></td></tr>';
	else
		tempPic += '<tr><td>&nbsp;</td></tr>';
	tempPic += '<tr><td>';
	tempPic += '<b>' + data[list][id][4] + '</b></td></tr></table>';
	pict.html(tempPic);
	pict.show();
}
	

function init() {
	param = document.location.search;
	plist = param.indexOf("list");
	if(plist == -1) plist = 0;
	else plist = param.substring(plist+5, 8);
	initlayers();
	listToShow(plist,0);
	
}

function next() {
	if(offset_+8 < data[sect_].length) {
		offset_ = offset_ + 8;
		listToShow(sect_,offset_);
	}
}

function previous() {
	if(offset_-8 >= 0) {
		offset_ = offset_ - 8;
		listToShow(sect_,offset_);
	}
}

function parNumero(el) {
	offset_ = el * 8;
	listToShow (sect_,offset_);
}

function navigationPhoto(id) {
	nav_list.hide();
	nbrPage = data[id].length / 8;
	
	
	pointeurStart = Math.floor(offset_ / 40);
	
	tempNav = '<table width="135" cellspacing="0" cellpadding="0" border="0"><tr>';
	
	if(offset_ - 8 < 0)
		tempNav += '<td><img src="../img/b_fleche_precedente_off.gif" alt="Précédente" name="btprevious" id="btprevious" width="16" height="15" border="0"></td>';
	else
		tempNav += '<td><a href="javascript:void(0);" onclick="previous(); return false;"><img src="../img/b_fleche_precedente_off.gif" alt="Précédente" name="btprevious" id="btprevious" width="16" height="15" border="0"></a></td>';
	
	tempNav += '<td align="center" class="txt-petit">';

	for (i = pointeurStart * 5; i <= nbrPage; i++) {
		if (i < (pointeurStart * 5) + 5)
		{
			if(i == (offset_ / 8))
				tempNav += '<b>' +(i+1)+ '</b>&nbsp;';
			else
				tempNav += '<a href="javascript:void(0);" onclick="parNumero('+ i +'); return false;">' + (i+1) + '</a>&nbsp;';
		}
	}
	
	
	if(offset_ + 8 >= data[id].length)
		tempNav += '<td align="center"><img src="../img/b_fleche_suivante_off.gif" alt="Suivante" name="btnext" id="btnext" width="16" height="15" border="0"></td>';
	else
		tempNav += '<td align="right"><a href="javascript:void(0);" onclick="next(); return false;"><img src="../img/b_fleche_suivante_off.gif" alt="Suivante" name="btnext" id="btnext" width="16" height="15" border="0"></a></td>';
		
	tempNav += '</tr></table>';
	
	nav_list.html(tempNav);
	nav_list.show();
}

function writeContent(content) {
	list.hide();
	list.html(content);
	list.show();
}	

function listToShow(id,offset) {
	len_ = offset+8;
	if(data[id].length < len_) len_ = data[id].length;

	var tmp = '';
	tmp += '\'<table>'	
	for(x = offset; x < len_; x++) {
		tmp += '<tr><td><a href="javascript:void(0);" onclick="picToShow('+ id +','+ x +'); return false;"><img src="img/'+ data[id][x][0] +'" width="64" height="43" border="0"></a></td>';
		x = x+1;
		if( x < data[id].length) 
			tmp += '<td><a href="javascript:void(0);" onclick="picToShow('+ id +','+ x +'); return false;"><img src="img/'+ data[id][x][0] +'" width="64" height="43" border="0"></a></td></tr>';
		else
			tmp+= '<td></td></tr>'
		}
	tmp += '</table>\''
	
	sect_ = id;
	offset_ = offset;
	
	setTimeout("writeContent("+tmp+")",20);
	setTimeout("navigationPhoto("+id+")",20);
	setTimeout("picToShow("+id+","+offset+")",20);
	setTimeout("titreToShow("+id+")",20);
}


