var imageArray = new Array;
var activeImage;
var isDisplayed = false;
var fileLoadingImage = "http://195.154.180.97/provostpresse/images/loading.gif";
var fileBottomNavCloseImage = "http://195.154.180.97/provostpresse/images/close2.gif";
var fileBottomNavDlImage = "http://195.154.180.97/provostpresse/images/dl.gif";
var objBottomNavCloseImageLien = "";


var resizeSpeed = 10; // controls the speed of the image resizing (1=slowest and 10=fastest)

var borderSize = 10; //if you adjust the padding in the CSS, you will need to update this variable
if(resizeSpeed > 10){ resizeSpeed = 10;}
if(resizeSpeed < 1){ resizeSpeed = 1;}
resizeDuration = (11 - resizeSpeed) * 0.15;

Array.prototype.removeDuplicates = function () {
	for(i = 1; i < this.length; i++){
		if(this[i][0] == this[i-1][0]){
			this.splice(i,1);
		}
	}
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}
function affichePannelTrame(pannelObj)
{
	if(!isDisplayed)
	{
		isDisplayed=true;
		hideSelectBoxes();
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		var nb = arrayPageSize[1]+200;
		document.getElementById('overlay').style.height = nb +"px";
		//setHeight('overlay', arrayPageSize[1]+200);
		//new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
		document.getElementById('overlay').style.display = 'block'
		// calculate top offset for the lightbox and display 
		var arrayPageSize = getPageSize(); 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);
	
		document.getElementById(pannelObj).style.top = 0 +"px";
		//.setTop('lightbox', lightboxTop);
		document.getElementById(pannelObj).style.display = 'block'
		//.show('lightbox');
	}
}

function masquePannelTrame(pannelObj)
{
	if(isDisplayed)
	{
		isDisplayed=false;
		document.getElementById(pannelObj).style.display = 'none';
		//.hide('lightbox');
		//new Effect.Fade('overlay', { duration: 0.2});
		document.getElementById('overlay').style.display = 'none';
		showSelectBoxes();
	}
}

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}
function changeImage(index,numVignette,nombre){
	if(isDisplayed)
	{
		var imageZoom = document.getElementById("image_zoom_"+index);
		for(var i=0; i<=4; i++)
			document.getElementById("image_zoom_"+i).style.display = 'none';
		imageZoom.style.display = 'block';
		document.getElementById("curseur").innerHTML="#"+numVignette+"/"+nombre;
		
		}
	else
	{
		zoom();
	}
}
function afficheVignette(tabVignette){
	var nombre=tabVignette.length;
	var elt=document.getElementById("affVignette");
	var eltZoom=document.getElementById("cont_image_zoom");
	var affiche="";
	var affZoom ="";
	var taille = Math.ceil(100/nombre);
	for(i = 0; i <nombre; i++){
		affiche+="<td width ='"+taille+"%' align='center' class='bordure_vignette'><a href='#' onclick='changeImage("+i+","+nombre+")' title=''><img src='"+tabVignette[i]+"' alt=''  /></a></td>";
		
		
	}
	elt.innerHTML=affiche;
	
}
// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
// ---------------------------------------------------

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}
//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
