<div style="background-image: url(media/texts/photos_about/02aft.jpg); background-repeat: no-repeat;" id="blenddiv">

<DIV ID=diaporama_center>

<script type="text/javascript">

photos = new Array();
<?php
	$a = 0;
	$rep=$_SESSION['rep']; // on récupère le répertoire qui contient les photos
	$handle = opendir($rep); 
	while (($file = readdir())!=false) 
	{ 
		clearstatcache(); 
		if($file!=".." && $file!=".") 
		{
			//if (substr($file,-7)="500.jpg") {
			echo "photos[$a] = '$rep/$file';"; //etrange mais ca marche
			$a++; //}
		}
	}
	closedir($handle); 
?>

function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
} 

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
   if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
	var timer = 0;
	if(opacStart > opacEnd) {
        for(i = opacEnd; i >= opacStart; i++) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacEnd; i <= opacStart; i--)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }	
	}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

var rotate_delay = 5000; // delais en microseconde (4000 = 4 secs)
var num=0	

function diaporama_photos(num)
	{
	num1=num+1;
	<?php echo "num1=(num1>$a-1)*(num1-$a)+(num1<$a)*num1;"; ?> // astuce pour intégrer des variables php et javascript,  le compteur revient à zéro à la fin du cycle
	//if(document.getElementById)
		//{
		//window.document.getElementById("diaporama").innerHTML = "<CENTER><IMG SRC='"+photos[num1]+"' BORDER=0 WIDTH=500 HEIGHT=375><BR>"+"</CENTER>";
		//window.
		// document.getElementById("diaporama").innerHTML = "<center><IMG SRC='"+photos[num1]+"' BORDER=0 WIDTH=300 HEIGHT=250 id='photo'><BR>"+"</CENTER>";
		document.getElementById("diaporama").innerHTML = "<IMG SRC='"+photos[num1]+"' BORDER=0 WIDTH=300 HEIGHT=250 id='photo'><BR>";
		opacity("diaporama", 1, 100, 3000);

		//photo='photos[num1]';
		//photo='<CENTER><IMG SRC='+photo+'BORDER=0><BR></CENTER>';
			
		timer=setTimeout("diaporama_photos(num1)", rotate_delay);
		
	}	
diaporama_photos(num)
window.document.title="Accueil Chambres de Valcombe";
</script>
</div>
