<?php
/**
 * @package DJ-Events
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 * @developer Szymon Woronowski - szymon.woronowski@design-joomla.eu
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

if (!defined('DS')) {
	define('DS', DIRECTORY_SEPARATOR);
}

// Include the syndicate functions only once
require_once (dirname(__FILE__).DS.'helper.php');
require_once(JPATH_BASE.DS.'components'.DS.'com_djevents'.DS.'helpers'.DS.'djevents.php');
require_once(JPATH_BASE.DS.'components'.DS.'com_djevents'.DS.'helpers'.DS.'route.php');

$app = JFactory::getApplication();

DJEventsHelper::setAssets();
$lang = JFactory::GetLanguage();
$lang->load('com_djevents');

$doc = JFactory::getDocument();
$doc->addStyleSheet(JURI::root(true).'/modules/mod_djevents_calendar/assets/style.css');
JHtml::_('bootstrap.framework');
$layout = explode(':',$params->get('layout','month'));
$layout = (isset($layout[1]) ? $layout[1] : $layout[0]);

$version = new JVersion;
if($layout == 'scroll') {

    if (version_compare($version->getShortVersion(), '4.0', '<')) {
        $doc->addScript(JURI::root(true).'/modules/mod_djevents_calendar/assets/scroll.js');
    }else {
        $doc->addScript(JURI::root(true).'/modules/mod_djevents_calendar/assets/scroll_j4.js');
    }

} else if ($layout == 'month') {
    if (version_compare($version->getShortVersion(), '4.0', '<')) {
        $doc->addScript(JURI::root(true).'/modules/mod_djevents_calendar/assets/month.js');
    }else {
        $doc->addScript(JURI::root(true).'/modules/mod_djevents_calendar/assets/month_j4.js');
    }
}

$items = modDJEventsCalendarHelper::getItems($params);

$params->set('module', $module->id);

require JModuleHelper::getLayoutPath('mod_djevents_calendar', $params->get('layout','month'));
