<?php

/*---------------------------------------------------------------
# Package - Stools Framework  
# ---------------------------------------------------------------
# Author - joomla2you http://www.joomla2you.com
# Copyright (C) 2008 - 2015 joomla2you.com. All Rights Reserved. 
# Websites: http://www.joomla2you.com
# All rights reserved
# Joomla! is Free Software
# Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
-----------------------------------------------------------------*/

defined( '_JEXEC' ) or die();
jimport( 'joomla.plugin.plugin' );
jimport('joomla.application.module.helper');
jimport( 'joomla.event.plugin' );
jimport( 'joomla.html.parameter' );

class plgSystemMXMegaMenu extends JPlugin {
	var $_params;
	var $_pluginPath;
	function __construct( &$subject ) {	
		parent::__construct( $subject );
		$this->_plugin = JPluginHelper::getPlugin( 'system', 'mxmegamenu' );
		$this->_params = new JRegistry( $this->_plugin->params );
		$this->_pluginPath = JPATH_PLUGINS."/system/mxmegamenu/";
	}

	//Add menu parameter
	function onContentPrepareForm($form, $data) {
			JHtml::_('behavior.framework', true);
			$doc = JFactory::getDocument();	
			if (JVERSION < 3) {
				$plg_path = JURI::root(true).'/plugins/system/mxmegamenu/js/menuscript.js';
			} else {
				$plg_path = JURI::root(true).'/plugins/system/mxmegamenu/js/menuscript_j3.js';	//for joomla 3.0		
			}				
		
		if ($form->getName()=='com_menus.item') {
			JForm::addFormPath($this->_pluginPath);
			$form->loadFile('parameters', false);
			$doc->addScript($plg_path, "text/javascript");	
		}
	}
}

?>