SUBROOT=ROOT + "omniscience/vote/";				// ROOT previously declared, using it to locate specific folder used
bgoing=false;							// holds talking status of bush
ggoing=false;							// holds talking status of gore
dgoing=false;							// sees if debate is going on
bt=0;
gt=0;
playing=0;							// holds status of psa player
bpics = new Array(10);
gpics = new Array(10);
for (bt=0; bt<3; ++bt)
	{bpics[bt]=new Image();
	gpics[bt]=new Image();
	gpics[bt].src="gtext" + bt + ".gif";
	bpics[bt].src="btext" + bt + ".gif";
	}
bt=0;
gpics[3]=new Image();
bpics[3]=new Image();
gpics[3].src="gheadm.gif";
bpics[3].src="bheadm.gif";	


function talk(p)
    // makes a candidate speak on a subject, p determines who 
	{going=bgoing;
	if (p=='g') going=ggoing; 
	if (going==false)
    // makes sure not already talking, if not, lets him talk
		{if (p=='g') ggoing=true;
		if (p=='b') bgoing=true;
		xyz=p + "head";
		document.getElementById(xyz).src=SUBROOT + xyz + "m.gif";
    // moves his head
		xyz=p+"text";
		words=bt;
		if (p=='g')
			{words=gt;
			gt=(gt+1)%3;
			}
		else bt=(bt+1)%3;
		document.getElementById(xyz).src=SUBROOT + xyz + words + ".gif";
    // puts word in mouth
		xyz="shutup('" + p + "')";
		setTimeout(xyz, 4200);	
    // sets mouth to stop in 4 seconds
		}
	}
function shutup(p)
    // returns candidate to non-talking status
	{if (dgoing==false)
    // if debate is going on it wont stop it
		{abc=p + "head";
		document.getElementById(abc).src=SUBROOT + abc + "s.gif";
		abc=p + "text";
		document.getElementById(abc).src=SUBROOT + "text.gif";
		if (p=='g') ggoing=false;
		if (p=='b') bgoing=false; 
		}
	}
function debate()
    // starts the debate if not already going on
	{if (dgoing==false)
		{
		sreset(true);
		speak("b", 0);
		}
	}

function sreset(g)
    // resets debate to no one talking and plain text
	{dgoing=ggoing=bgoing=g;
	document.getElementById("bhead").src=SUBROOT + "bheads.gif";
	document.getElementById("ghead").src=SUBROOT + "gheads.gif";
	document.getElementById("btext").src=document.getElementById("gtext").src=SUBROOT + "text.gif";
	}
function speak(p, n)
    // controls debate turns and ends it, one person speaks, then next, etc. to end 
	{w=p + "text";
	h=p + "head";
	if (p=="b") p="g";
	else p="b";
	document.getElementById(p + "head").src=SUBROOT+ p+ "heads.gif";
	document.getElementById(p + "text").src=SUBROOT + "text.gif";
	document.getElementById(w).src=SUBROOT + w + n + ".gif";
	document.getElementById(h).src=SUBROOT + h + "m.gif";
	if (p=="b") ++n;
	if (n>=3) w="sreset(false)";
	else w="speak('" + p + "', " + n + ")";
	setTimeout(w, 4200);
	}

function playpsa(n) 
    // prints html to screen to play psa message
 	{if (playing==0)
    // if playing one, won't let it start another
		{playing=1;
		player="<embed src='" + ROOT + "omniscience/vote/psa"+n+".wav' hidden=true autostart=true loop=false>";
		document.getElementById("psaplayer").innerHTML= player;
		setTimeout("playing=0;", 5000);
		}
	
	}

	

