<?php


# FOLDER
$folder = 'warhol';

# FONTS
$font = 'museo-sans';
// font / template_font
if (!empty($_GET['font'])) {
 $font = $_GET['font'];
} else if (isset($GLOBALS['H']['template_font'])) { // DEPRECATED!!!! TO BE DELETED!!!!
 $font = $GLOBALS['H']['template_font']; // DEPRECATED!!!! TO BE DELETED!!!!
}

$font_body = $font;
$font_title = $font;
// font_title / template_font_title
if (!empty($_GET['font_title'])) {
 $font_title = $_GET['font_title'];
} else if (isset($GLOBALS['H']['template_font_title'])) { // DEPRECATED!!!! TO BE DELETED!!!!
 $font_title = $GLOBALS['H']['template_font_title']; // DEPRECATED!!!! TO BE DELETED!!!!
}

// font_body / template_font_body
if (!empty($_GET['font_body'])) {
 $font_body = $_GET['font_body'];
} else if (isset($GLOBALS['H']['template_font_body'])) { // DEPRECATED!!!! TO BE DELETED!!!!
 $font_body = $GLOBALS['H']['template_font_body']; // DEPRECATED!!!! TO BE DELETED!!!!
}


# COLORS
$menu = 'inverse'; //inverse o default
$color = 'navy';



