$tabs[$params['active_tab']] = true;
}
if (isset($params['is_submitted'])) {
    foreach ($this->Plugins() as $plugin => $parameters) {
        $this->SetPreference($plugin, $params[$plugin]);
    }
}
$headers = $this->StartTabHeaders() . $this->SetTabHeader('scripts', 'Scripts', $tabs['scripts']) . $this->SetTabHeader('plugins', 'Plugins', $tabs['plugins']) . $this->SetTabHeader('options', $this->lang('options'), $tabs['options']) . $this->EndTabHeaders() . $this->StartTabContent();
$this->smarty->assign('tab_headers', $headers);
$this->smarty->assign('end_tab', $this->EndTab());
$this->smarty->assign('tab_footers', $this->EndTabContent());
$this->smarty->assign('start_plugins_tab', $this->StartTab('plugins'));
$this->smarty->assign('start_scripts_tab', $this->StartTab('scripts'));
$this->smarty->assign('start_options_tab', $this->StartTab('options'));
// Scripts
$scripts = jQueryScript::doSelect();
foreach ($scripts as &$script) {
    $script->title = $this->CreateLink($id, 'manageScript', $returnid, $script->getName(), array('script_id' => $script->getId()));
    $script->edit = $this->CreateLink($id, 'manageScript', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/edit.gif', $script->getName(), '', '', 'systemicon'), array('script_id' => $script->getId()));
    $script->delete = $this->CreateLink($id, 'manageScript', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $script->getName(), '', '', 'systemicon'), array('script_id' => $script->getId(), 'delete' => true), $this->lang('are_you_sure'));
    if ($script->getLoadDefault()) {
        $script->load_default_state = $this->CreateLink($id, 'manageScript', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/true.gif', $script->getName(), '', '', 'systemicon'), array('script_id' => $script->getId(), 'load_default_state' => true));
    } else {
        $script->load_default_state = $this->CreateLink($id, 'manageScript', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/false.gif', $script->getName(), '', '', 'systemicon'), array('script_id' => $script->getId(), 'load_default_state' => true));
    }
    if ($script->getInHeader()) {
        $script->in_header_state = $this->CreateLink($id, 'manageScript', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/true.gif', $script->getName(), '', '', 'systemicon'), array('script_id' => $script->getId(), 'in_header_state' => true));
    } else {
        $script->in_header_state = $this->CreateLink($id, 'manageScript', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/false.gif', $script->getName(), '', '', 'systemicon'), array('script_id' => $script->getId(), 'in_header_state' => true));
    }
}
 private function generateHeader()
 {
     global $jQuery;
     if (isset($jQuery['loaded'])) {
         return;
     }
     $html = jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/libraries/jquery-1.4.2/jquery.js');
     $html .= jQueryBase::getJavascriptTag(null, 'jQuery.noConflict();');
     // foreach ($this->getPlugins() as $plugin => $parameters)
     // 		{
     // 			if (isset($parameters['active'] ))
     // 			$html .= ($parameters['active'] == 1)?jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/libraries/plugins/' . $parameters['path']):'';
     // 		}
     // Scripts loading
     $default_scripts = jQueryScript::doSelect(array('where' => array('load_default' => true)));
     foreach ($default_scripts as $script) {
         $jQuery['headers']['scripts'][$script->getPosition()] = $script->getId();
         $required_plugins = explode(',', $script->getRequiredPlugins());
         foreach ($required_plugins as $plugin) {
             if ($plugin != '') {
                 $jQuery['headers']['plugins'][$plugin] = 1;
             }
             //TODO: FIX THE POSITION ISSUE
         }
     }
     // Plugins
     $plugins = $this->getActivePlugins();
     foreach ($plugins as $plugin => $status) {
         $jQuery['headers']['plugins'][$plugin] = 1;
     }
     // Output plugins
     if (is_array($jQuery['headers']['plugins'])) {
         foreach ($jQuery['headers']['plugins'] as $plugin => $status) {
             $html .= jQueryBase::getJavascriptTag($this->getPluginUrl($plugin));
         }
     }
     // Output scripts
     if (is_array($jQuery['headers']['scripts'])) {
         ksort($jQuery['headers']['scripts']);
         foreach ($jQuery['headers']['scripts'] as $script_id) {
             $html .= jQueryBase::getJavascriptTag($this->config['root_url'] . '/modules/jQuery/load.php?id=' . $script_id);
         }
     }
     $jQuery['loaded'] = true;
     return $html;
 }