//-- (c) Damian Smith 2008

var current_image = 0;

function randomNo(no_of_images) {
    return parseInt(Math.random(1) * no_of_images);  
    }
    
    //-- get next image
function changeImageNo(no_of_images) {
    current_image++;
    if(current_image>no_of_images) current_image = 0;
    return parseInt(Math.random(1) * no_of_images);  
    }

function rotateImage(name, images_array, select_image_no) {
    //images_array.splice(current_image); // remove current image from array.
    var no_of_images = images_array.length;
    if(isNaN(select_image_no)) { 
        //select_image_no = randomNo(no_of_images);
        select_image_no = changeImageNo(no_of_images);
        if(select_image_no == current_image) select_image_no = randomNo(no_of_images);     
        }
    if(document.images[name]) the_image = document.images[name];   //-- use name tag
    else if(document.getElementById(name)) the_image = document.getElementById(name); //else use ID tag  
    the_image.src = images_array[select_image_no][0];
    
    if(images_array[select_image_no][2]) var image_title = images_array[select_image_no][2];      
    else var image_title = "Weymouth Seafront Guest House";   
    the_image.title = image_title;
    the_image.alt = image_title;
    return select_image_no;
    }