// fondu
var coef = 0.05 ; // avancement de l'opacit&eacute;
var temps = 50 ; // temps entre chaque changement d'opacit&eacute;
var temps_pause = 4000 ; // temps d'attente entre 2 changements d'images
var nombre_image = 3 ; // nombre d'images a faire bouger
var prefix_image = './images/fondu/'; // chemin + prefix du nom des images
var suffix_image = '.gif' ; // suffix + '.extension' du nom des images

// pas touche
var indice = 2; // les 2 premiere image sont deja charger dans le HTML, on commence a la 3eme
var isIE = navigator.userAgent.toLowerCase().indexOf('msie')!=-1 ;
var img1 = null;
var img2 = null ;
var sens = 1;
var tabImg; // tab contenant les images
// deplace
var Timer;
var Pas = 5; // vitesse défilement texte
var limite = -865;
//   indices des tableaux limites ci-dessous :
// Collection : 	0 = inutilisé
//			1 =  tableaux,  
//			2  =  sculptures, 
//			3  =  dessins 
//			4 =  terres cuites
var limites = ["-865", "-5310", "-10300", "-970", "-3585"]; // H>1024
var limites1 = ["-865", "-4840", "-9385", "-880", "-3265"];  // H>900 à 1024
var limites2 = ["-710", "-4370", "-8470", "-795", "-2945"];  // H>800 à 900 
var limites3 = ["-550", "-3370", "-6505", "-620", "-2275"];  // <H<800
// appel
var collect = "tableaux";
var initiales = "tb";
var url = "";
var det = "details";

function resolutiononly() {
document.location=window.location.pathname+"?width="+screen.width+"&height="+screen.height;
}
function resolution(collection) {
	if (collection == 1){
		url='tableaux/slides/js_tb001.php'	
	}
	else if (collection == 2){
		url='sculptures/slides/js_sc001.php'	
		}
		else if (collection == 3){
		url='dessins/slides/js_ds001.php'	
			}
			else if (collection == 4){
			url='terrescuites/slides/js_tc001.php'	
			}
	document.location=window.location.pathname+"?width="+screen.width+"&height="+screen.height+"&posit=0px&page="+url;
}

function appel(page,collection,detail) {
// collection : 1 =  tableaux,  2  =  sculptures,  3  =  dessins 
	if (detail==1){
		det = 'details'
		}
		else{
		det = 'slides'
		}
		
	if (collection == 1){
		collect = 'tableaux'	
		initiales = "tb"	
	}
	else if (collection == 2){
			collect = 'sculptures'
			initiales = 'sc'
		}
		else if (collection == 3){
			collect = 'dessins'
			initiales = 'ds'
			}
			else if (collection == 4){
			collect = 'terrescuites'
			initiales = 'tc'
			}
	url=collect+'/'+det+'/js_'+initiales+page+'.php'
	
	if(document.getElementById)
	{
       Objet = document.getElementById("contenu");
	 }
   else
   {
      Objet = document.all["contenu"];
	} 
	document.location=window.location.pathname+"?width="+screen.width+"&height="+screen.height+"&posit="+Objet.style.top+"&page="+url;
}
function prechargerImg(){
tabImg = new Array(nombre_image);
for (i=0; i<=nombre_image -1; i++){
tabImg[i]=new Image();
tabImg[i].src = prefix_image+(i+1)+suffix_image;
}
}

function init()
{
//tamingselect() ;
img1 = document.getElementById("defilement1") ;
img2 = document.getElementById("defilement2") ;

prechargerImg();
change_opacity();
}

function change_opacity()
{
var opacity1 = 0 ;
var opacity2 = 0 ;
if (isIE) // for IE
{ opacity1 = parseFloat(img1.filters.alpha.opacity);
opacity2 = parseFloat(img2.filters.alpha.opacity);
}
else // for mozilla
{ opacity1 = parseFloat(img1.style.MozOpacity);
opacity2 = parseFloat(img2.style.MozOpacity);
}

if (sens)
{ if (isIE) // for IE
{ img1.filters.alpha.opacity = opacity1 + coef * 100;
img2.filters.alpha.opacity = opacity2 - coef * 100;
}
else // for Mozilla
{ img1.style.MozOpacity = opacity1 + coef;
img2.style.MozOpacity = opacity2 - coef;
}
}
else
{
if (isIE) // for IE
{ img1.filters.alpha.opacity = opacity1 - coef * 100;
img2.filters.alpha.opacity = opacity2 + coef * 100;
}
else // for Mozilla
{ img1.style.MozOpacity = opacity1 - coef;
img2.style.MozOpacity = opacity2 + coef;
}
}

if (isIE) // for IE
{ opacity1 = parseFloat(img1.filters.alpha.opacity);
opacity2 = parseFloat(img2.filters.alpha.opacity);
}
else // for mozilla
{ opacity1 = parseFloat(img1.style.MozOpacity);
opacity2 = parseFloat(img2.style.MozOpacity);
}

// on fait vari&eacute; le sens d'opacit&eacute; du bazar
if (opacity2 <= 0)
{ img2.src=tabImg[indice++].src;
sens = 0;
if (indice == (tabImg.length)) indice=0;
window.setTimeout("change_opacity()",temps_pause) ; // attente
return 0;
}
else if (opacity1 <= 0)
{ img1.src=tabImg[indice++].src;
sens = 1;
if (indice == (tabImg.length)) indice=0;
window.setTimeout("change_opacity()",temps_pause) ; // attente
return 0;
}
window.setTimeout("change_opacity()",temps) ; // recursion toutes les x millisec
}


function deplace(Sens,Collection,Vitesse) {
//  Sens :  	-1    	monte
//		+1	descent
// Collection : 	1 =  tableaux,  
//			2  =  sculptures, 
//			3  =  dessins 
//			4 = terres cuites
//Vitesse 	Multiplie le senes
//	recupere dans Objet les propriétés de "contenu"
	if(document.getElementById) {
		Objet = document.getElementById("contenu");
		}
	else {
		Objet = document.all["contenu"];
		}
	if(screen.height<=600) {
		limite = limites3[Collection];
	}
	else if(screen.height<=768) {
		limite = limites2[Collection];
	}
	else if(screen.height<=900) {
		limite = limites1[Collection];
	}
	else {
		limite = limites[Collection];
	}
//		
//	if(screen.width>=1280) {
//		if(screen.height>900) {
//		limite = limites[Collection];
//		}
//		else {
//		limite = limites1[Collection];
//		}
//	}
//	else if (screen.width>=1024) {
//		limite = limites2[Collection];
//		}
//		else {
//			limite = limites3[Collection];
//			}
	
	position = parseInt(Objet.style.top)-1;

	if(parseInt(Objet.style.top)  > 0) {
		Objet.style.top = "0px";
		}
	else if ((position<limite) & (Sens<0)) {
			Objet.style.top = limite+"px";
			}
		else {
			Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens*Vitesse)) + "px";
			Timer = setTimeout("deplace(" + Sens + "," + Collection + "," + Vitesse +");", 50);
			}
}

function deplacetop() {
   if(document.getElementById)
       Objet = document.getElementById("contenu");
   else
		Objet = document.all["contenu"];
		Objet.style.top = "0px";
}




