/**
     * ShowContent
     * Create the fader object and output the content.
     */
    function pmxc_ShowContent()
    {
        global $context, $txt;
        if (!empty($this->faderdata)) {
            // create the fader object
            $start = pmx_getcookie('pmx_oFader' . $this->cfg['id']);
            echo '
				<div id="pmxfader' . $this->cfg['id'] . '"></div>
				<script type="text/javascript">
				var oFader' . $this->cfg['id'] . ' = new PmxOpacFader({
					fadeName: \'oFader' . $this->cfg['id'] . '\',
					fadeUptime: ' . $this->faderdata['up'] . ',
					fadeDowntime: ' . $this->faderdata['down'] . ',
					fadeHoldtime: ' . $this->faderdata['hold'] . ',
					fadeChangetime: ' . $this->cfg['config']['settings']['changetime'] * 1000 . ',
					fadeContId: \'pmxfader' . $this->cfg['id'] . '\',
					fadeData: ' . $this->faderdata['lines'] . ',
					fadeCsr: ' . (is_null($start) ? 0 : $start) . '
				});
				</script>';
        }
    }
/**
* pmx_handle_xml - Handle xml action requests
**/
function pmx_handle_xml()
{
    global $context, $boardurl, $modSettings, $boarddir, $pmxCacheFunc;
    if (isset($_REQUEST['getcookie'])) {
        if ($_REQUEST['name'] == 'ecl_auth' && isset($_REQUEST['value']) && $_REQUEST['value'] == 'checkECL') {
            $result = pmx_checkECL_Cookie($_REQUEST['sender'] == 'reqOverlay');
        } else {
            $result = pmx_getcookie($_REQUEST['name']);
        }
    } else {
        if (isset($_REQUEST['setcookie'])) {
            // php syntax check?
            if ($_REQUEST['name'] == 'pmx_php_check') {
                $context['pmx_imageurl'] = $boardurl . '/Themes/default/PortaMx/SysCss/Images/';
                $result = PortaMx_PHPsyntax($_REQUEST['value']);
            } else {
                $result = 'ok';
                if ($_REQUEST['name'] == 'pmx_eclauth') {
                    pmx_setECL_Cookie();
                } else {
                    pmx_setcookie($_REQUEST['name'], $_REQUEST['value']);
                }
            }
        }
    }
    ob_start();
    echo $result;
    ob_end_flush();
    exit;
}
/**
* Init all variables and load the settings from the database.
* Check the requests and prepare the templates to load.
*/
function PortaMx($doinit = false)
{
    global $context, $modSettings, $boardurl, $scripturl, $user_info, $maintenance, $language, $pmxCacheFunc, $sc, $cookiename, $txt;
    // we can exit on this...
    if (defined('PortaMx') || isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && empty($doinit)) {
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && !empty($user_info['possibly_robot'])) {
            redirectexit();
        } else {
            return;
        }
    }
    define('PortaMx', 1);
    // no sign up for robots please !!
    if (!empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'signup') {
        redirectexit();
    }
    if (empty($user_info['possibly_robot'])) {
        // portal enable/disable request ?
        if ((isset($_REQUEST['pmxportal']) || isset($_REQUEST['pmxsef'])) && allowedTo('admin_forum')) {
            $mode = 'pmx' . (isset($_REQUEST['pmxportal']) ? 'portal' : 'sef');
            updateSettings(array($mode . '_disabled' => $_REQUEST[$mode] == 'off' ? '1' : '0'));
            redirectexit();
        }
        // clear PortaMx cache request ?
        if (isset($_GET['action']) && isset($_GET['area']) && (in_array($_GET['action'], array('admin', 'portamx')) && $_GET['area'] == 'pmx_cache')) {
            if (isset($_GET[$_SESSION['session_var']]) && $_GET[$_SESSION['session_var']] == $sc) {
                $pmxCacheFunc['clean']();
                $_SESSION['pmx_cache_cleared'] = true;
            }
            if (isset($_SESSION['pmx_last_request'])) {
                redirectexit($_SESSION['pmx_last_request']);
            }
        } elseif (pmx_checkECL_Cookie() && strpos($_SERVER['REQUEST_URL'], 'viewsmfile') === false) {
            $_SESSION['pmx_last_request'] = $_SERVER['REQUEST_URL'];
        }
        $lang = $pmxCacheFunc['get']($user_info['ip'] . '-lang');
        if (!pmx_checkECL_Cookie()) {
            if ($lang === null) {
                // get browser language
                $browserlang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']) : '';
                if (preg_match_all('~en\\b|de\\b~i', $browserlang, $temp) > 0) {
                    $avail = array_keys(PortaMx_getLanguages());
                    if (in_array('de', $temp[0])) {
                        if (in_array('german', $avail)) {
                            $lang = 'german';
                        } elseif (in_array('german-utf8', $avail)) {
                            $lang = 'german-utf8';
                        }
                    } else {
                        $lang = $language;
                    }
                    $_POST['language'] = $lang;
                    $_POST['redir'] = pmx_http_build_query($_GET);
                }
            } else {
                $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $lang;
            }
            // need to releoad base language
            loadLanguage('index+Modifications');
        } else {
            if ($lang !== null) {
                $_POST['language'] = $lang;
                $_POST['redir'] = pmx_http_build_query($_GET);
            }
        }
        // check if a language change requested
        if (!empty($_POST['language'])) {
            $pmxCacheFunc['clean']();
            $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $_POST['language'];
            if (pmx_checkECL_Cookie()) {
                // Make it permanent for members.
                if (!empty($user_info['id'])) {
                    updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
                } else {
                    $_SESSION['language'] = $user_info['language'];
                }
            } else {
                $pmxCacheFunc['put']($user_info['ip'] . '-lang', $language, 360, false);
                $_POST['redir'] = pmx_http_build_query($_GET);
            }
            if (isset($_POST['redir'])) {
                redirectexit($_POST['redir']);
            }
        }
    }
    if (empty($modSettings['pmx_eclmodal']) && !pmx_checkECL_Cookie() && (!empty($_REQUEST['action']) && $_REQUEST['action'] != 'xml' || !empty($_REQUEST['page']) || !empty($_REQUEST['cat']) || !empty($_REQUEST['art']))) {
        if (empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'login') {
            setupMenuContext();
            pmx_ECL_Error($_REQUEST['action']);
        } else {
            redirectexit();
        }
    }
    // redirect on illegal request
    if (!empty($_REQUEST['pmxportal']) || !empty($_REQUEST['pmxsef']) || !empty($_REQUEST['pmxerror']) && !empty($_REQUEST['action'])) {
        redirectexit('pmxerror=unknown');
    }
    // check if a permanent theme change requested
    if (isset($_REQUEST['theme']) && isset($_REQUEST['pmxrd'])) {
        PortaMx_ChangeTheme($_REQUEST['theme'], $_REQUEST['pmxrd']);
    }
    // load all settings
    PortaMx_getSettings();
    // shoutbox POST request?
    if (!empty($_POST['pmx_shout']) && !empty($_POST['shoutbox_id'])) {
        PortaMx_GetShoutbox($_POST['shoutbox_id']);
        if (pmx_checkECL_Cookie()) {
            $_SESSION['pmx_shoutreload'] = true;
        }
        exit;
    }
    // exit on follow actions
    $rqaction = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    if (isset($_REQUEST['xml']) || in_array($rqaction, array('jseditor', 'jsoption', '.xml', 'xmlhttp', 'verificationcode', 'printpage'))) {
        return;
    }
    // login with redirect .. correct SEF url
    if ($rqaction == 'login' && !empty($_SESSION['old_url']) && function_exists('pmxsef_query')) {
        $_SESSION['old_url'] = $scripturl . pmx_http_build_query(pmxsef_query(rawurldecode(ltrim(str_replace($boardurl, '', $_SESSION['old_url']), '/'))));
    }
    // check if a pmxscriptdebug/pmxspidertest requested
    $tmp = isset($_GET['pmxscriptdebug']) ? 'pmxscriptdebug' : (isset($_GET['pmxspidertest']) ? 'pmxspidertest' : '');
    if (!empty($tmp) && in_array($_GET[$tmp], array('on', 'off'))) {
        if (allowPmx('pmx_admin')) {
            if ($tmp == 'pmxscriptdebug') {
                pmx_setcookie($tmp, $_GET[$tmp] == 'on' ? '1' : '');
                unset($_GET[$tmp]);
                redirectexit(pmx_http_build_query($_GET));
            } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'on' && !empty($modSettings['pmx_ecl'])) {
                $logCook = pmx_getcookie($cookiename);
                pmx_setcookie($tmp, $logCook);
                pmx_setcookie($cookiename, '');
                pmx_setcookie('pmx_eclauth', '');
                pmx_setcookie('PHPSESSID', '');
                unset($logCook);
                redirectexit();
            }
        } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'off' && pmx_getcookie('pmxspidertest')) {
            $udata = pmx_getcookie($tmp);
            if (isset($udata) && is_array($dtmp = unserialize($udata)) && count($dtmp == 4)) {
                pmx_setECL_Cookie();
                pmx_setcookie($cookiename, $udata, $dtmp[2]);
                unset($dtmp);
                unset($udata);
            }
            pmx_setcookie('pmxspidertest', '');
            redirectexit();
        }
    }
    // load common javascript
    loadJavascriptFile(PortaMx_loadCompressed('PortaMx.js'), array('external' => true));
    addInlineJavascript('
	var pmx_restore_top = ' . intval(!empty($context['pmx']['settings']['restoretop'])) . ';');
    if ($doinit || !empty($modSettings['pmxportal_disabled'])) {
        loadLanguage($context['pmx_templatedir'] . 'PortaMx');
        loadCSSFile(PortaMx_loadCompressed('portamx.css'), array('external' => true));
        return;
    }
    // on Admin or Moderate load admin language, css and javascript
    if (($rqaction == 'admin' || $rqaction == 'portamx') && isset($_REQUEST['area']) && in_array($_REQUEST['area'], explode(',', $context['pmx']['areas']))) {
        loadJavascriptFile(PortaMx_loadCompressed('PortaMxAdmin.js'), array('external' => true));
        loadCSSFile(PortaMx_loadCompressed('portamx_admin.css'), array('external' => true));
        loadLanguage($context['pmx_templatedir'] . 'Admin');
        addInlineJavascript("\n\t" . 'BlockActive=\'' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '\';' . "\n\t" . 'BlockInactive=\'' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '\';');
    }
    // Error request?
    if (!empty($_REQUEST['pmxerror'])) {
        return PmxError();
    }
    // check Error request, Forum request
    $context['pmx']['forumReq'] = !empty($_REQUEST['action']) || !empty($context['current_board']) || !empty($context['current_topic']);
    if (empty($context['pmx']['forumReq']) && !empty($context['pmx']['settings']['other_actions'])) {
        $reqtyp = Pmx_StrToArray($context['pmx']['settings']['other_actions']);
        foreach ($reqtyp as $rtyp) {
            @(list($rtyp, $rval) = Pmx_StrToArray($rtyp, '='));
            $context['pmx']['forumReq'] = $context['pmx']['forumReq'] || isset($_REQUEST[$rtyp]) && (is_null($rval) || $_REQUEST[$rtyp] == $rval);
        }
    }
    // check Page, category, article request
    $pmxRequestTypes = array('spage', 'art', 'cat', 'child');
    $context['pmx']['pageReq'] = array();
    foreach ($pmxRequestTypes as $type) {
        if (empty($_REQUEST['action']) && !empty($_REQUEST[$type])) {
            $context['pmx']['pageReq'][$type] = PortaMx_makeSafe($_REQUEST[$type]);
        }
    }
    // no request on forum or pages and no frontpage .. go to forum
    if (empty($context['pmx']['forumReq']) && empty($context['pmx']['pageReq']) && $context['pmx']['settings']['frontpage'] == 'none') {
        $_REQUEST['action'] = $_GET['action'] = 'community';
        $context['pmx']['forumReq'] = true;
    }
    // Disable HighSlide on action?
    if (isset($_REQUEST['action']) && isset($context['pmx']['settings']['noHS_onaction'])) {
        $noHighSlide = isset($context['pmx']['settings']['noHS_onaction']) ? Pmx_StrToArray($context['pmx']['settings']['noHS_onaction']) : array();
        if (in_array($_REQUEST['action'], $noHighSlide)) {
            $context['pmx']['settings']['disableHS'] = 1;
        }
    }
    // Admin panel/block hidding ?
    $hideRequest = array_intersect($context['pmx']['extracmd'], array_keys($_REQUEST));
    if (!empty($hideRequest) && allowPmx('pmx_admin')) {
        @(list($hideRequest) = array_values($hideRequest));
        $mode = substr($hideRequest, 5);
        $hidetyp = substr($hideRequest, 0, 5);
        $offparts = empty($modSettings['pmx_' . $hidetyp . 'off']) ? array() : Pmx_StrToArray($modSettings['pmx_' . $hidetyp . 'off']);
        if ($mode == 'off') {
            if ($hidetyp == 'panel') {
                $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? $context['pmx']['block_sides'] : array_merge($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']);
            } else {
                $offparts = array_merge($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest]));
            }
        } else {
            if ($hidetyp == 'panel') {
                $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']);
            } else {
                $offparts = $_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest]));
            }
        }
        updateSettings(array('pmx_' . $hidetyp . 'off' => implode(',', $offparts)));
        unset($_GET[$hideRequest]);
        redirectexit(pmx_http_build_query($_GET));
    }
    // check all the actions and more...
    if (empty($context['pmx']['forumReq'])) {
        // if a redirect request, exit
        $requrl = strpos($_SERVER['REQUEST_URL'], substr($scripturl, 0, strrpos($scripturl, '/'))) === false ? $_SERVER['REQUEST_URL'] : $scripturl;
        if (substr($requrl, 0, strrpos($requrl, '/')) != substr($scripturl, 0, strrpos($scripturl, '/'))) {
            return;
        }
        // we use the frontpage ?
        $useFront = $context['pmx']['settings']['frontpage'] == 'none' && empty($context['pmx']['pageReq']) ? '' : 'frontpage';
        // get all block on active panels they can view
        $context['pmx']['viewblocks'] = getPanelsToShow($useFront);
        // frontpage and/or Page blocks exist ?
        if (!empty($maintenance) && $context['pmx']['settings']['frontpage'] != 'none' || empty($useFront) || !empty($context['pmx']['show_pagespanel']) || !empty($context['pmx']['show_frontpanel']) && $context['pmx']['settings']['frontpage'] != 'none') {
            // setup headers
            PortaMx_headers('frontpage');
            $context['robot_no_index'] = empty($context['pmx']['settings']['indexfront']);
            if ($context['pmx']['settings']['frontpage'] == 'fullsize') {
                loadTemplate($context['pmx_templatedir'] . 'Frontpage');
                $context['template_layers'] = array('fronthtml', 'portamx');
                call_integration_hook('integrate_load_theme');
            } else {
                loadTemplate($context['pmx_templatedir'] . 'Mainindex');
                $context['template_layers'][] = 'portamx';
            }
            if (!empty($context['pmx']['pageReq']) || empty($context['pmx']['forumReq']) && $context['pmx']['settings']['frontpage'] != 'none') {
                loadTemplate($context['pmx_templatedir'] . 'PortaMx');
            }
        } else {
            // page req error?
            if (!empty($context['pmx']['pageReq']) && empty($context['pmx']['show_pagespanel'])) {
                redirectexit('pmxerror=page');
            }
            // else go to forum
            $_REQUEST['action'] = $_GET['action'] = !empty($maintenance) && empty($user_info['is_admin']) ? '' : 'community';
            $context['pmx']['forumReq'] = true;
            $context['pmx']['viewblocks'] = null;
        }
    }
    if (!empty($context['pmx']['forumReq'])) {
        // get the action
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] == 'collapse' ? 'community' : $_REQUEST['action'] : (isset($_REQUEST['board']) ? 'boards' : (isset($_REQUEST['topic']) ? 'topics' : ''));
        // get all block on active panels they can view
        $context['pmx']['viewblocks'] = getPanelsToShow($action);
        // setup headers
        PortaMx_headers($action);
        // load the "Main" template on pages, cats or arts
        if (!empty($context['pmx']['pageReq'])) {
            loadTemplate($context['pmx_templatedir'] . 'PortaMx');
        }
        loadTemplate($context['pmx_templatedir'] . 'Mainindex');
        $context['template_layers'][] = 'portamx';
    }
    // Load the Frame template
    loadTemplate($context['pmx_templatedir'] . 'Frames');
    // supress these links if ECL not accepted
    if (!empty($rqaction) && !pmx_checkECL_Cookie() && isset($modSettings['pmx_eclmodalaction']) && in_array($rqaction, Pmx_StrToArray($modSettings['pmx_eclmodalaction']))) {
        pmx_ECL_Error('request');
    }
    // Create the linktree
    return pmx_MakeLinktree();
}
/**
* Top frame
**/
function Pmx_Frame_top($cfg, $count)
{
    global $context, $scripturl, $options, $txt;
    $context['pmx_framecount']++;
    $context['pmx_frames'][$context['pmx_framecount']] = true;
    if (!empty($cfg['config']['skip_outerframe'])) {
        $context['pmx_frames'][$context['pmx_framecount']] = false;
        return null;
    }
    // get the block title for user language have it or forum default
    $blocktitle = PortaMx_getTitle($cfg['config']);
    // the title align
    $ttladjust = '';
    switch ($cfg['config']['title_align']) {
        case 'left':
            $imgalign = 'right';
            $txtalign = 'left';
            $ttlimg = $txtalign;
            $toggleClass = 'class="float' . $imgalign;
            break;
        case 'right':
            $imgalign = 'left';
            $txtalign = 'right';
            $ttlimg = $txtalign;
            $toggleClass = 'class="float' . $imgalign;
            break;
        case 'center':
            $imgalign = 'right';
            $txtalign = 'center';
            $ttlimg = 'left';
            $toggleClass = 'class="float' . $imgalign;
    }
    if ($cfg['config']['title_icon'] == 'none.png') {
        $cfg['config']['title_icon'] = '';
    }
    if (empty($cfg['config']['title_icon'])) {
        $ttladjust = ' pmxadj';
    }
    if ($cfg['config']['title_align'] == 'center') {
        if (!empty($cfg['config']['title_icon']) && !empty($cfg['config']['collapse']) && $context['pmx']['settings']['shrinkimages'] != 2) {
            $ttladjust = ' pmxadj_center';
        } elseif (empty($cfg['config']['title_icon']) && empty($cfg['config']['collapse'])) {
            $ttladjust = '';
        } elseif (empty($cfg['config']['title_icon'])) {
            $ttladjust = ' pmxadj_' . $imgalign;
        } else {
            $ttladjust = ' pmxadj_' . $ttlimg;
        }
    }
    $cfg['config']['innerpad'] = isset($cfg['config']['innerpad']) ? $cfg['config']['innerpad'] : '4';
    $innerPad = Pmx_getInnerPad($cfg['config']['innerpad']);
    // custom css ?
    if (!empty($cfg['customclass'])) {
        $isCustHeader = !empty($cfg['customclass']['header']);
        $isCustFrame = !empty($cfg['customclass']['frame']);
    } else {
        $isCustHeader = $isCustFrame = false;
    }
    $IDtype = $cfg['blocktype'] . $cfg['id'];
    $frame = false;
    $cfg['noID'] = in_array($cfg['blocktype'], array('category', 'article', 'static_category', 'static_article'));
    $showAcs = allowPmxGroup($cfg['acsgrp']);
    $cfg['active'] = !isset($cfg['active']) ? true : $cfg['active'];
    echo '
						<div' . (empty($cfg['noID']) ? ' id="block.id.' . $cfg['id'] . '" ' : '') . ' style="margin-bottom:' . (empty($count) ? '0' : $context['pmx']['settings']['panelpad']) . 'px; overflow:hidden;' . (in_array(strtolower($cfg['side']), array('left', 'right')) ? 'width:' . $context['pmx']['settings'][strtolower($cfg['side']) . '_panel']['size'] . 'px; padding-' . (strtolower($cfg['side']) == 'left' ? 'right:' : 'left:') . $context['pmx']['settings']['panelpad'] . 'px;' : '') . (empty($cfg['active']) || empty($showAcs) ? 'display:none;' : '') . '">';
    // show the collapse, if set and have a header
    $head_bar = !empty($cfg['config']['visuals']['header']) && $cfg['config']['visuals']['header'] !== 'hide' ? str_replace('bg', '_bar', $cfg['config']['visuals']['header']) : '';
    if (!empty($cfg['config']['visuals']['header']) && $cfg['config']['visuals']['header'] != 'none' || empty($cfg['config']['visuals']['header']) && !empty($cfg['config']['visuals']['body'])) {
        echo '
							<div class="' . (!empty($head_bar) ? $head_bar : 'title_no_bar') . '">
								<h3';
        if (!empty($cfg['config']['collapse']) && $context['pmx']['settings']['shrinkimages'] != 2) {
            if (!isset($options['collapse' . $IDtype])) {
                $cook = pmx_getcookie('pmx_upshr' . $IDtype, false);
                $options['collapse' . $IDtype] = is_null($cook) ? '0' : $cook;
            }
        } else {
            $options['collapse' . $IDtype] = '0';
        }
        echo ' class="' . (!empty($cfg['config']['visuals']['header']) ? $cfg['config']['visuals']['header'] : $cfg['config']['visuals']['body']) . ' cbodypad">';
        // show the collapse / expand icon
        if (!empty($cfg['config']['collapse'])) {
            echo '
									<span id="upshrink_' . $IDtype . '_Img" ' . (empty($options['collapse' . $IDtype]) ? $toggleClass . $context['pmx_img_expand'] : $toggleClass . $context['pmx_img_colapse']) . ' title="' . (empty($options['collapse' . $IDtype]) ? $txt['pmx_collapse'] : $txt['pmx_expand']) . $blocktitle . '"></span>';
        }
        // show the title icon is set
        if (!empty($cfg['config']['title_icon'])) {
            echo '
									<img class="title_images pmx' . $ttlimg . '" src="' . $context['pmx_Iconsurl'] . $cfg['config']['title_icon'] . '" alt="*" title="' . $blocktitle . '" />';
        }
        echo '
									<span class="pmxtitle pmx' . $txtalign . $ttladjust . '">';
        // if quickedit link the title to blockedit?
        if (!empty($context['pmx']['settings']['manager']['qedit']) && allowPmx('pmx_admin') && !empty($blocktitle)) {
            $btyp = str_replace('static_', '', $cfg['blocktype']);
            echo '
										<a href="' . $scripturl . '?action=' . (allowPmx('pmx_admin', true) ? 'portamx' : 'admin') . ';area=pmx_' . (in_array($btyp, array('category', 'article')) ? $btyp == 'category' ? 'categories;sa=edit;id=' . preg_replace('/_[0-9]+/', '', $cfg['catid']) : 'articles;sa=edit;id=' . preg_replace('/_[0-9]+/', '', $cfg['id']) : 'blocks;sa=' . $cfg['side']) . ';edit=' . preg_replace('/_[0-9]+/', '', $cfg['id']) . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="pmxsetEditTop(this)">' . $blocktitle . '</a>';
        } else {
            echo '
									' . (empty($blocktitle) ? '&nbsp;' : $blocktitle);
        }
        echo '
									</span>
								</h3>
							</div>';
    }
    // show content frame
    $frameclass = $cfg['config']['visuals']['frame'] . ' ' . $cfg['config']['visuals']['body'] . (strpos($head_bar, 'notrnd') !== false ? ' notrnd' : '');
    if (!empty($cfg['config']['visuals']['frame']) || $isCustFrame) {
        echo '
							<div' . (!empty($cfg['config']['collapse']) ? ' id="upshrink_' . $IDtype . '"' . (empty($options['collapse' . $IDtype]) ? '' : ' style="display:none;"') : '') . '>
								<div class="' . $frameclass . '" style="padding:' . $innerPad[0] . 'px ' . $innerPad[1] . 'px !important; margin-top:0px;">
									<div';
    } else {
        echo '
							<div' . (!empty($cfg['config']['collapse']) ? ' id="upshrink_' . $IDtype . '"' . (empty($options['collapse' . $IDtype]) ? '' : ' style="display:none;"') : '') . (!empty($cfg['config']['visuals']['body']) ? ' class="blockcontent fr_' . $head_bar . ' ' . $cfg['config']['visuals']['body'] . '"' : '') . '>
								<div' . (!empty($hashead) ? ' class="pmx_noframe_' . $cfg['blocktype'] . '"' : '') . ' style="padding:' . $innerPad[0] . 'px ' . $innerPad[1] . 'px !important;">
									<div';
    }
    // have a bodytext class ?
    if (!empty($cfg['config']['visuals']['bodytext'])) {
        echo ' class="' . $cfg['config']['visuals']['bodytext'] . '"';
    }
    // have overflow and (min-/max-)height?
    if (!empty($cfg['config']['overflow'])) {
        echo ' style="' . (isset($cfg['config']['maxheight']) && !empty($cfg['config']['maxheight']) ? (empty($cfg['config']['height']) ? 'max-height' : $cfg['config']['height']) . ':' . $cfg['config']['maxheight'] . 'px;' : '') . 'overflow:' . $cfg['config']['overflow'] . ';text-overflow:ellipsis;white-space:nowrap;"';
    }
    echo '>';
    // if header or frame and can collaps?
    if (!empty($cfg['config']['collapse']) && $cfg['config']['visuals']['header'] != 'none') {
        $tmp = '
		var ' . $IDtype . ' = new smc_Toggle({
		bToggleEnabled: true,
		bCurrentlyCollapsed: ' . (empty($options['collapse' . $IDtype]) ? 'false' : 'true') . ',
		aSwappableContainers: [
			\'upshrink_' . $IDtype . '\'
		],
		aSwapImages: [
			{
				sId: \'upshrink_' . $IDtype . '_Img\',';
        if ($context['pmx']['settings']['shrinkimages'] == '0') {
            $tmp .= '
				srcCollapsed: \'' . $context['pmx_img_colapse'] . '\',
				altCollapsed: ' . JavaScriptEscape($txt['pmx_expand'] . $blocktitle) . ',';
        } else {
            $tmp .= '
				altCollapsed: ' . JavaScriptEscape($txt['pmx_expand'] . $blocktitle) . ',';
        }
        if ($context['pmx']['settings']['shrinkimages'] == '0') {
            $tmp .= '
				srcExpanded: \'' . $context['pmx_img_expand'] . '\',
				altExpanded: ' . JavaScriptEscape($txt['pmx_collapse'] . $blocktitle) . '
			}';
        } else {
            $tmp .= '
				altExpanded: ' . JavaScriptEscape($txt['pmx_collapse'] . $blocktitle) . '
			}';
        }
        $tmp .= '
		],
		oCookieOptions: {
			bUseCookie: true,
			sCookieName: \'' . 'pmx_upshr' . $IDtype . '\',
			sCookieValue: \'' . $options['collapse' . $IDtype] . '\'
		}
	});';
        addInlineJavascript("\t" . str_replace("\n", "\n\t", PortaMx_compressJS($tmp)), true);
        unset($tmp);
    }
}
 /**
  * The display block Methode.
  * ShowBlock prepare the frame, header and the body of each block.
  * Load the a css file if available.
  * After frame, header and body is prepared, the block depended content output is called.
  */
 function pmxc_ShowBlock($count = 0, $placement = '')
 {
     global $options;
     if (!empty($this->inBlockCall)) {
         $this->cfg['id'] .= '_0';
     }
     // set block upshrink
     $cook = 'pmx_upshr' . $this->cfg['blocktype'] . $this->cfg['id'];
     $cookval = pmx_getcookie($cook);
     if (!empty($this->cfg['config']['collapse_state']) && is_null($cookval)) {
         $cookval = $options['collapse' . $this->cfg['blocktype'] . $this->cfg['id']] = $this->cfg['config']['collapse_state'] == '1' ? 1 : 0;
         pmx_setcookie($cook, $cookval);
     } else {
         $options['collapse' . $this->cfg['blocktype'] . $this->cfg['id']] = intval(!empty($cookval));
     }
     // Placement for Frontpage blocks?
     if (function_exists('Pmx_Frame_top') && (empty($placement) || !empty($placement) && ($placement == $this->cfg['config']['frontplace'] || empty($this->cfg['config']['frontplace'])))) {
         if ($this->cfg['blocktype'] == 'category') {
         }
         $this->getCustomCSS($this->cfg);
         Pmx_Frame_top($this->cfg, $count);
         // whe have now to call the block depended methode.
         $this->pmxc_ShowContent($count);
         Pmx_Frame_bottom();
         return 1;
     } else {
         return 0;
     }
 }
    /**
     * ShowContent
     */
    function pmxc_ShowContent()
    {
        global $scripturl, $context, $user_info, $txt;
        echo '
				<div style="padding-bottom:4px;"' . (isset($this->cfg['config']['visuals']['questiontext']) ? ' class="' . $this->cfg['config']['visuals']['questiontext'] . '"' : '') . '>
					<a href="' . $scripturl . '?topic=' . $this->polls['topic'] . '.0"><b>' . $this->polls['question'] . '</b></a>';
        if (!empty($this->polls['is_locked']) && (!empty($this->polls['allow_view_results']) || empty($this->polls['allow_view_results']) && empty($this->polls['allow_vote']) && empty($this->polls['is_expired']))) {
            echo '<span' . (isset($this->cfg['config']['visuals']['bodytext']) ? ' class="' . $this->cfg['config']['visuals']['bodytext'] . '"' : '') . '>' . $txt['pmx_poll_select_locked'] . '</span>';
        }
        echo '
				</div>';
        if (!empty($this->polls['allow_vote'])) {
            echo '
				<div id="pxm_allowvotepoll' . $this->cfg['id'] . '"' . (!empty($this->polls['allow_view_results']) && $this->currentpoll['state'] == '1' ? ' style="display:none"' : '') . '>
					<form id="pmx_voteform' . $this->cfg['id'] . '" action="' . $scripturl . '?action=vote;topic=' . $this->polls['topic'] . ';poll=' . $this->polls['id'] . '" method="post" accept-charset="', $context['character_set'], '">
						<input type="hidden" name="poll" value="' . $this->polls['id'] . '" />
						<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
						<input type="hidden" name="pmx_votepoll" value="' . pmx_http_build_query($_GET) . '" />
						<div style="padding-top:4px;line-height:1em;">';
            $i = 0;
            foreach ($this->polls['options'] as $option) {
                echo '
							<div class="polloptions"><label id="pmx_pollopt' . $this->cfg['id'] . '_' . $i . '" style="border:none; background:transparent;" for="' . $option['id'] . '">' . $option['vote_button'] . ' <span style="vertical-align:3px;">' . $option['option'], '</span></label></div>';
                $i++;
            }
            echo '
						</div>
						<div>' . $this->polls['allowed_warning'] . '</div>';
            if (!empty($this->polls['expired'])) {
                echo '
						<div style="padding-top:4px;"><b>' . $txt['poll_expires_on'] . ':</b> ' . $this->polls['expired'] . '</div>';
            }
            echo '
						<hr class="pmx_hr" />
						<input style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_vote'] . '" onmouseup="pmx_VotePoll(\'' . $this->cfg['id'] . '\', this)" />';
            if ($this->polls['allow_view_results']) {
                echo '
						<input style="margin:2px;float:left;" type="button" class="button_submit" name="button" value="' . $txt['pmx_poll_results'] . '" onmouseup="pmx_ShowPollResult(\'' . $this->cfg['id'] . '\', this)" />';
            }
            echo '
					</form>
				</div>';
        }
        if (!empty($this->polls['allow_view_results'])) {
            echo '
				<div id="pxm_allowviewpoll' . $this->cfg['id'] . '"' . (!empty($this->polls['allow_vote']) && $this->currentpoll['state'] == '0' ? ' style="display:none"' : '') . '>
					<table class="pmx_table">';
            $tablen = 100 / $this->polls['tablen'];
            $tablen = $tablen > 100 ? 100 : $tablen;
            $ownpolls = isset($this->PollChoices[$this->polls['id']]) ? $this->PollChoices[$this->polls['id']] : array();
            // Guestpolls
            // ;id,timestamp,[vote,vote...]; etc
            $cook = pmx_getcookie('guest_poll_vote');
            if (empty($cook)) {
                $guestpolls = array();
            } else {
                $guestinfo = explode(';', trim($cook, ';'));
                // Find the poll we're after.
                foreach ($guestinfo as $i => $guestvoted) {
                    $temp = explode(',', $guestvoted);
                    if ($temp[0] != $this->polls['id']) {
                        continue;
                    } else {
                        $guestpolls[] = $temp[2];
                    }
                }
            }
            foreach ($this->polls['options'] as $key => $option) {
                $barlen = $option['percent'] == 0 ? '0' : ceil($option['percent'] * $tablen);
                $barlen = $barlen > 100 ? 100 : $barlen;
                $strong = $option['percent'] > 0 && ($user_info['is_guest'] && is_array($guestpolls) && in_array($key, $guestpolls)) || !$user_info['is_guest'] && is_array($ownpolls) && in_array($key, $ownpolls) ? array(0 => '<b>', 1 => '</b>') : array(0 => '', 1 => '');
                echo '
				<tr>
					<td style="text-align:left;height:35px;width:95%;">' . $strong[0] . $option['option'] . $strong[1] . '
						<div style="height: 10px;width:' . $barlen . '%;"' . ($barlen > 0 ? ' class="poll_bar"' : '') . '></div>
					</td>
					<td style="text-align:right;">
						<div style="margin-top:14px;white-space:nowrap;margin-left:8px;">
						 ' . $strong[0] . $option['votes'] . ' (' . $option['percent'] . '%)' . $strong[1] . '
						</div>
					</td>
				</tr>';
            }
            echo '
					</table>
					<div style="clear:both; padding-top:8px;"><b>' . $txt['poll_total_voters'] . ':</b> ' . $this->polls['total_votes'] . '</div>';
            if (!empty($this->polls['expired'])) {
                echo '
					<div style="padding-top:4px;"><b>' . (!empty($this->polls['is_expired']) ? $txt['pmx_poll_closed'] . '</b>' : $txt['poll_expires_on'] . ':</b> ' . $this->polls['expired']) . '</div>';
            }
            if (!empty($this->polls['allow_vote']) || !empty($this->polls['allow_change_vote'])) {
                echo '
					<hr class="pmx_hr" />';
                if (!empty($this->polls['allow_vote'])) {
                    echo '
						<input style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_return_vote'] . '" onmouseup="pmx_ShowPollVote(' . $this->cfg['id'] . ', ' . $this->currentpoll['id'] . ')" />';
                }
                if (!empty($this->polls['allow_change_vote'])) {
                    echo '
					<input  style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_change_vote'] . '" onmouseup="pmx_ChangePollVote(' . $this->cfg['id'] . ', this)" />
					<form id="pmx_voteform' . $this->cfg['id'] . '" action="' . $scripturl . '?action=vote;topic=' . $this->polls['topic'] . ';poll=' . $this->polls['id'] . '" method="post" accept-charset="', $context['character_set'], '">
						<input type="hidden" name="poll" value="' . $this->polls['id'] . '" />
						<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
						<input type="hidden" name="pmx_votepoll" value="' . pmx_http_build_query($_GET) . '" />
					</form>';
                }
            }
            echo '
				</div>';
        }
        if (empty($this->polls['allow_view_results']) && empty($this->polls['allow_vote']) && empty($this->polls['is_expired'])) {
            echo '
				<div style="padding:0 3px;">';
            foreach ($this->polls['options'] as $option) {
                echo '
					' . $option['option'] . '<div style="line-height:0.8em; padding-bottom:0.5em;">&nbsp;&laquo;&ndash;&raquo;</div>';
            }
            if (!empty($this->polls['expired'])) {
                echo '
					<div style="padding-top:4px;"><b>' . (!empty($this->polls['is_expired']) ? $txt['pmx_poll_closed'] . '</b>' : $txt['poll_expires_on'] . ':</b> ' . $this->polls['expired']) . '</div>';
            }
            echo '
				</div>';
            if (!empty($this->polls['allow_vote']) || !empty($this->polls['allow_change_vote'])) {
                echo '
				<hr class="pmx_hr" />';
                if (!empty($this->polls['allow_change_vote'])) {
                    echo '
				<input  style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_change_vote'] . '" onmouseup="pmx_ChangePollVote(' . $this->cfg['id'] . ', this)" />
				<form id="pmx_voteform' . $this->cfg['id'] . '" action="' . $scripturl . '?action=vote;topic=' . $this->polls['topic'] . ';poll=' . $this->polls['id'] . '" method="post" accept-charset="', $context['character_set'], '">
					<input type="hidden" name="poll" value="' . $this->polls['id'] . '" />
					<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
					<input type="hidden" name="pmx_votepoll" value="' . pmx_http_build_query($_GET) . '" />
				</form>';
                }
            }
        }
        // multiple polls enabled?
        if (count($this->pollquestions) > 1) {
            $maxwidth = in_array($this->cfg['side'], array('right', 'left')) ? '98%' : 0;
            $cact = empty($_SERVER['QUERY_STRING']) ? '' : '?' . PortaMx_makeSafe($_SERVER['QUERY_STRING']);
            echo '
				<form id="pmx_votechange' . $this->cfg['id'] . '" action="' . $scripturl . $cact . '" method="post" accept-charset="', $context['character_set'], '">
					<input id="pollchanged' . $this->cfg['id'] . '" type="hidden" name="pollchanged' . $this->cfg['id'] . '" value="' . $this->polls['id'] . '" />
					<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
					<div style="padding:5px 0 2px 0;">' . $txt['pmx_pollmultiview'] . '</div>
						<select name="pollselect"' . (!empty($maxwidth) ? ' style="width:' . $maxwidth . ';"' : '') . ' onchange="pmx_ChangeCurrentPoll(\'' . $this->cfg['id'] . '\', this);">';
            foreach ($this->pollquestions as $id => $question) {
                echo '
							<option value="' . $id . '"' . ($id == $this->currentpoll['id'] ? ' selected="selected"' : '') . '>' . $question . '</option>';
            }
            echo '
					</select>
				</form>';
        }
    }