//+trace dis

// load the standard form creation utilities
$this->execPieceByName('ff_InitLib');

// create table if it does not yet exist
ff_query(
    "CREATE TABLE IF NOT EXISTS `#__rnr_contest` (".
        "`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,".
        "`userid` INT( 11 ) DEFAULT '0' NOT NULL ,".
        "`couple` VARCHAR( 50 ) NOT NULL ,".
        "`age` TINYINT( 1 ) DEFAULT '0' NOT NULL ,".
        "`acro` TINYINT( 1 ) DEFAULT '0' NOT NULL ,".
        "`fun` TINYINT( 1 ) DEFAULT '0' NOT NULL ,".
        "`boogie` TINYINT( 1 ) DEFAULT '0' NOT NULL,".
        "PRIMARY KEY  (`id`)".
    ") TYPE=MyISAM AUTO_INCREMENT=1"
);

// load old record if any
global $record;
$rows = ff_select("select * from `#__rnr_contest` where userid=".JFactory::getUser()->get('id',0));
if (count($rows)) {
   $record = $rows[0];
   ff_setChecked('age', $record->age);
   if ($record->acro  ) ff_setChecked('acro'  ,'1');
   if ($record->fun   ) ff_setChecked('fun'   ,'1');
   if ($record->boogie) ff_setChecked('boogie','1');
} else
   $record = NULL;