//var imagelist = new Array();
//imagelist.push(  Array( "../userimages/image1.jpg","http://www.bridgelabs.ca","the first image" ) );
//imagelist.push(  Array( "../userimages/image2.jpg","http://www.clear-site.com","the second image" ) );
//imagelist.push(  Array( "../userimages/image2.jpg","http://www.clear-site.com","the third image" ) );

//preload all the images.
/*var pics = new Array();
for (i=0; i<imagelist.length; i++){
    // 0 = imgurl
    // 1 = alttext
    pics[i] = new Image;
    pics[i].src = imagelist[i][0];
}*/

var lastindex = 0;
function rotateimage(idname){
    var imagelist;
    var lastindex;
    eval('imagelist = imagelist_'+idname+';');
    eval('lastindex = lastindex_'+idname+';');
    
    var element = document.getElementById(idname);

    if(rotatemethod == 'ordered'){
        var index = lastindex % imagelist.length;
        lastindex++;
        eval('lastindex_'+idname+' = lastindex;');
    } else {
        var index = Math.round(Math.random() * (imagelist.length-1));
    }

    var html = "<a href='" + imagelist[index][1] + "'><img border=0' title='"+ imagelist[index][2] +"' alt='"+ imagelist[index][2] +"' src='" + imagelist[index][0] + "'></a>";

    element.innerHTML = html;
    
    if(changewhileloaded == true){
        setTimeout('rotateimage(\'' +idname+ '\')', refreshdelay * 1000);
    }
}
