CREATE TABLE IF NOT EXISTS `#__dearflip` (
                               `id`       INT(11)     NOT NULL AUTO_INCREMENT,
                               `book_title` text,
                               `df_cat` VARCHAR(255) NOT NULL DEFAULT '',


                               `published` tinyint(4) NOT NULL DEFAULT '1',
                                `ordering`  int(11)  NOT NULL DEFAULT '0',
                                `dfx_book_type_list` VARCHAR(255) NOT NULL,
                               `dfx_pdf` text,
                               `dfx_images_source` text,
                                `dfx_images_sort_by` VARCHAR(255) NOT NULL DEFAULT '1',




                               `dfx_view_mode` VARCHAR(255) NOT NULL DEFAULT '_df_book',
                               `dfx_thumb` text ,
                               `dfx_button_text` VARCHAR(255) NOT NULL ,
                               `dfx_custom_text` text,

    /*layout*/
                               `dfx_3d_2d` VARCHAR(255) NOT NULL DEFAULT 'true',
                               `dfx_hardpages` VARCHAR(255) NOT NULL DEFAULT 'none',
                               `dfx_bgColor` VARCHAR(255) NOT NULL DEFAULT '',
                                `dfx_bgImage` text,


                                `dfx_flipduration` VARCHAR(255) NOT NULL DEFAULT '',
                                `dfx_containerHeight` VARCHAR(255) NOT NULL DEFAULT '',

                               `dfx_pdfPagerenderSize` VARCHAR(255) NOT NULL DEFAULT '',
                               `dfx_autoEnableSound` VARCHAR(255) NOT NULL DEFAULT 'true',
                               `dfx_enableDownload` VARCHAR(255) NOT NULL DEFAULT 'true',
                               `dfx_pageMode` VARCHAR(255) NOT NULL DEFAULT 'null',
                               `dfx_singlePageMode` VARCHAR(255) NOT NULL DEFAULT 'null',
                               `dfx_controlsPosition` VARCHAR(255) NOT NULL DEFAULT 'bottom',
                               `dfx_hide_controls` text,
                               `dfx_direction` VARCHAR(255) NOT NULL DEFAULT '1',
                               `dfx_forcePageFit` VARCHAR(255) NOT NULL DEFAULT 'true',
                               `dfx_enableAutoPlay` VARCHAR(255) NOT NULL DEFAULT 'false',

                                `dfx_autoPlayDuration` VARCHAR(255) NOT NULL DEFAULT '',
                               `dfx_enableAutoPlayAutomatically` VARCHAR(255) NOT NULL DEFAULT 'false',
                               `dfx_pageSize` VARCHAR(255) NOT NULL DEFAULT '0',

    /*outline*/
                               `dfx_autoEnableOutline` VARCHAR(255) NOT NULL DEFAULT 'false',
                               `dfx_autoEnableThumbnail` VARCHAR(255) NOT NULL DEFAULT 'false',


                               PRIMARY KEY (`id`)
)
    ENGINE =InnoDB

    AUTO_INCREMENT =0
    DEFAULT CHARSET =utf8;

CREATE TABLE IF NOT EXISTS `#__dearflipcat` (
    `id`       INT(11)     NOT NULL AUTO_INCREMENT,
    `cat_title` VARCHAR(255) NOT NULL,
    `dfx_cat_description` text,
    `dfx_cat_view_mode` VARCHAR(255) NOT NULL DEFAULT '_df_thumb',
    `dfx_sort_books_in_cat_by`	VARCHAR(255) NOT NULL DEFAULT '1',
    `dfx_cat_button_text_type` VARCHAR(255) NOT NULL DEFAULT 'button_book_title',
    `published` tinyint(4) NOT NULL DEFAULT '1',




    PRIMARY KEY (`id`)
    )
    ENGINE =InnoDB
	AUTO_INCREMENT =0
	DEFAULT CHARSET =utf8;


