/**
     @brief The Workhorse that does the actuall inserting.
 
     Inserts all necessary settings and configurations into the Template using the I(Insert) class  
 */
 public function linkSciptsAndStylesheets()
 {
     // DateTimePicker CSS
     $cssFile = WB_URL . '/modules/date_time_picker/XDSoftDateTimePicker/css/jquery.datetimepicker.css';
     I::AddCss(array('setname' => "datetimepicker_css", 'href' => $cssFile, 'media' => "screen"));
     // DateTimePicker_overrides.css
     $cssOverrides = THEME_URL . '/css/date_time_picker_override.css';
     if (is_readable(str_replace(WB_URL, WB_PATH, $cssOverrides))) {
         I::AddCss(array('setname' => "datetimepicker_overrides_css", 'href' => $cssOverrides, 'media' => "screen"));
     }
     // DateTimePicker Plugin JS File
     $jsFile = WB_URL . '/modules/date_time_picker/XDSoftDateTimePicker/js/jquery.datetimepicker.full.min.js';
     I::AddJs(array('setname' => "datetimepicker_js", 'position' => "HeadLow", 'src' => $jsFile));
     echo '<script type="text/javascript" src="' . $jsFile . '"></script>';
     $sPluginCfg = " lang: '" . strtolower(LANGUAGE) . "'";
     // take care of the leading comma (,) before each new setting
     $sPluginCfg .= $this->mask == true ? '", mask: "true' : '';
     $sPluginCfg .= $this->lazyInit == true ? ", lazyInit: 'true'" : '';
     $sPluginCfg .= $this->step != 60 ? ", step: " . $this->step : '';
     if ($this->timepicker == false) {
         $sPluginCfg .= ", timepicker: 'false'";
     } else {
         $sPluginCfg .= ", formatTimeScroller: '" . $this->sTimeFormat . "'";
     }
     if ($this->datepicker == false) {
         $sPluginCfg .= ", datepicker: 'false'";
     }
     $sPluginCfg .= ", format: '" . $this->sDateTimeFormat . "'";
     //generate inlineJS from above string and add to Queue
     if ($this->selector != '') {
         global $TEXT;
         $sJS = "\r\n\t\t\t\tvar THEME_URL = '" . THEME_URL . "';\r\n\t\t\t\t\$(document).ready(function(){\r\n\t\t\t\t\t\r\n\t\t\t\t\t\$.datetimepicker.setLocale('" . strtolower(LANGUAGE) . "');\r\n\t\t\t\t\tvar DELETE_DATE = Boolean(" . $this->delete_date_handle . ");\r\n\t\t\t\t\tvar SELECTOR = \$(\"[rel='" . $this->selector . "']\");\r\n\t\t\t\t\tSELECTOR.datetimepicker({" . $sPluginCfg . "});\r\n\t\t\t\t\t\r\n\t\t\t\t\t// add ICONS\r\n\t\t\t\t\tSELECTOR.each(function() {\t\t\r\n\t\t\t\t\t\tvar oInputField = this;\r\n\t\t\t\t\t\tvar sFieldID = this.getAttribute('id');\r\n\t\t\t\t\t\tvar CAL_ICON = ' <img alt=\"[show cal]\" rel=\"' + sFieldID + '\" id=\"show_' + sFieldID + '\" class=\"showcal\"  src=\"' + THEME_URL +'/images/calendar_16.png\" title=\"" . $TEXT['CALENDAR'] . "\">';\r\n\t\t\t\t\t\tif(DELETE_DATE == true){\r\n\t\t\t\t\t\t\tvar RESET_ICON = ' <img alt=\"[reset]\" rel=\"reset_' + sFieldID + '\" class=\"reset_datetime\" src=\"' + THEME_URL +'/images/clock_del_16.png\" title=\"" . $TEXT['DELETE_DATE'] . "\">';\r\n\t\t\t\t\t\t}else{ \r\n\t\t\t\t\t\t\tvar RESET_ICON = '';\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\$(this).after(CAL_ICON + RESET_ICON);\r\n\t\t\t\t\t\tvar RESET_ICON2 = \$(\"img.reset[rel=\" + sFieldID + \"]\");\r\n\t\t\t\t\t\tif(\$(this).val() == ''){\r\n\t\t\t\t\t\t\tRESET_ICON2.css({ opacity: 0.2 });\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tRESET_ICON2.css('cursor', 'pointer').click(function() {\r\n\t\t\t\t\t\t\t   \$('input#' + sFieldID).val('');\r\n\t\t\t\t\t\t\t   RESET_ICON2.css({ opacity: 0.8 });\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t\$('#show_' + sFieldID).css('cursor', 'pointer').click(function(){\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t  oInputField.focus();\t\t\r\n\t\t\t\t\t\t});\t\t\r\n\t\t\t\t\t});\t\r\n\t\t\t\t\t\r\n\t\t\t\t\t// empty date input\r\n\t\t\t\t\tif(DELETE_DATE == true){\r\n\t\t\t\t\t\t\$('.reset_datetime').click(function () {\r\n\t\t\t\t\t\t\tvar FIELD = this.getAttribute('rel');\r\n\t\t\t\t\t\t\tvar ID = '#' + FIELD.replace('reset_', '');\r\n\t\t\t\t\t\t\t\$(ID).attr('value', '');\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\t\t\t\t\t\r\n\t\t\t\t});\r\n\t\t\t";
         I::AddJs(array('setname' => "DateTimePicker", 'position' => "BodyLow", 'script' => $sJS));
     }
 }
                $include_head_link_css .= '<link href="' . WB_URL . '/modules/' . $module_dir . '/frontend.css"';
                $include_head_link_css .= ' rel="stylesheet" type="text/css" media="screen" />' . "\n";
            }
            // check if frontend.js file needs to be included into the <body></body> of index.php
            if (file_exists(WB_PATH . '/modules/' . $module_dir . '/frontend.js')) {
                $include_head_links .= '<script src="' . WB_URL . '/modules/' . $module_dir . '/frontend.js" type="text/javascript"></script>' . "\n";
            }
            // check if frontend_body.js file needs to be included into the <body></body> of index.php
            if (file_exists(WB_PATH . '/modules/' . $module_dir . '/frontend_body.js')) {
                $include_body_links .= '<script src="' . WB_URL . '/modules/' . $module_dir . '/frontend_body.js" type="text/javascript"></script>' . "\n";
            }
        }
    }
}
// Sysvars always added to Insert
I::AddJs(array('setname' => "wbsysvars", 'position' => "HeadTop", 'script' => wb_make_js_sys_vars(false), 'overwrite' => true));
// Frontend functions
if (!function_exists('page_link')) {
    /**
     * generate full qualified URL from relative link based on pages_dir
     * @param string $link
     * @return string
     */
    function page_link($link)
    {
        return $GLOBALS['wb']->page_link($link);
    }
}
if (!function_exists('get_page_link')) {
    /**
     * get relative link from database based on pages_dir