$colors = array(
    'autumn' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '312a22'),
        '02' => array('hex' => '51473b'),
        '02_01' => array('hex' => '29221b'),
        '02_02' => array('hex' => '352d24'),
        '02_03' => array('hex' => '41382e'),
        '03' => array('hex' => '928473'),
        '03_01' => array('hex' => '695d4e'),
        '03_02' => array('hex' => '726555'),
        '03_03' => array('hex' => '837666'),
        '04' => array('hex' => 'f2edda'),
        '05' => array('hex' => 'bb4418'),
        '05_01' => array('hex' => '912f0a'),
        '05_02' => array('hex' => '9f350e'),
        '05_03' => array('hex' => 'ad3c12'),
        '05_04' => array('hex' => 'd2a290'),
        '05_05' => array('hex' => 'dfae9c'),
        'footer-fg' => array('hex' => 'f2edda'),
        'footer-bg' => array('hex' => '312a22'),
        'footer-link' => array('hex' => '928473')
    ),
    'black' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => 'ffffff'),
        'bg' => array('hex' => '000000'),
        'ok' => array('hex' => '77975e'),
        'ko' => array('hex' => 'f45d4e'),
        '01' => array('hex' => 'efefef'),
        '02' => array('hex' => 'c6c6c6'),
        '02_01' => array('hex' => 'b7b4b4'),
        '02_02' => array('hex' => 'aaa6a6'),
        '02_03' => array('hex' => '999595'),
        '03' => array('hex' => '888888'),
        '03_01' => array('hex' => '777777'),
        '03_02' => array('hex' => '666666'),
        '03_03' => array('hex' => '555555'),
        '04' => array('hex' => '212121'),
        '05' => array('hex' => 'f45d4e'),
        '05_01' => array('hex' => 'e55344'),
        '05_02' => array('hex' => 'd84a3c'),
        '05_03' => array('hex' => 'cc4639'),
        '05_04' => array('hex' => '661f18'),
        '05_05' => array('hex' => '5a1c16'),
        'footer-fg' => array('hex' => 'c6c6c6'),
        'footer-bg' => array('hex' => '000000'),
        'footer-link' => array('hex' => 'f45d4e')
    ),
    'citric' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '519d55'),
        'ko' => array('hex' => '9d5551'),
        '01' => array('hex' => '0e5797'),
        '02' => array('hex' => '0e5797'),
        '02_01' => array('hex' => '093862'),
        '02_02' => array('hex' => '0b487c'),
        '02_03' => array('hex' => '0e5797'),
        '03' => array('hex' => '87b2d8'),
        '03_01' => array('hex' => '093862'),
        '03_02' => array('hex' => '0b487c'),
        '03_03' => array('hex' => '0e5797'),
        '04' => array('hex' => 'c3d8eb'),
        '05' => array('hex' => 'd94400'),
        '05_01' => array('hex' => '361100'),
        '05_02' => array('hex' => '571b00'),
        '05_03' => array('hex' => '8d2c00'),
        '05_04' => array('hex' => 'b33800'),
        '05_05' => array('hex' => 'd94400'),
        'footer-fg' => array('hex' => 'c3d8eb'),
        'footer-bg' => array('hex' => '0e5797'),
        'footer-link' => array('hex' => '87b2d8')
    ),
    'deep-purple' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '519d55'),
        'ko' => array('hex' => '9d5551'),
        '01' => array('hex' => '302b2f'),
        '02' => array('hex' => '312c30'),
        '02_01' => array('hex' => '342f33'),
        '02_02' => array('hex' => '3e393d'),
        '02_03' => array('hex' => '514c50'),
        '03' => array('hex' => 'cbc6ca'),
        '03_01' => array('hex' => '635f62'),
        '03_02' => array('hex' => '767275'),
        '03_03' => array('hex' => '8e8a8e'),
        '04' => array('hex' => 'cdcbcc'),
        '05' => array('hex' => '4a024c'),
        '05_01' => array('hex' => '4b034d'),
        '05_02' => array('hex' => '560e58'),
        '05_03' => array('hex' => '540c56'),
        '05_04' => array('hex' => '6f2871'),
        '05_05' => array('hex' => '924c94'),
        'footer-fg' => array('hex' => 'cdcbcc'),
        'footer-bg' => array('hex' => '302b2f'),
        'footer-link' => array('hex' => 'cbc6ca')
    ),
    'elegant' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '2b2e38'),
        '02' => array('hex' => '60626a'),
        '02_01' => array('hex' => '37383d'),
        '02_02' => array('hex' => '4d4e55'),
        '02_03' => array('hex' => '54565d'),
        '03' => array('hex' => 'a1a8ad'),
        '03_01' => array('hex' => '737d84'),
        '03_02' => array('hex' => '8b949a'),
        '03_03' => array('hex' => '939ba1'),
        '04' => array('hex' => 'cacbcd'),
        '05' => array('hex' => '6d0036'),
        '05_01' => array('hex' => '16000b'),
        '05_02' => array('hex' => '440022'),
        '05_03' => array('hex' => '530029'),
        '05_04' => array('hex' => 'd1afc6'),
        '05_05' => array('hex' => 'dabfcd'),
        'footer-fg' => array('hex' => 'cacbcd'),
        'footer-bg' => array('hex' => '2b2e38'),
        'footer-link' => array('hex' => 'a1a8ad'),
        'dark' => array('hex' => '49182d'),
        'light' => array('hex' => 'f6f7f7')
    ),
    'fresh' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '163955'),
        '02' => array('hex' => '2f5d81'),
        '02_01' => array('hex' => '1b3d58'),
        '02_02' => array('hex' => '224866'),
        '02_03' => array('hex' => '295374'),
        '03' => array('hex' => 'a4cced'),
        '03_01' => array('hex' => '7aa3c4'),
        '03_02' => array('hex' => '89b0d1'),
        '03_03' => array('hex' => '96bedf'),
        '04' => array('hex' => 'ebf4fb'),
        '05' => array('hex' => '9eb100'),
        '05_01' => array('hex' => '7c8b01'),
        '05_02' => array('hex' => '879702'),
        '05_03' => array('hex' => '92a300'),
        '05_04' => array('hex' => 'cdd496'),
        '05_05' => array('hex' => 'd9e0a2'),
        'footer-fg' => array('hex' => 'ebf4fb'),
        'footer-bg' => array('hex' => '163955'),
        'footer-link' => array('hex' => 'a4cced')
    ),
    'golden' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'f6f5f3'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '271b0f'),
        '02' => array('hex' => '271b0f'),
        '02_01' => array('hex' => '0c0803'),
        '02_02' => array('hex' => '0e0905'),
        '02_03' => array('hex' => '1b120a'),
        '03' => array('hex' => 'dad1b5'),
        '03_01' => array('hex' => 'ada487'),
        '03_02' => array('hex' => 'bab195'),
        '03_03' => array('hex' => 'c8bfa3'),
        '04' => array('hex' => 'eae4d2'),
        '05' => array('hex' => 'a09266'),
        '05_01' => array('hex' => '736741'),
        '05_02' => array('hex' => '83764d'),
        '05_03' => array('hex' => '918459'),
        '05_04' => array('hex' => 'd0c399'),
        '05_05' => array('hex' => 'ddd1ab'),
        'footer-fg' => array('hex' => 'eae4d2'),
        'footer-bg' => array('hex' => '271b0f'),
        'footer-link' => array('hex' => 'dad1b5')
    ),
    'golden-dark' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => 'ffffff'),
        'bg' => array('hex' => '000000'),
        'ok' => array('hex' => '77975e'),
        'ko' => array('hex' => 'f45d4e'),
        '01' => array('hex' => 'efefef'),
        '02' => array('hex' => 'c6c6c6'),
        '02_01' => array('hex' => 'b7b4b4'),
        '02_02' => array('hex' => 'aaa6a6'),
        '02_03' => array('hex' => '999595'),
        '03' => array('hex' => '555555'),
        '03_01' => array('hex' => '474545'),
        '03_02' => array('hex' => '383636'),
        '03_03' => array('hex' => '2b2929'),
        '04' => array('hex' => '212121'),
        '05' => array('hex' => 'c6b07c'),
        '05_01' => array('hex' => 'b5a06e'),
        '05_02' => array('hex' => 'a48f60'),
        '05_03' => array('hex' => '937f51'),
        '05_04' => array('hex' => '826e43'),
        '05_05' => array('hex' => '715e35'),
        'footer-fg' => array('hex' => '212121'),
        'footer-bg' => array('hex' => 'efefef'),
        'footer-link' => array('hex' => '555555')
    ),
    'mustard' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => 'ffffff'),
        'bg' => array('hex' => '1f1d15'),
        'ok' => array('hex' => '77975e'),
        'ko' => array('hex' => 'bd2819'),
        '01' => array('hex' => 'ffffeb'),
        '02' => array('hex' => 'd7d2b1'),
        '02_01' => array('hex' => 'cac5a1'),
        '02_02' => array('hex' => 'b9b492'),
        '02_03' => array('hex' => 'aca783'),
        '03' => array('hex' => '89846d'),
        '03_01' => array('hex' => '7a755f'),
        '03_02' => array('hex' => '6e6952'),
        '03_03' => array('hex' => '5f5a44'),
        '04' => array('hex' => '343122'),
        '05' => array('hex' => 'dcc248'),
        '05_01' => array('hex' => 'cdb43d'),
        '05_02' => array('hex' => 'bea633'),
        '05_03' => array('hex' => 'b19a2d'),
        '05_04' => array('hex' => '584f23'),
        '05_05' => array('hex' => '49411c'),
        'footer-fg' => array('hex' => '343122'),
        'footer-bg' => array('hex' => 'ffffeb'),
        'footer-link' => array('hex' => '89846d')
    ),
    'nature' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'f5f3f3'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '411d0e'),
        '02' => array('hex' => '543326'),
        '02_01' => array('hex' => '5d3f32'),
        '02_02' => array('hex' => '5d3f32'),
        '02_03' => array('hex' => '97837b'),
        '03' => array('hex' => 'c9bcb6'),
        '03_01' => array('hex' => 'a58f86'),
        '03_02' => array('hex' => 'b7a69e'),
        '03_03' => array('hex' => 'c9bcb6'),
        '04' => array('hex' => 'e7e7e9'),
        '05' => array('hex' => '859826'),
        '05_01' => array('hex' => '9dad51'),
        '05_02' => array('hex' => '9dad51'),
        '05_03' => array('hex' => 'a9b767'),
        '05_04' => array('hex' => 'b6c17d'),
        '05_05' => array('hex' => 'c2cb92'),
        'footer-fg' => array('hex' => 'e7e7e9'),
        'footer-bg' => array('hex' => '411d0e'),
        'footer-link' => array('hex' => 'c9bcb6')
    ),
    'navy' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '2b2e38'),
        '02' => array('hex' => '565a66'),
        '02_01' => array('hex' => '333742'),
        '02_02' => array('hex' => '3d424e'),
        '02_03' => array('hex' => '484c59'),
        '03' => array('hex' => '8e9099'),
        '03_01' => array('hex' => '606371'),
        '03_02' => array('hex' => '6e717e'),
        '03_03' => array('hex' => '80828d'),
        '04' => array('hex' => 'e6e2e1'),
        '05' => array('hex' => '155a91'),
        '05_01' => array('hex' => '0a3e67'),
        '05_02' => array('hex' => '0d4776'),
        '05_03' => array('hex' => '115184'),
        '05_04' => array('hex' => '9ab3c8'),
        '05_05' => array('hex' => 'a8c2d6'),
        'footer-fg' => array('hex' => 'e6e2e1'),
        'footer-bg' => array('hex' => '2b2e38'),
        'footer-link' => array('hex' => '8e9099')
    ),
    'neutral' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => '313131'),
        '02' => array('hex' => '5e5e5e'),
        '02_01' => array('hex' => '3a3a3a'),
        '02_02' => array('hex' => '454545'),
        '02_03' => array('hex' => '505050'),
        '03' => array('hex' => '939393'),
        '03_01' => array('hex' => '686868'),
        '03_02' => array('hex' => '767676'),
        '03_03' => array('hex' => '868686'),
        '04' => array('hex' => 'f1f1f1'),
        '05' => array('hex' => 'a8c240'),
        '05_01' => array('hex' => '657426'),
        '05_02' => array('hex' => '75872d'),
        '05_03' => array('hex' => '8fa536'),
        '05_04' => array('hex' => 'e1eabc'),
        '05_05' => array('hex' => 'eef3d9'),
        'footer-fg' => array('hex' => 'f1f1f1'),
        'footer-bg' => array('hex' => '313131'),
        'footer-link' => array('hex' => '939393')
    ),
    'sand-dunes' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '00cc00'),
        'ko' => array('hex' => 'cc0000'),
        '01' => array('hex' => 'cf7000'),
        '02' => array('hex' => '8e7c66'),
        '02_01' => array('hex' => '635442'),
        '02_02' => array('hex' => '72614d'),
        '02_03' => array('hex' => '7f6d58'),
        '03' => array('hex' => 'd9c2a7'),
        '03_01' => array('hex' => 'af9679'),
        '03_02' => array('hex' => 'bda487'),
        '03_03' => array('hex' => 'ccb497'),
        '04' => array('hex' => 'f5f1ee'),
        '05' => array('hex' => 'ff4200'),
        '05_01' => array('hex' => 'd93b03'),
        '05_02' => array('hex' => 'e53b00'),
        '05_03' => array('hex' => 'f33f00'),
        '05_04' => array('hex' => 'cba89b'),
        '05_05' => array('hex' => 'dab7aa'),
        'footer-fg' => array('hex' => 'f5f1ee'),
        'footer-bg' => array('hex' => 'cf7000'),
        'footer-link' => array('hex' => 'd9c2a7')
    ),
    'slate' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => 'e9eaeb'),
        'bg' => array('hex' => '2c2d2e'),
        'ok' => array('hex' => '77975e'),
        'ko' => array('hex' => 'f45d4e'),
        '01' => array('hex' => 'e9eaeb'),
        '02' => array('hex' => 'a3a4a5'),
        '02_01' => array('hex' => '999a9b'),
        '02_02' => array('hex' => '8e8f90'),
        '02_03' => array('hex' => '828384'),
        '03' => array('hex' => '828384'),
        '03_01' => array('hex' => '999a9b'),
        '03_02' => array('hex' => '8e8f90'),
        '03_03' => array('hex' => '828384'),
        '04' => array('hex' => '545556'),
        '05' => array('hex' => '8f8b86'),
        '05_01' => array('hex' => 'b7b3ae'),
        '05_02' => array('hex' => 'afaba6'),
        '05_03' => array('hex' => 'a8a49f'),
        '05_04' => array('hex' => '9e9a95'),
        '05_05' => array('hex' => '8f8b86'),
        'footer-fg' => array('hex' => 'e9eaeb'),
        'footer-bg' => array('hex' => '2c2d2e'),
        'footer-link' => array('hex' => 'a3a4a5')
    ),
    'tangerine' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '519d55'),
        'ko' => array('hex' => '9d5551'),
        '01' => array('hex' => '3c3c3c'),
        '02' => array('hex' => '5b534b'),
        '02_01' => array('hex' => '743c01'),
        '02_02' => array('hex' => '934c01'),
        '02_03' => array('hex' => 'b25b02'),
        '03' => array('hex' => 'bfbfbf'),
        '03_01' => array('hex' => '3f3f3f'),
        '03_02' => array('hex' => '7f7f7f'),
        '03_03' => array('hex' => '3c3c3c'),
        '04' => array('hex' => 'bfbfbf'),
        '05' => array('hex' => 'd16c02'),
        '05_01' => array('hex' => '341b01'),
        '05_02' => array('hex' => '542b01'),
        '05_03' => array('hex' => '743c01'),
        '05_04' => array('hex' => '934c01'),
        '05_05' => array('hex' => 'b25b02'),
        'footer-fg' => array('hex' => 'bfbfbf'),
        'footer-bg' => array('hex' => '3c3c3c'),
        'footer-link' => array('hex' => 'bfbfbf')
    ),
    'test' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '519d55'),
        'ko' => array('hex' => '9d5551'),
        '01' => array('hex' => 'ff0000'),
        '02' => array('hex' => 'ffff00'),
        '02_01' => array('hex' => '3e3e00'),
        '02_02' => array('hex' => '646400'),
        '02_03' => array('hex' => '8a8a00'),
        '03' => array('hex' => '00ff00'),
        '03_01' => array('hex' => '102e10'),
        '03_02' => array('hex' => '1a4a1a'),
        '03_03' => array('hex' => '236723'),
        '04' => array('hex' => '0000ff'),
        '05' => array('hex' => 'ff00ff'),
        '05_01' => array('hex' => '340a34'),
        '05_02' => array('hex' => '370737'),
        '05_03' => array('hex' => '721872'),
        '05_04' => array('hex' => '721872'),
        '05_05' => array('hex' => '921e92'),
        'footer-fg' => array('hex' => '0000ff'),
        'footer-bg' => array('hex' => 'ff0000'),
        'footer-link' => array('hex' => '00ff00')
    ),
    'turquoise' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '519d55'),
        'ko' => array('hex' => '9d5551'),
        '01' => array('hex' => '383532'),
        '02' => array('hex' => '5c5754'),
        '02_01' => array('hex' => '3c3936'),
        '02_02' => array('hex' => '474340'),
        '02_03' => array('hex' => '524d4a'),
        '03' => array('hex' => 'ccc8c5'),
        '03_01' => array('hex' => 'a39f9b'),
        '03_02' => array('hex' => 'b0aca9'),
        '03_03' => array('hex' => 'bebab7'),
        '04' => array('hex' => 'd1cdca'),
        '05' => array('hex' => '238e74'),
        '05_01' => array('hex' => '1c6f5a'),
        '05_02' => array('hex' => '1f7963'),
        '05_03' => array('hex' => '20836b'),
        '05_04' => array('hex' => 'a6c3b3'),
        '05_05' => array('hex' => 'b2cfbf'),
        'footer-fg' => array('hex' => 'd1cdca'),
        'footer-bg' => array('hex' => '383532'),
        'footer-link' => array('hex' => 'ccc8c5')
    ),
    'wine' => array(
        'black' => array('hex' => '000000'),
        'white' => array('hex' => 'ffffff'),
        'fg' => array('hex' => '000000'),
        'bg' => array('hex' => 'ffffff'),
        'ok' => array('hex' => '519d55'),
        'ko' => array('hex' => '9d5551'),
        '01' => array('hex' => '353535'),
        '02' => array('hex' => '585858'),
        '02_01' => array('hex' => '393939'),
        '02_02' => array('hex' => '434343'),
        '02_03' => array('hex' => '4e4e4e'),
        '03' => array('hex' => 'c8c8c8'),
        '03_01' => array('hex' => '9f9f9f'),
        '03_02' => array('hex' => 'acacac'),
        '03_03' => array('hex' => 'bababa'),
        '04' => array('hex' => 'dddddd'),
        '05' => array('hex' => '930e3a'),
        '05_01' => array('hex' => 'a40a40'),
        '05_02' => array('hex' => '7e0128'),
        '05_03' => array('hex' => '8f0a36'),
        '05_04' => array('hex' => 'b92e5d'),
        '05_05' => array('hex' => 'd6497a'),
        'footer-fg' => array('hex' => 'dddddd'),
        'footer-bg' => array('hex' => '353535'),
        'footer-link' => array('hex' => 'c8c8c8')
    )
);


