<?php
if( $a == 'list' ){
	if( isset( $sOption ) ) $content.= $oTpl->parse( 'message_done.tpl' );
	$aPolls = throwPolls( );
	$oTpl->assign( 'aPolls', $aPolls );
	$content.= $oTpl->parse( 'polls_list.tpl' );
} elseif( $a == 'form' ){
	if( isset( $_POST['sOption'] ) ){
		$iPoll = savePoll( $_POST );
		header( 'Location: ' . $_SERVER['PHP_SELF'] . '?p=' . $p . '&sOption=save&iPoll=' . $iPoll );
		exit;
	}
	if( isset( $sOption ) ) $content.= $oTpl->parse( 'message_done.tpl' );
	if( isset( $iPoll ) && is_numeric( $iPoll ) ){
		$aPoll = throwPollData( $iPoll );
	} else{
		$aPoll['iPollId'] = null;
	}
	$oTpl->assign( 'aPoll', $aPoll );
	$content.= $oTpl->parse( 'polls_form.tpl' );
} elseif( $a == 'delete' && isset( $iPoll ) && is_numeric( $iPoll ) ){
	deletePoll( $iPoll );
	header( 'Location: ' . $_SERVER['PHP_SELF'] . '?p=' . $aActions['f'] . '-list&sOption=del' );
	exit;
} ?>