
window.onload = initAll;

function initAll() {

     choosePic ();
     initDate();
     rotate();
     initLinks();
     processPrevious();
      processNext();
      
}

// VAR

var adImages = new Array("images/Rotator/insidestore11.jpg", "images/Rotator/Milo.jpg","images/Rotator/insidestore12.jpg","images/Rotator/insidestore13.jpg","images/Rotator/insidestore14.jpg","images/Rotator/insidestore2.jpg",
 "images/Rotator/insidestore3.jpg","images/Rotator/Odo.jpg","images/Rotator/insidestore4.jpg","images/Rotator/insidestore5.jpg","images/Rotator/goat.jpg",
 "images/Rotator/Movie.jpg", "images/Rotator/makere.jpg","images/Rotator/Marugbotakebe.jpg","images/Rotator/panla Gbibe.jpg",
 "images/Rotator/Titus Pupa.jpg","images/Rotator/Fro Fish.jpg","images/Rotator/Fever Leaves.jpg","images/Rotator/Eja Yiyan.jpg",
 "images/Rotator/Custard 1.jpg","images/Rotator/Cassava leaves.jpg","images/Rotator/Nido.jpg");
var thisAd = 0;

var dayName = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var myPix = new Array("images/Fourth of July Fire Works 1.jpg", "images/jimmy4.jpg", "images/jimmy5.jpg");
var thisPic = 0;


var now = new Date();

//FUNCTIONS

    function choosePic() {
        thisAd = Math.floor((Math.random() * adImages.length));
        document.getElementById("alagbado").src = adImages[thisAd];

        rotate();
    }

    function rotate() {
        thisAd++;
        if (thisAd == adImages.length) {
            thisAd = 0;
        }
        document.getElementById("alagbado").src = adImages[thisAd];

        setTimeout(rotate, 6 * 1000);
    }

    function initDate() {
       
        var now = new Date();
        var dtString = dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate();

        document.getElementById("dtField").innerHTML = dtString;
    }

    

//Picture View
    function initLinks() {
        document.getElementById("prevLink").onclick = processPrevious;
        document.getElementById("nextLink").onclick = processNext;
    }

    function processPrevious() {
        if (thisPic == 0) {
            thisPic = myPix.length;
        }
        thisPic--;
        document.getElementById("myPicture").src = myPix[thisPic];
        return false;
    }

    function processNext() {
        thisPic++;
        if (thisPic == myPix.length) {
            thisPic = 0;
        }
        document.getElementById("myPicture").src = myPix[thisPic];
        return false;
    }