if (empty($palette_constructor)) { // related to the portfolio
$darkThemes = array('black', 'golden-dark', 'mustard', 'slate');

function to_rgb($colourstr) {
    $rhex = substr($colourstr, 0, 2);
    $ghex = substr($colourstr, 2, 2);
    $bhex = substr($colourstr, 4, 2);

    $R = hexdec($rhex);
    $G = hexdec($ghex);
    $B = hexdec($bhex);

    return $R . ',' . $G . ',' . $B;
}

foreach ($colors as $theme => $color) {
    foreach ($color as $key => $value) {
        $colors[$theme][$key]['rgb'] = to_rgb($value['hex']);
        if (in_array($theme, $darkThemes)) {
            $dark = 'fg';
        } else {
            $dark = '01';
        }
        if ($key == $dark) {
            $colors[$theme]['dark']['hex'] = $colors[$theme][$key]['hex'];
            $colors[$theme]['dark']['rgb'] = $colors[$theme][$key]['rgb'];
        } elseif ($key == 'bg') {
            $colors[$theme]['light']['hex'] = $colors[$theme][$key]['hex'];
            $colors[$theme]['light']['rgb'] = $colors[$theme][$key]['rgb'];
        }
    }
}
}

// BACKGROUNDS
$template_bg_grids = "";
if (!empty($_GET['template_bg_grids'])) {
	$template_bg_grids = $_GET['template_bg_grids'];
} elseif (!empty($GLOBALS['H']['template_bg_grids'])) { 
	$template_bg_grids = $GLOBALS['H']['template_bg_grids'];
}

