﻿String.prototype.endsWith = function(str) {return (this.match(str+"$")==str)};

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(InitializeTimer);

var SECONDS_BETWEEN_IMAGE_SWAP = 7;
var secs
var timerID = null
var timerRunning = false
var delay = 1000
var isAutismImageBlue = true;

function InitializeTimer()
{
        //alert("currentAutismImageSrc is: " + "test");
    // Set the length of the timer, in seconds
    secs = SECONDS_BETWEEN_IMAGE_SWAP
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
//        var myLinkStyleClassName = document["joinTheListLink"].style;
        var myLinkStyleClassName = document.getElementById('joinTheListLink').className;
        //alert("myLinkStyleClassName is: " + myLinkStyleClassName );
        if(myLinkStyleClassName.endsWith("topmenu")){
	         document.getElementById('joinTheListLink').className = 'topmenuorange';
	         document.getElementById('joinTheListLink2').className = 'topmenuorange';	         
        }else{
	         document.getElementById('joinTheListLink').className= 'topmenu';
	         document.getElementById('joinTheListLink2').className= 'topmenu';	         
        }
        
        InitializeTimer();
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}