CREATE TABLE IF NOT EXISTS `#__dearflipsetting` (
    `id`       INT(11)     NOT NULL AUTO_INCREMENT,


    /*layout*/
    `dfx_setting_3d_2d` VARCHAR(255) NOT NULL DEFAULT 'true',
    `dfx_setting_hardpages` VARCHAR(255) NOT NULL DEFAULT 'none',
    `dfx_setting_pdfPagerenderSize` INT(11) NOT NULL DEFAULT 1600,
    `dfx_setting_autoEnableSound` VARCHAR(255) NOT NULL DEFAULT 'true',
    `dfx_setting_enableDownload` VARCHAR(255) NOT NULL DEFAULT 'true',
    `dfx_setting_pageMode` VARCHAR(255) NOT NULL DEFAULT 'null',
    `dfx_setting_singlePageMode` VARCHAR(255) NOT NULL DEFAULT 'null',
    `dfx_setting_controlsPosition` VARCHAR(255) NOT NULL DEFAULT 'bottom',
    `dfx_setting_enableAutoPlay` VARCHAR(255) NOT NULL DEFAULT 'false',
    `dfx_setting_enableAutoPlayAutomatically` VARCHAR(255) NOT NULL DEFAULT 'false',


    /*updates */
    `dfx_setting_thumb_type` VARCHAR(255) NOT NULL DEFAULT 'div',
    `dfx_setting_enableAnalytics` VARCHAR(255) NOT NULL DEFAULT 'true',
    `dfx_setting_enableZoomOnScroll` VARCHAR(255) NOT NULL DEFAULT 'false',
    `dfx_setting_bgColor` VARCHAR(255) NOT NULL DEFAULT '#777',
    `dfx_setting_bgImage` text,
    `dfx_setting_containerHeight` VARCHAR(255) NOT NULL DEFAULT 'auto',
    `dfx_setting_paddingLeft` INT(11) NOT NULL DEFAULT 20,
    `dfx_setting_paddingRight` INT(11) NOT NULL DEFAULT 20,
    `dfx_setting_flipduration` INT(11) NOT NULL DEFAULT 800,
    `dfx_setting_zoomRatio` VARCHAR(255) NOT NULL DEFAULT '1.5',
    `dfx_setting_paperStiffness` INT(11) NOT NULL DEFAULT 3,
    `dfx_setting_moreControls` text,
    `dfx_settings_hide_controls` text,
    `dfx_setting_disablePartialLoading` VARCHAR(255) NOT NULL DEFAULT 'false',
    `dfx_setting_pdfPartialLoadingChunkSize` VARCHAR(255) NOT NULL DEFAULT '512',
    `dfx_setting_autoplayDuration` INT(11) NOT NULL DEFAULT 5000,
    `dfx_setting_pdfLinkOpenTarget` INT(11) NOT NULL DEFAULT 2,

    /*translate */
    `dfx_settings_translate_loading_message` text,
    `dfx_settings_translate_turn_on_off_sound` text,
    `dfx_settings_translate_toggle_thumbnails` text,
    `dfx_settings_translate_toggle_outline_bookmark` text,
    `dfx_settings_translate_previous_page` text,
    `dfx_settings_translate_next_page` text ,
    `dfx_settings_translate_toggle_fullscreen` text ,
    `dfx_settings_translate_zoom_in` text,
    `dfx_settings_translate_zoom_out` text ,
    `dfx_settings_translate_toggle_help` text ,
    `dfx_settings_translate_single_page_mode` text ,
    `dfx_settings_translate_double_page_mode` text ,
    `dfx_settings_translate_download_pdf_file` text,
    `dfx_settings_translate_goto_first_page` text ,
    `dfx_settings_translate_goto_last_page` text ,
    `dfx_settings_translate_play` text,
    `dfx_settings_translate_pause` text,
    `dfx_settings_translate_share` text ,
    `dfx_settings_translate_share_mail_subject` text ,
    `dfx_settings_translate_share_mail_message` text,




    PRIMARY KEY (`id`)



    )
    ENGINE =InnoDB
    AUTO_INCREMENT =0
    DEFAULT CHARSET =utf8;


/*Dual is used so that  global settings is inserted on install and only when dearflipsetting table is empty*/

INSERT INTO #__dearflipsetting (`id`)
SELECT 1 FROM DUAL
WHERE NOT EXISTS (SELECT * FROM #__dearflipsetting);