$template_bg_color ="";
if (!empty($_GET['template_bg_color'])) {
	$template_bg_color = $_GET['template_bg_color'];
} elseif (!empty($GLOBALS['H']['template_bg_color'])) { 
	$template_bg_color = $GLOBALS['H']['template_bg_color'];
}

if ($template_bg_grids != "" &&  $template_bg_color != "") $template_bg = '/files/img/warhol/bg-'.$template_bg_grids.'-'.$template_bg_color.'.png';
else  $template_bg = "";

if (!empty($_GET['template_bg'])) {
	$template_bg = $_GET['template_bg'];
} elseif (isset($GLOBALS['H']['template_bg'])) { 
	$template_bg = $GLOBALS['H']['template_bg'];
}

if (!empty($_GET['color']) and !empty($colors[$_GET['color']])) {
 $color = $_GET['color'];
} else if (isset($GLOBALS['H']['template_color'])) { // DEPRECATED!!!! TO BE DELETED!!!!
 $color = $GLOBALS['H']['template_color']; // DEPRECATED!!!! TO BE DELETED!!!!
}

?>

/*
 * jQuery FlexSlider v2.2.0
 * //www.woothemes.com/flexslider/
 *
 * Copyright 2012 WooThemes
 * Free to use under the GPLv2 license.
 * //www.gnu.org/licenses/gpl-2.0.html
 *
 * Contributing author: Tyler Smith (@mbmufffin)
 */


