// JavaScript Document

/*
 * Simple image rotator.
 */
function setRandomImageAndLink(linksArray, anchorid, imageid, target)
{
    if (target == null)
    {
        target = "_blank";
    }

    var currentdate = new Date();
    var index = currentdate.getSeconds() % linksArray.length;
    var link = linksArray[index][0];
    var imagesrc = linksArray[index][1];
    var imagealt = linksArray[index][2];

    var anchor = document.getElementById(anchorid);
    if (anchor != null)
    {
        anchor.setAttribute("href", link);
    }

    var image = document.getElementById(imageid);
    if (image != null)
    {
        image.setAttribute("src", imagesrc);
        image.setAttribute("alt", imagealt);
    }
}