Possible Duplicate:
my carousel does not work
am a bit puzzled! i got this carousel am creating and i desire that it loops. everything else works out fine, but, when the last image has slid up i want the first one to do the same after it, then the second...infinitely. i have tried many things like appending the first image to the last. i have also tried showing back the images after the last(this one tries but gives an undesirable effect).
i need to be shown what tweaks i need to make. thanks big time!
var images = $("#slideShow div");
var index = 0;
for (i = 0; i < images.length; i++) {
$(images[i]).addClass("image-" + i);
}
setInterval(function() {
$(".image-" + (index)).slideUp(1000);
if (index < images.length - 1) {
index += 1;
}
else {
index = 0;
}
}, 500);
#slideShow {
height:20em;
width:80%;
float:right;
}
#slideShow div{
line-height:20em;
float:right;
}
#slideShow img{
vertical-align:middle;
border:solid 5px #A5A5A5;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
}
<div id="slideShow">
<?php
$dir = "carousel";
$dh = opendir($dir);
while($slide = readdir($dh)){
$items[] = $slide;
}
for($i=0; $i<sizeof($items); $i++){
if($items[$i] != "." && $items[$i] != ".."){
$imagePath = $dir."/".$items[$i];
$image = "<div>"."<img src = \"".$imagePath."\""." />"."</div>";
echo $image;
}
}
closedir($dh);
?>
</div>