/* Browser Resets
*********************************/
.flex-container a:active,
.flexslider a:active,
.flex-container a:focus,
.flexslider a:focus
{
	outline: none;
}
.slides,
.flex-control-nav,
.flex-direction-nav
{
	margin: 0;
	padding: 0;
	list-style: none;
}

/* FlexSlider Necessary Styles
*********************************/
.flexslider
{
	margin: 0;
	padding: 0;
}
.flexslider .slides > li
{
	display: none;
	-webkit-backface-visibility: hidden;
}

/* Hide the slides before the JS is loaded. Avoids image jumping */
.flexslider .slides img
{
	width: 100%;
	display: block;
}
.flex-pauseplay span
{
	text-transform: capitalize;
}

/* Clearfix for the .slides element */
.slides:after
{
	content: ".";
	display: block;
	clear: both;
	visibility: hidden;
	line-height: 0;
	height: 0;
}
html[xmlns] .slides
{
	display: block;
}
* html .slides
{
	height: 1%;
}

/* No JavaScript Fallback */
/* If you are not using another script, such as Modernizr, make sure you
 * include js that eliminates this class on page load */
.no-js .slides > li:first-child
{
	display: block;
}

/* FlexSlider Default Theme
*********************************/
.flexslider
{
	margin: 0 0 40px 0;
	position: relative;
	zoom: 1;
	background-color: #<?=$colors[$color]['03']['hex']?>;
}
.flex-viewport
{
	max-height: 2000px;
	-webkit-transition: all 1s ease;
	-moz-transition: all 1s ease;
	-o-transition: all 1s ease;
	transition: all 1s ease;
}
.loading .flex-viewport
{
	max-height: 300px;
}
.flexslider .slides
{
	zoom: 1;
}
.carousel li
{
	margin-right: 5px;
}

