CREATE TABLE IF NOT EXISTS `#__contact_enhanced_cf` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) NOT NULL,
  `label` varchar(200) NOT NULL,
  `required` tinyint(1) NOT NULL default '0',
  `type` varchar(20) NOT NULL,
  `value` mediumtext NOT NULL,
  `ordering` int(11) NOT NULL,
  `catid` int(11) NOT NULL,
  `published` tinyint(1) NOT NULL default '1',
  `attributes` mediumtext,
  `tooltip` varchar(255) default NULL,
  `iscore` tinyint(1) NOT NULL default '0',
  `params` mediumtext,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__contact_enhanced_cv` (
  `id` int(11) NOT NULL auto_increment,
  `text` varchar(100) NOT NULL,
  `value` varchar(100) NOT NULL,
  `description` mediumtext NOT NULL,
  `type` varchar(100) default NULL,
  `ordering` int(11) NOT NULL,
  `category` varchar(100) NOT NULL,
  `parent` varchar(100) default NULL,
  `published` tinyint(1) NOT NULL default '1',
  `params` mediumtext,
  PRIMARY KEY  (`id`),
  KEY `ce_cv_text_values` (`text`,`value`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__contact_enhanced_details` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `alias` varchar(255) NOT NULL default '',
  `con_position` varchar(255) default NULL,
  `address` text,
  `suburb` varchar(100) default NULL,
  `state` varchar(100) default NULL,
  `country` varchar(100) default NULL,
  `postcode` varchar(100) default NULL,
  `telephone` varchar(255) default NULL,
  `fax` varchar(255) default NULL,
  `misc` mediumtext,
  `sidebar` mediumtext,
  `image` varchar(255) default NULL,
  `imagepos` varchar(20) default NULL,
  `email_to` varchar(255) default NULL,
  `default_con` tinyint(1) unsigned NOT NULL default '0',
  `published` tinyint(1) unsigned NOT NULL default '0',
  `checked_out` int(11) unsigned NOT NULL default '0',
  `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `ordering` int(11) NOT NULL default '0',
  `params` text NOT NULL,
  `user_id` int(11) NOT NULL default '0',
  `catid` int(11) NOT NULL default '0',
  `access` tinyint(3) unsigned NOT NULL default '0',
  `mobile` varchar(255) NOT NULL default '',
  `skype` VARCHAR( 255 ) NOT NULL default '',
  `webpage` varchar(255) NOT NULL default '',
  `lat` varchar(20) NOT NULL,
  `lng` varchar(20) NOT NULL,
  `zoom` tinyint(3) unsigned NOT NULL,
  `extra_field_1` mediumtext NOT NULL,
  `extra_field_2` mediumtext NOT NULL,
  `extra_field_3` mediumtext NOT NULL,
  `extra_field_4` mediumtext NOT NULL,
  `extra_field_5` mediumtext NOT NULL,
  `extra_field_6` mediumtext NOT NULL,
  `extra_field_7` mediumtext NOT NULL,
  `extra_field_8` mediumtext NOT NULL,
  `extra_field_9` mediumtext NOT NULL,
  `extra_field_10` mediumtext NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `catid` (`catid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `#__contact_enhanced_messages` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `parent` int(11) NOT NULL default '0',
  `from_name` varchar(200) NOT NULL,
  `from_email` varchar(100) NOT NULL,
  `from_id` int(11) unsigned NOT NULL default '0' COMMENT 'Joomla user id, in case the user is logged in when he submits the form',
  `email_to` mediumtext NOT NULL,
  `email_cc` mediumtext NOT NULL,
  `email_bcc` mediumtext NOT NULL,
  `subject` varchar(255) NOT NULL,
  `contact_id` int(11) NOT NULL,
  `category_id` int(11) NOT NULL,
  `date` datetime NOT NULL,
  `reply_date` datetime NOT NULL,
  `replied_by` int(11) unsigned NOT NULL,
  `message` mediumtext NOT NULL,
  `user_ip` varchar(24) NOT NULL,
  `published` int(8) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='Recorded emails';


CREATE TABLE IF NOT EXISTS `#__contact_enhanced_message_fields` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `message_id` int(11) unsigned NOT NULL,
  `field_id` int(11) unsigned NOT NULL,
  `field_type` varchar(20) NOT NULL,
  `value` mediumtext NOT NULL,
  `modified` tinyint(1) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

