<?php
/**
 * @extension       Marlev Templates
 * @author          Lev Milicenco <support@marlev.it>
 * @link            http://www.marlev.it
 * @copyright       Copyright 2015 marlev.it All Rights Reserved
 * @license         http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 *
 */
defined('_JEXEC') or die;

$input = JFactory::getApplication()->input;
$loadoffline = $input->getInt("loadoffline", false);
$rand_query = md5(rand(0, 99999));
$params = JFactory::getApplication()->getTemplate(true)->params;
$app = JFactory::getApplication();
if ($params->get('bootstrapselect') == true) {
    JHtml::_('formbehavior.chosen', 'select');
}
if ($params->get('logo') == true) {
    $logo = htmlspecialchars($this->baseurl . '/' . $params->get('logo'));
} else {
    $logo = htmlspecialchars($this->baseurl . '/templates/' . $this->template . '/images/default-logo.png');
}


require_once JPATH_BASE . '/templates/' . $this->template . '/lib/layout.php';
require_once JPATH_BASE . '/templates/' . $this->template . '/lib/helper.php';
require_once JPATH_BASE . '/templates/' . $this->template . '/lib/template.php';
$getlayout = defined_layout();
$tlayout = $params->get('tlayout', false);
$error = false;
if (isset($this->error) || $loadoffline == 1 || $app->get('offline', 0) == 1) {
    if (isset($this->error)) {
        $error = true;
    }
    ?>
    <script src="<?php echo $this->baseurl ?>/media/jui/js/jquery.min.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
    <script src="<?php echo $this->baseurl ?>/media/jui/js/jquery-noconflict.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
    <script src="<?php echo $this->baseurl ?>/media/jui/js/jquery-migrate.min.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
    <script src="<?php echo $this->baseurl ?>/media/system/js/caption.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
    <script src="<?php echo $this->baseurl ?>/media/jui/js/bootstrap.min.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
    <?php
}
$content = new ml_template_render($getlayout, $tlayout, $logo, $params, $this->baseurl, $this->template, $error);
$template = $this->baseurl . '/templates/' . $this->template . '/';




//Cookie alert

$cookiealert_on = $params->get('cookie_enable', 0);
$cookie_position = $params->get('cookie_position', "bottom");
$cookie_post = JRequest::getString('accettocookie');
if ($cookie_post == "cookie-consentiti") {
    $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
    setcookie('cookie-consentiti-' . $this->template, "accept", time() + (10 * 365 * 24 * 60 * 60), '/', $domain, false);
}


$Changefavicon = $params->get('changeFavicon');
?>
<meta name=viewport content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="<?php echo $this->baseurl ?>/<?php echo (!empty($Changefavicon)) ? $Changefavicon : 'templates/' . $this->template . '/favicon.png'; ?>" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/bootstrap/css/bootstrap.css?<?php echo $rand_query; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo $template; ?>css/template.css?<?php echo $rand_query; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo $template; ?>css/slides.css?<?php echo $rand_query; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo $template; ?>/custom/css.css?<?php echo $rand_query; ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo $template; ?>css/layouts/<?php echo $this->template . "-" . $params->get('tid') ?>.css?<?php echo $rand_query; ?>" type="text/css" />
<script src="<?php echo $template; ?>js/js.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
<script src="<?php echo $template; ?>custom/js.js?<?php echo $rand_query; ?>" type="text/javascript"></script>
<?php if ($params->get('pcmenulayout', 'slide') === "slide") { ?>

    <script type="text/javascript">
    <?php
    if ($params->get("slidelogo", false) !== false) {
        $logo = htmlspecialchars($this->baseurl . '/' . $params->get("slidelogo"));
    }
    ?>
        jQuery(document).ready(function () {
            var ml_slidelogo_params = {
                "show_logo_slide": '<?php echo $params->get("show_logo_slide", "hide"); ?>',
                "slidelogoheight": '<?php echo $params->get("slidelogowidth", 3); ?>',
                "logoslideralign": '<?php echo $params->get("logoslideralign", "center"); ?>',
                "slidelogoeffect": '<?php echo $params->get("slidelogoeffect", "null"); ?>',
                "slidelogowidthimg": '<?php echo $params->get("slidelogowidthimg", 216); ?>',
                "slidelogomargintop": '<?php echo $params->get("slidelogomargintop", 7); ?>',
                "slidelogomarginleft": '<?php echo $params->get("slidelogomarginleft", 0); ?>',
                "slidelogoheightimg": '<?php echo $params->get("slidelogoheightimg", 45); ?>',
                "slidelogo": '<?php echo $logo; ?>'
            };

            jQuery.marlevSlideMenu(ml_slidelogo_params);
            jQuery(window).scroll(function () {
                jQuery.marlevSlideMenu(ml_slidelogo_params);
            });
        });
    </script>
    <?php
}
if ($params->get('btnstyle', false) !== false) {
    ?>
    <script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery.rewrite_btn_style("<?php echo $params->get('btnstyle'); ?>");
        });
    </script>
    <?php
}