/* Direction Nav */
.flex-direction-nav
{
	*height: 0;
}
.flex-direction-nav a
{
	text-decoration: none;
	display: block;
	position: absolute;
	top: 45%;
	z-index: 10;
	cursor: pointer;
	color: #<?=$colors[$color]['bg']['hex']?>;
	-webkit-transition: all .3s ease;
	-moz-transition: all .3s ease;
	transition: all .3s ease;
	font-size: 18px;
	opacity: 0.7;
}
.flex-direction-nav a span i.fa-inverse
{
	color: #<?=$colors[$color]['01']['hex']?>;
	font-weight: bold;
}
.flex-direction-nav .flex-prev
{
	left: 10px;
}
.flex-direction-nav .flex-next
{
	right: 10px;
	text-align: right;
}
.flexslider:hover .flex-next:hover, .flexslider:hover .flex-prev:hover
{
	opacity: 1;
}
.flex-direction-nav .flex-disabled
{
	opacity: 0!important;
	filter:alpha(opacity=0);
	cursor: default;
}

/* Pause/Play */
.flex-pauseplay a
{
	display: block;
	width: 20px;
	height: 20px;
	position: absolute;
	bottom: 5px;
	left: 10px;
	opacity: 0.8;
	z-index: 10;
	overflow: hidden;
	cursor: pointer;
	color: #000;
}
.flex-pauseplay a:before
{
	font-family: FontAwesome;
	font-size: 20px;
	display: inline-block;
	content: '\f0a9';
}
.flex-pauseplay a:hover
{
	opacity: 1;
}
.flex-pauseplay a.flex-play:before
{
	content: '\f003';
}

