var IE = false;
var NS = false;
if (document.all) IE = true;
if (document.layers) NS = true;
function readCookie(name)
{
	if (document.cookie == '') return false;
	else
	{
		var c0, c1;
		var cookie = document.cookie;
		c0 = cookie.indexOf(name);
		if(c0 != -1)
		{
			c0 += name.length + 1;
			c1 = cookie.indexOf(';', c0);
			if(c1 == -1) c1 = cookie.length;
			return unescape(cookie.substring(c0,c1));
		}
		else return false;
    }
}
function writePoll(application,id,question,answers,answerIDs,votes,sumvotes,action,pollSize)
{
	var s = '';
	if (action == null) action='';
	if (NS) var size=10; else var size=12;
	s+="<table cellspacing=0 cellpadding=2>";

	s+="<form name='Poll_"+id+"' action='"+action+"' method='post' target='_top'>";
	s+="<input type=hidden name=P"+id+" value="+id+">";
	s+="<input type=hidden name=Display.objectsAvailable value="+id+">";
	s+="<tr>";
	s+="	<td align=center colspan=2>";
	s+="		<span class='PollQuestion'><b>"+question+"</b></span>";
	s+="	</td>";
	s+="</tr>";
	if (readCookie(application.toUpperCase()+".PA"+id))
	{
		for (i=0;i<answers.length;i++)
			{
				percent = Math.floor(votes[i]/sumvotes*100);
				width = percent+1;
				s+="<tr>";
				s+="	<td align=center colspan=2>";
				s+="		<Table cellpadding=0 cellspacing=2 width=100%>";
				s+="		<tr>";
				s+="			<td valign=top>";
				s+="				<span style='font-size=9'>";
				s+="				<img src=/images/design/ltbluedot.gif width="+width+" height=10> "+percent+"% -";
				s+="				"+answers[i]+"</font></span><br>";
				s+="			</td>";
				s+="		</tr>";
				s+="		</table>";
				s+="	</td>";
				s+="</tr>";
			}
		s+="<tr align=center>";
		s+="	<td colspan=2>";
		s+="	<span style='font-size=10'>";
		s+="		"+sumvotes+" Total Votes</font>";
		s+="	</span>";
		s+="	</td>";
		s+="</tr>";
	}
	else
	{
		s+="<tr>";
		s+="	<td colspan=2>";
		for (i=0;i<answers.length;i++)
		{
			s+="		<span><input type=radio class='Radio' name=a value="+answerIDs[i]+"></span><span";
			s+="			style='font-size="+(size-2)+"'>"+answers[i]+"</font></span>";
			s+="			<br>";
		}
		s+="</tr>";
		s+="<tr><td colspan=2 align=center><input type=image src='/images/design/poll_vote.gif' border=0 width=60 height=23></td>";
	}
	s+="</tr>";
	s+="</form>";
	s+="</table>";
	document.write(s);
}

