I'm using this code to read array from test.php output, sort it and then show the results like a slide show. 

there is something wrong at this line because only one of the images is displayed.

```
    curimg= (curimg < galleryarray.length)
    curimg + 1;

```

here is the code:

```
> <script type="text/javascript">
> var curimg=0;
> function rotateimages(){
> galleryarray.sort();
> document.getElementById("picsimg").setAttribute("src", "images/"+galleryarray[curimg]);
> curimg= (curimg < galleryarray.length);
> curimg + 1;
> }
>
> window.onload = function(){
> setInterval("rotateimages()", 2000);
> }
>
> setTimeout(function(){
>   window.location.reload(1);
> }, 20000);
>
> </script>
> 

```

whats wrong with my code?

another problem that i have is that when i load the page for the first time it shows a blank page for 2000 miliseconds. //or whatever value that i've set above.

Either the delay is kicking in before the images are loaded or somehow my counting is wrong. how to fix that?

this is the output from my php code: 

```
var galleryarray = new Array();
galleryarray[0] = "image1.jpg";
galleryarray[1] = "image5.jpg";
galleryarray[2] = "image2.jpg";
galleryarray[3] = "image4.jpg";
galleryarray[4] = "image8.jpg";
galleryarray[5] = "image7.jpg";
galleryarray[6] = "image0.jpg";
galleryarray[7] = "image3.jpg";
galleryarray[8] = "image6.jpg";​

```