var secs
var timerID = null
var timerRunning = false
var delay = 1000
var displayCount = 2;

window.onload = InitializeTimer

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 3
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{

    if (secs==0)
    {
        StopTheClock()
        InitializeTimer()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("You have just wasted 10 seconds of your life.")
        if(displayCount > noImgs)
          displayCount = 1;
        swapImage(displayCount++, imgPath, noImgs, "ALTTEXT")
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}


function showImage(path,alt){
		document.getElementById("mainImage").src = path;
		document.getElementById("mainImage").alt = alt;
	}

	function changeClass(id, newClass) {
		identity=document.getElementById(id);
		identity.className=newClass;
	}


	function selectImage(imgNumber, imgBaseName, noOfLi, alt){
    StopTheClock()
	  swapImage(imgNumber, imgBaseName, noOfLi, alt);
	}

	function swapImage(imgNumber, imgBaseName, noOfLi, alt){

		for(i = 1; i <= noOfLi; i++)
			changeClass("li_"+i, "not_selected");
		changeClass("li_"+imgNumber, "selected");
		showImage(imgBaseName+imgNumber+'.jpg', alt);
	}

