var secs;
var secs2;
var timerID = null;
var timerRunning = false;
var delay = 1000;
var docdir;
function InitializeTimer(dir)
{
    // Set the length of the timer, in seconds
    secs = 0;
	secs2 = 11;
    StopTheClock();
	docdir=dir;
	StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock();

        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
		//console.log(docdir);
		url = docdir+"chat_msg.php";
		loadURL(url,"chatText");		
        
	    secs = 1;
		secs2++;
		timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
    else
    {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
	if (secs2==12)
	{
		url = docdir+"onlineusers.php";
        loadURL(url,"onlineText");
		secs2=0;
	}
}