<?php
require("includes_path.php");
include ( $includes_path . "/settings.inc");
include ( $includes_path . "/globalfunctions.inc");
include ( $includes_path . "/functionhtml.inc");

// Latest Poll
  		$latest_query = mysql_query("SELECT pid FROM be_sympoll_list WHERE status='1' ORDER BY timeStamp DESC LIMIT 0,1") or mysql_die();
  		$latest_array = mysql_fetch_array($latest_query);
  		$latest_poll = $latest_array["pid"];

require ($includes_path . "/classes/plist.php3");
require ($includes_path . "/booth.php3");


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
// DISPLAYS LIST OF POLLS
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

// This shouldn't be required, but $mypollid is being reset to the default...
$selected_poll = $mypollid;

$l = new PList();

$content .= "
	<TABLE BORDER=\"0\" CELLSPACING=\"15\" CELLPADDING=\"0\" WIDTH=\"85%\" ALIGN=\"center\">
	<TR><TD VALIGN=\"top\">

	<TABLE BORDER=\"0\" CELLSPACING=\"15\" CELLPADDING=\"0\" WIDTH=\"100%\">
	<TR><TD>
  
	<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\" BGCOLOR=\"$symp_table_border\" WIDTH=\"100%\">
	<TR><TD>
	<TABLE BORDER=\"0\" CELLPADDING=\"5\" CELLSPACING=\"0\" BGCOLOR=\"$symp_table_bg\" WIDTH=\"100%\">
	<TR><TD>
	<FONT COLOR=\"$symp_table_tx\"><B>&nbsp;Current Polls:</B></FONT>
	</TD></TR></TABLE>
	</TD></TR></TABLE>

	</TD></TR><TR><TD>

	<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\" BGCOLOR=\"$symp_table_border\" WIDTH=\"100%\">
	<TR><TD>
	<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"0\" BGCOLOR=\"$symp_table_bg\" WIDTH=\"100%\">
	<TR><TD VALIGN=\"top\">\n";

$content .=  "<FONT SIZE=\"2\"><BR>";
$anypolls = FALSE;
while(sizeof($l->question) != 0 && list($k,$v) = each($l->question)) {
    if($l->status[$k] != 0) {
		$anypolls = TRUE;
		$content .= "&nbsp;&nbsp;&nbsp; o &nbsp;";
		$content .= "<A HREF=\"polllist.php3?mypollid=$k\">$v</A>";
		$content .= "<BR>\n";
	}
}
reset($l->question);
if ($anypolls == FALSE) { 
	$content .= "&nbsp;&nbsp;&nbsp; There are currently no polls available.<BR>"; 
	}
$content .= "</FONT><BR>";

$content .= "
	</TD></TR></TABLE>
	</TD></TR></TABLE>
	</TD></TR></TABLE>

	</TD><TD VALIGN=\"top\">\n\n";
	if(isset($mypollid)) {
 		// $content .=   display_booth($mypollid);
 		$pid = $selected_poll;
 		$content .=   display_booth();
	} else {
  		$content .= "<strong>Latest Poll</strong>";
  		$pid = $latest_poll;
			$content .=   display_booth();
	}
  $content .= "</TD></TR></TABLE>\n\n";
  
include ( $includes_path . "/functionhtml.inc");

// echo  $content; 
        
// database connect
  mysql_pconnect($hostname, $username, $password) or die ("Error connecting");
  mysql_select_db($database);
  
$template = "main.tpl";	

include ( $includes_path . "/template.inc");
$content =  $content;  
include ($includes_path . "/template_includes.inc");

?>