/* Control Nav */
.flex-control-nav
{
	width: 100%;
	position: absolute;
	bottom: -40px;
	text-align: center;
}
.flex-control-nav li
{
	margin: 0 6px;
	display: inline-block;
	zoom: 1;
}
.flex-control-paging li a
{
	width: 11px;
	height: 11px;
	display: block;
	background: #666;
	background: rgba(0,0,0,0.3);
	cursor: pointer;
	text-indent: -9999px;
	-webkit-border-radius: 20px;
	-moz-border-radius: 20px;
	-o-border-radius: 20px;
	border-radius: 20px;
	-webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
	-moz-box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
	-o-box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
	box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
}
.flex-control-paging li a:hover
{
	background: #333;
	background: rgba(0,0,0,0.7);
}
.flex-control-paging li a.flex-active
{
	background: #000;
	background: rgba(0,0,0,0.9);
	cursor: default;
}
.flex-control-thumbs
{
	margin: 5px 0 0;
	position: static;
	overflow: hidden;
}
.flex-control-thumbs li
{
	width: 25%;
	float: left;
	margin: 0;
}
.flex-control-thumbs img
{
	width: 100%;
	display: block;
	opacity: .7;
	cursor: pointer;
}
.flex-control-thumbs img:hover
{
	opacity: 1;
}
.flex-control-thumbs .flex-active
{
	opacity: 1;
	cursor: default;
}

.ba-flexslider-container
{
	padding: 0;
	overflow: hidden;
}
.ba-flexslider-container h3
{
	background-color: #<?=$colors[$color]['01']['hex']?>;
	color: #<?=$colors[$color]['bg']['hex']?>;
	line-height: 40px;
	padding: 0 15px;
	margin-bottom: 0;
}