<?php
/**
 * jeGroupBuy package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2010 - 2011 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/
// no direct access
defined('_JEXEC') or die('Restricted access');

$user = & JFactory::getUser();
$controllerName = JRequest::getCmd( 'controller', 'products' );
switch($controllerName)
{
	case 'products':
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
		$controllerName = 'jeGroupBuyController'.$controllerName;
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy', true);
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings');
	break;

	case 'category':
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
		$controllerName = 'jeGroupBuyController'.$controllerName;
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category', true);
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings');
	break;

	case 'stores':
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
		$controllerName = 'jeGroupBuyController'.$controllerName;
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores', true);
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings');
	break;

	case 'templates':
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
		$controllerName = 'jeGroupBuyController'.$controllerName;
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates', true);
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings');
	break;

	case 'orders':
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
		$controllerName = 'jeGroupBuyController'.$controllerName;
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders', true);
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings');
	break;

	case 'settings':
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' );
		$controllerName = 'jeGroupBuyController'.$controllerName;
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings', true);
	break;

	default:
		require_once( JPATH_COMPONENT.DS.'controllers'.DS.'products'.'.php' );
		$controllerName = 'jeGroupBuyControllerproducts';
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_PRODUCTS'), 'index.php?option=com_jegroupbuy', true);
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_CATEGORIES'), 'index.php?option=com_jegroupbuy&controller=category');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SHOPS'), 'index.php?option=com_jegroupbuy&controller=stores');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_TEMPLATE'), 'index.php?option=com_jegroupbuy&controller=templates');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_ORDERS'), 'index.php?option=com_jegroupbuy&controller=orders');
		JSubMenuHelper::addEntry(JText::_('JE_GROUPBUY_SETTINGS'), 'index.php?option=com_jegroupbuy&controller=settings');
	break;
}
$controller	= new $controllerName( );
$controller->execute( JRequest::getCmd('task'));
$controller->redirect();
?>