/*
This script was written by Steve Reynolds for www.themouthpiece.com 
Copyright themouthpiece.com 1st June 2007
*/
var tmpNextThread=0;

function tmpDisplayNextThread(position,text)
{
 document.getElementById("tmpLink" + position).innerHTML=text;
 
}

function tmpWritePanelContent(number)
{
  if (gotThreadsOk())
  {
 	for (var i=0;i<number;i++)
	 {
  		tmpDisplayNextThread(i,threads[tmpNextThread].link);
  		tmpNextThread++;
 		if  (tmpNextThread == threads.length)
 		{
 			 tmpNextThread=0;
 		}
 	 }
 }
 else
 {
 	tmpDisplayNextThread(0,"Sorry, could not connect to server");
 }
}

function timerexp()
{
 tmpWritePanelContent(tmpPanelCount);
 timer= setTimeout('timerexp()',tmpPanelRotationTime*1000);
}

function gotThreadsOk()
{
	return Boolean(typeof threads  != 'undefined' && threads);
}

function tmpStartPanel()
{
// did the server load up the threads ok?
if(gotThreadsOk())
{
	for (var i=0;i<threads.length;i++)
	{
 		threads[i].link="<a class=\"tmpPanel\" href=\"http://www.themouthpiece.com/vb/showthread.php?t="+threads[i].threadid +" target=_blank\">" + threads[i].title+"<\/a>";
	}
}
document.write("<table class=\"tmpPanel\">");
document.write("<tr class=\"tmpPanel\"><th class=\"tmpPanel\" colspan=\"2\" ><\/th><\/tr>");

for (var i=0;i<tmpPanelCount;i++)
{
 document.write("<tr class=\"tmpPanel\">");
 document.write("<td class=\"tmpImg\" >");
 document.write("<\/td>");
 document.write("<td class=\"tmpPanel\" id=\"tmpLink" +i + "\">");
 document.write("<\/td>");
 document.write("<\/tr>");
}

document.write("<\/table>");


	tmpWritePanelContent(tmpPanelCount);
	if (tmpPanelDoTimedRotate==true)
	{
 		timer= setTimeout('timerexp()',tmpPanelRotationTime*1000);
	}
}