<?php

/**
 * Pro Perfect Karousel
 *This program is free software: you can redistribute it and/or modify it under the terms
 *of the GNU General Public License as published by the Free Software Foundation,
 *either version 3 of the License, or (at your option) any later version.
 *
 *This program is distributed in the hope that it will be useful,
 *but WITHOUT ANY WARRANTY; without even the implied warranty of
 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *GNU General Public License for more details.
 *
 *You should have received a copy of the GNU General Public License
 *along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *@author ProJoom
 *@copyright (C) 2008 - 2012 ProJoom
 *@link http://www.projoom.com/extensions/pro-perfect-karousel.html.html Official website
 **/
defined('_JEXEC') or die('Access denied!');
error_reporting(E_ALL ^ E_NOTICE);
global $mainframe, $js_loaded;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
jimport('joomla.filesystem.archive');
$document = &JFactory::getDocument();
require_once (dirname(__file__) . DS . 'helper.php');
$pj_hlp = new pj_hlp();
$vscript = $params->get('vscript');
$nofl = $params->get('nofl');
$objalign = $params->get('objalign');
$npcwidth = $params->get('npcwidth');
$npcheight = $params->get('npcheight');
$npccwidth = $params->get('npccwidth');
$npcqual = $params->get('npcqual');
$npcbg = $params->get('npcbg');
$npcbgpath = $params->get('npcbgpath');
$npcbgpathcustom = $params->get('npcbgpathcustom');
$npcpreloader = $params->get('npcpreloader');
$npcnavtype = $params->get('npcnavtype');
$npcnavspeed = $params->get('npcnavspeed');
$npcnavbtncol = $params->get('npcnavbtncol');
$npcnavbtnalpha = $params->get('npcnavbtnalpha');
$npcnavset = $params->get('npcnavset');
$npcrefl = $params->get('npcrefl');
$npcreflalpha = $params->get('npcreflalpha');
$npcreflheight = $params->get('npcreflheight');
$npcrefldist = $params->get('npcrefldist');
$npceftime = $params->get('npceftime');
$npcefcentry = $params->get('npcefcentry');
$npcefcexit = $params->get('npcefcexit');
$npcefdetimgentry = $params->get('npcefdetimgentry');
$npcefdetimgexit = $params->get('npcefdetimgexit');
$npcefcont1entry = $params->get('npcefcont1entry');
$npcefcont1exit = $params->get('npcefcont1exit');
$npcefcont2entry = $params->get('npcefcont2entry');
$npcefcont2exit = $params->get('npcefcont2exit');
$npctthtml = $params->get('npctthtml');
$npcttaa = $params->get('npcttaa');
$npcttal = $params->get('npcttal');
$npcttbld = $params->get('npcttbld');
$npcttit = $params->get('npcttit');
$npcttcol = $params->get('npcttcol');
$npcttsize = $params->get('npcttsize');
$npcttleft = $params->get('npcttleft');
$npctttop = $params->get('npctttop');
$npcttwidth = $params->get('npcttwidth');
$npcttheight = $params->get('npcttheight');
$npcttbgcol = $params->get('npcttbgcol');
$npcttborder = $params->get('npcttborder');
$npcttbordercol = $params->get('npcttbordercol');
$npctttm = $params->get('npctttm');
$npcdetpg = $params->get('npcdetpg');
$npcdetpgzoom = $params->get('npcdetpgzoom');
$npcdetpgimgleft = $params->get('npcdetpgimgleft');
$npcdetpgimgtop = $params->get('npcdetpgimgtop');
$npcc1html = $params->get('npcc1html');
$npcc1aa = $params->get('npcc1aa');
$npcc1al = $params->get('npcc1al');
$npcc1bold = $params->get('npcc1bold');
$npcc1ita = $params->get('npcc1ita');
$npcc1col = $params->get('npcc1col');
$npcc1size = $params->get('npcc1size');
$npcc1left = $params->get('npcc1left');
$npcc1top = $params->get('npcc1top');
$npcc1width = $params->get('npcc1width');
$npcc1height = $params->get('npcc1height');
$npcc1bgcol = $params->get('npcc1bgcol');
$npcc1border = $params->get('npcc1border');
$npcc1bordercol = $params->get('npcc1bordercol');
$npcc2html = $params->get('npcc2html');
$npcc2aa = $params->get('npcc2aa');
$npcc2al = $params->get('npcc2al');
$npcc2bold = $params->get('npcc2bold');
$npcc2ita = $params->get('npcc2ita');
$npcc2col = $params->get('npcc2col');
$npcc2size = $params->get('npcc2size');
$npcc2left = $params->get('npcc2left');
$npcc2top = $params->get('npcc2top');
$npcc2width = $params->get('npcc2width');
$npcc2height = $params->get('npcc2height');
$npcc2bgcol = $params->get('npcc2bgcol');
$npcc2border = $params->get('npcc2border');
$npcc2bordercol = $params->get('npcc2bordercol');
$npcbackmsg = $params->get('npcbackmsg');
$npcbackmsgaa = $params->get('npcbackmsgaa');
$npcbackmsghtml = $params->get('npcbackmsghtml');
$npcbackmsgbold = $params->get('npcbackmsgbold');
$npcbackmsgsize = $params->get('npcbackmsgsize');
$npcbackmsgleft = $params->get('npcbackmsgleft');
$npcbackmsgtop = $params->get('npcbackmsgtop');
$npcbackmsgwidth = $params->get('npcbackmsgwidth');
$npcbackmsgheight = $params->get('npcbackmsgheight');
$npcbackmsgcol = $params->get('npcbackmsgcol');
$npctitfont = $params->get('npctitfont');
$npcc2font = $params->get("npcc2font");
$mixed = $params->get('npcmixed');
$tempvar = $params->get('npccatid');
$tempvar2 = $params->get('npccatsel');
$pjurl = $params->get('pjurl');
if ($pjurl == '1') {
    $RURL = JURI::base();
} else {
    $RURL = JURI::base(true) . '/';
}
$pj_hlp->init($RURL);
if (!empty($tempvar)) {
    $catid = explode(",", $tempvar);
} else {
    if ($tempvar2 != 0) {
        $catid = explode(",", $tempvar2);
    }
}
$debug_key = "";
$debug_key = JRequest::getVar('pj', '', 'get');
$nofl = $pj_hlp->nofl($nofl);
$randomize = $params->get('npcrand');
if ($randomize == "yes") {
    $rndmz = " ORDER BY RAND()";
} else {
    $rndmz = " ORDER BY ordering";
}
$compat = $pj_hlp->mode($vscript, 'mod_novapc');
$custombg = 'images/carousel/backgrounds/' . $npcbgpathcustom;
$preloader = 'images/carousel/preloaders/' . $npcpreloader;
if (!empty($npcbgpath)) {
    $custombg = $npcbgpath;
}
if ($npcbg == '1') {
    $npcbg = 'true';
} else {
    $npcbg = 'false';
}
if ($npcrefl == '1') {
    $npcrefl = 'true';
} else {
    $npcrefl = 'false';
}
if ($npctthtml == '1') {
    $npctthtml = 'true';
    $npcttc1 = '<font color=\'' . $npcttcol . '\' face=\'Verdana\' size=\'' . $npcttsize . '\'>';
    $npcttc2 = '</font>';
} else {
    $npctthtml = 'false';
    $npcttc1 = '';
    $npcttc2 = '';
}
if ($npcbackmsghtml == '1') {
    $npcbackmsghtml = 'true';
    $npcback1 = '<font color=\'' . $npcbackmsgcol . '\' face=\'Verdana\' size=\'' . $npcbackmsgsize . '\'>';
    $npcback2 = '</font>';
} else {
    $npcbackmsghtml = 'false';
    $npcback1 = '';
    $npcback2 = '';
}
if ($npcttaa == '1') {
    $npcttaa = 'true';
} else {
    $npcttaa = 'false';
}
if ($npcttbld == '1') {
    $npcttbld = 'true';
} else {
    $npcttbld = 'false';
}
if ($npcttit == '1') {
    $npcttit = 'true';
} else {
    $npcttit = 'false';
}
if ($npcttborder == '1') {
    $npcttborder = 'true';
} else {
    $npcttborder = 'false';
}
if ($npctttm == '1') {
    $npctttm = 'true';
} else {
    $npctttm = 'false';
}
if ($npcdetpg == '1') {
    $npcdetpg = 'true';
} else {
    $npcdetpg = 'false';
}
if ($npcc2html == '1') {
    $npcc2html = 'true';
    $npchtc1 = '<font color=\'' . $npcc2col . '\' face=\'Verdana\' size=\'' . $npcc2size . '\'>';
    $npchtc2 = '</font>';
} else {
    $npcc2html = 'false';
    $npchtc1 = '';
    $npchtc2 = '';
}
if ($npcc2aa == '1') {
    $npcc2aa = 'true';
} else {
    $npcc2aa = 'false';
}
if ($npcc2bold == '1') {
    $npcc2bold = 'true';
} else {
    $npcc2bold = 'false';
}
if ($npcc2ita == '1') {
    $npcc2ita = 'true';
} else {
    $npcc2ita = 'false';
}
if ($npcc2border == '1') {
    $npcc2border = 'true';
} else {
    $npcc2border = 'false';
}
//buttons
if ($npcnavset == '1') {
    $butleft = 'images/carousel/buttons/set1l.png';
    $butright = 'images/carousel/buttons/set1r.png';
}
if ($npcnavset == '2') {
    $butleft = 'images/carousel/buttons/set2l.png';
    $butright = 'images/carousel/buttons/set2r.png';
}
if ($npcnavset == '3') {
    $butleft = 'images/carousel/buttons/set3l.png';
    $butright = 'images/carousel/buttons/set3r.png';
}
if ($npcnavset == '4') {
    $butleft = 'images/carousel/buttons/set4l.png';
    $butright = 'images/carousel/buttons/set4r.png';
}
if ($npcnavset == '5') {
    $butleft = 'images/carousel/buttons/set5l.png';
    $butright = 'images/carousel/buttons/set5r.png';
}
if ($npcnavset == '6') {
    $butleft = 'images/carousel/buttons/set6l.png';
    $butright = 'images/carousel/buttons/set6r.png';
}
if ($npcnavset == '7') {
    $butleft = 'images/carousel/buttons/set7l.png';
    $butright = 'images/carousel/buttons/set7r.png';
}
if ($npcnavset == '8') {
    $butleft = 'images/carousel/buttons/set8l.png';
    $butright = 'images/carousel/buttons/set8r.png';
}
if ($npcnavset == '9') {
    $butleft = 'images/carousel/buttons/set9l.png';
    $butright = 'images/carousel/buttons/set9r.png';
}
$file_number = "_" . $module->id;
if (!JFolder::exists(JPATH_BASE . "/cache/mod_novapc")) {
    if (!JFolder::create(JPATH_BASE . "/cache/mod_novapc")) {
        JError::raiseWarning(1, 'Pro Perfect Karousel: Cannot create the default configuration directory "cache/mod_novapc". Please create it manually using Media Manager or a FTP client.');
    }
    $pj_hlp->setperms(JPATH_BASE . "/cache/mod_novapc");
}
$xmlfile = JPATH_BASE . "/cache/mod_novapc/npc$file_number.xml";
$ffile = "npc$file_number.xml";
$ppath = JPATH_BASE . "/cache/mod_novapc/" . $ffile;
if (file_exists($xmlfile)) {
    if (JPath::canChmod($ppath)) {
        JPath::setPermissions($ppath, 0777);
    }
    JFile::delete($xmlfile);
}
$playlist = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$playlist .= '<ProPerfectKarousel>' . "\n";
$playlist .= '<Images
CarouselWidth="' . $npccwidth . '"
CarouselCenterLeft="0"
CarouselCenterTop="0"
CarouselRandomImages="0"
CarouselRenderQuality="' . $npcqual . '"
CarouselPreloader="' . $preloader . '"
BackGroundVisible="' . $npcbg . '"
BackGroundPath="' . $custombg . '"
BackGroundTop="0"
BackGroundLeft="0"
NavigationType="' . $npcnavtype . '"
NavigationSpeed="' . $npcnavspeed . '"
NavigationButtonsColor="' . $npcnavbtncol . '"
NavigationButtonsAlpha="' . $npcnavbtnalpha . '"
NavigationButtonLeftLeft="0"
NavigationButtonLeftTop="0"
NavigationButtonLeftPath="' . $butleft . '"
NavigationButtonRightLeft="0"
NavigationButtonRightTop="0"
NavigationButtonRightPath="' . $butright . '"
ReflectionVisible="' . $npcrefl . '"
ReflectionAlpha="' . $npcreflalpha . '"
ReflectionHeight="' . $npcreflheight . '"
ReflectionDistance="' . $npcrefldist . '"
EffectsTime="' . $npceftime . '"
EffectCarouselEntry="' . $npcefcentry . '"
EffectCarouselExit="' . $npcefcexit . '"
EffectDetailImageEntry="' . $npcefdetimgentry . '"
EffectDetailImageExit="' . $npcefdetimgexit . '"
EffectContent1Entry="' . $npcefcont1entry . '"
EffectContent1Exit="' . $npcefcont1exit . '"
EffectContent2Entry="' . $npcefcont2entry . '"
EffectContent2Exit="' . $npcefcont2exit . '"
ToolTipHTML="' . $npctthtml . '"
ToolTipAntiAliasing="' . $npcttaa . '"
ToolTipAlign="' . $npcttal . '"
ToolTipBold="' . $npcttbld . '"
ToolTipItalic="' . $npcttit . '"
ToolTipFont="' . $npctitfont . '"
ToolTipFontColor="' . $npcttcol . '"
ToolTipFontSize="' . $npcttsize . '"
ToolTipLeading="0"
ToolTipUnderline="false"
ToolTipLeft="' . $npcttleft . '"
ToolTipTop="' . $npctttop . '"
ToolTipWidth="' . $npcttwidth . '"
ToolTipHeight="' . $npcttheight . '"
ToolTipBgColor="' . $npcttbgcol . '"
ToolTipBorder="' . $npcttborder . '"
ToolTipBorderColor="' . $npcttbordercol . '"
ToolTipTopMost="' . $npctttm . '"
DetailPageEnabled="' . $npcdetpg . '"
DetailImageZoom="' . $npcdetpgzoom . '"
DetailImageLeft="' . $npcdetpgimgleft . '"
DetailImageTop="' . $npcdetpgimgtop . '"
Content1HTML="' . $npcbackmsghtml . '"
Content1AntiAliasing="' . $npcbackmsgaa . '"
Content1Align="left"
Content1Bold="' . $npcbackmsgbold . '"
Content1Italic="false"
Content1Font="Verdana"
Content1FontColor="' . $npcbackmsgcol . '"
Content1FontSize="' . $npcbackmsgsize . '"
Content1Leading="0"
Content1Underline="false"
Content1Left="' . $npcbackmsgleft . '"
Content1Top="' . $npcbackmsgtop . '"
Content1Width="' . $npcbackmsgwidth . '"
Content1Height="' . $npcbackmsgheight . '"
Content1BgColor=""
Content1Border="false"
Content1BorderColor=""
Content2HTML="' . $npcc2html . '"
Content2AntiAliasing="' . $npcc2aa . '"
Content2Align="' . $npcc2al . '"
Content2Bold="' . $npcc2bold . '"
Content2Italic="' . $npcc2ita . '"
Content2Font="' . $npcc2font . '"
Content2FontColor="' . $npcc2col . '"
Content2FontSize="' . $npcc2size . '"
Content2Leading="0"
Content2Underline="false"
Content2Left="' . $npcc2left . '"
Content2Top="' . $npcc2top . '"
Content2Width="' . $npcc2width . '"
Content2Height="' . $npcc2height . '"
Content2BgColor="' . $npcc2bgcol . '"
Content2Border="' . $npcc2border . '"
Content2BorderColor="' . $npcc2bordercol . '"  >' . "\n";
if (!empty($catid)) {
    foreach ($catid as $id) {
        $id = trim($id);
        $query = "SELECT * FROM #__novapc WHERE cid=" . $id . " AND showPlaylist = 1" . $rndmz;
        $db = &JFactory::getDBO();
        $db->setQuery($query);
        $Fields = $db->loadObjectList();
        foreach ($Fields as $npcinf) {
            $npcimg = $npcinf->npcimg;
            $npclink = $npcinf->npclink;
            $npctarget = ($npcinf->npctarget) ? "_blank" : "_self";
            $npctt = $npcinf->npctt;
            $npcbigdesc = $npcinf->npcbigdesc;
            if (!file_exists(JPATH_BASE . "/" . $npcimg)) {
                $npcimg = 'modules/mod_novapc/tmpl/notfound.png';
            }
            if (is_numeric($npclink)) {
                $npclink = JURI::base() . 'index.php?option=com_content&view=article&id=' . $npclink;
            }
            $ext_cat = pathinfo(JPATH_BASE . "/" . $npcimg);
            $ext_cat = $ext_cat['extension'];
            if (preg_match('/\A(jpg)\Z/i', $ext_cat) || preg_match('/\A(gif)\Z/i', $ext_cat) || preg_match('/\A(png)\Z/i', $ext_cat) || preg_match('/\A(bmp)\Z/i', $ext_cat) ||
                preg_match('/\A(jpeg)\Z/i', $ext_cat)) {
                if (!file_exists(JPATH_BASE . "/" . $npcimg)) {
                    $pj_hlp->error_files .= JPATH_BASE . "/" . $npcimg . "<br/>";
                    $pj_hlp->error_num_files++;
                } else {
                    $pj_hlp->good_files++;
                }
                $pj_hlp->total_files++;
                $comp[] = '<Image>
	<ImagePath><![CDATA[' . $npcimg . ']]></ImagePath>
	<ImageLink><![CDATA[' . $npclink . ']]></ImageLink>
	<ImageLinkTarget><![CDATA[' . $npctarget . ']]></ImageLinkTarget>
	<ToolTip><![CDATA[' . $npcttc1 . $npctt . $npcttc2 . ']]></ToolTip>
	<Content1><![CDATA[' . $npcback1 . $npcbackmsg . $npcback2 . ']]></Content1>
	<Content2><![CDATA[' . $npchtc1 . $npcbigdesc . $npchtc2 . ']]></Content2>
	<JSFunction><![CDATA[' . ${"npcjava" . $n} . ']]></JSFunction>
</Image>' . "\n";
            } else {
                $pj_hlp->total_files++;
                $pj_hlp->wrong_format_files .= JPATH_BASE . "/" . $npcimg . "<br/>";
                $pj_hlp->wrong_format_num_files++;
                $pj_hlp->error_files .= JPATH_BASE . "/" . $npcimg . "<br/>";
                $pj_hlp->error_num_files++;
            }
        }
    }
}
for ($i = 1; $i <= 40; $i++) {
    if ($i < 10) {
        $n = "0" . $i;
    } else {
        $n = $i;
    }
    ${"npcimg" . $n} = $params->get('npcimg' . $n);
    ${"npclink" . $n} = $params->get('npclink' . $n);
    ${"npctarget" . $n} = $params->get('npctarget' . $n);
    ${"npctt" . $n} = $params->get('npctt' . $n);
    ${"npcbigdesc" . $n} = str_replace('<br />', '', $params->get('npcbigdesc' . $n));
    if (is_numeric(${"npclink" . $n})) {
        ${"npclink" . $n} = JURI::base() . 'index.php?option=com_content&view=article&id=' . ${"npclink" . $n};
    }
    if (!empty(${"npcimg" . $n}) && !empty(${"npclink" . $n})) {
        $ext_bend = pathinfo(JPATH_BASE . "/" . ${"npcimg" . $n});
        $ext_bend = $ext_bend['extension'];
        if (preg_match('/\A(jpg)\Z/i', $ext_bend) || preg_match('/\A(gif)\Z/i', $ext_bend) || preg_match('/\A(png)\Z/i', $ext_bend) || preg_match('/\A(bmp)\Z/i', $ext_bend) ||
            preg_match('/\A(jpeg)\Z/i', $ext_bend)) {
            if (!file_exists(JPATH_BASE . "/" . ${"npcimg" . $n})) {
                $pj_hlp->error_files .= JPATH_BASE . "/" . ${"npcimg" . $n} . "<br/>";
                $pj_hlp->error_num_files++;
            } else {
                $pj_hlp->good_files++;
            }
            $pj_hlp->total_files++;
            $bend[] = '<Image>
 	<ImagePath><![CDATA[' . ${"npcimg" . $n} . ']]></ImagePath>
 	<ImageLink><![CDATA[' . ${"npclink" . $n} . ']]></ImageLink>
 	<ImageLinkTarget><![CDATA[' . ${"npctarget" . $n} . ']]></ImageLinkTarget>
 	<ToolTip><![CDATA[' . $npcttc1 . ${"npctt" . $n} . $npcttc2 . ']]></ToolTip>
 	<Content1><![CDATA[' . $npcback1 . $npcbackmsg . $npcback2 . ']]></Content1>
 	<Content2><![CDATA[' . $npchtc1 . ${"npcbigdesc" . $n} . $npchtc2 . ']]></Content2>
 	<JSFunction><![CDATA[' . ${"npcjava" . $n} . ']]></JSFunction>
</Image>' . "\n";
        } else {
            $total_files++;
            $pj_hlp->total_files++;
            $pj_hlp->wrong_format_files .= JPATH_BASE . "/" . ${"npcimg" . $n} . "<br/>";
            $pj_hlp->wrong_format_num_files++;
            $pj_hlp->error_files .= JPATH_BASE . "/" . ${"npcimg" . $n} . "<br/>";
            $pj_hlp->error_num_files++;
        }
    }
}
if ($mixed == "yes") {
    if (!empty($comp) && !empty($bend)) {
        $plarray = array_merge($comp, $bend);
    } elseif (!empty($comp)) {
        $plarray = $comp;
    } elseif (!empty($bend)) {
        $plarray = $bend;
    }
} else {
    if (!empty($comp)) {
        $plarray = $comp;
    } else
        if (!empty($bend)) {
            $plarray = $bend;
        }
}
if (empty($plarray)) {
    echo '<div style="background-color: red;text-align:center;"><h4 style="color:#FFFFFF;">ProJoom Perfect Karousel : No images detected!</h4></div>';
    return;
}
if ($randomize == "yes") {
    shuffle($plarray);
    if (!empty($plarray)) {
        foreach ($plarray as $plfield) {
            $playlist .= $plfield;
        }
    } else {
        $playlist .= "";
    }
} else {
    if (!empty($plarray)) {
        foreach ($plarray as $plfield) {
            $playlist .= $plfield;
        }
    } else {
        $playlist .= "";
    }
}
$playlist .= '</Images>
<StaticContents>
  <StaticContent
    HTML="false"
    AntiAliasing="false"
    Align="left"
    Bold="false"
    Italic="false"
    Font="Verdana"
    FontColor="#000000"
    FontSize="11"
    Leading="0"
    Underline="false"
    Left="270"
    Top="10"
    Width="120"
    Height="50"
    TopMost="false"
    BgColor="#eeeeee"
    Border="true"
    BorderColor="#b50000"
    VisibleOnCarouselPage="false"
    VisibleOnDetailPage="false" >
  <Content><![CDATA[]]></Content>
  </StaticContent>
  <StaticContent
    HTML="false"
    AntiAliasing="false"
    Align="left"
    Bold="false"
    Italic="false"
    Font="Verdana"
    FontColor="#000000"
    FontSize="11"
    Leading="0"
    Underline="false"
    Left="400"
    Top="10"
    Width="120"
    Height="50"
    TopMost="false"
    BgColor="#eeeeee"
    Border="true"
    BorderColor="#b50000"
    VisibleOnCarouselPage="false"
    VisibleOnDetailPage="false" >
    <Content><![CDATA[]]></Content>
  </StaticContent>
</StaticContents>
</ProPerfectKarousel>' . "\n";
if ($debug_key == "dbgppk") {
    echo $pj_hlp->debug('Pro Perfect Karousel', 'mod_novapc', 'yes', $document);
    return;
}
if (!@JFile::write($xmlfile, $playlist)) {
    printf('<div style="background-color: red;">
<center><span style="font-size: small; color: white;"><strong>Unable to create <span STYLE="color: yellow">
' . str_replace(JPATH_BASE, "", $xmlfile) . '</span> configuration file. <br/>
<a target="_blank" href="http://www.projoom.com/knowledgebase/article/warning_touch()_[function.touch]_unable_to_create_file.html">Click here</a> for more information.</strong></span></center></div>');
}
$ppkid = rand(1000, 5000);
$onthefly = '#alppk_' . $ppkid . '{
text-align: ' . $objalign . ';
}';
$document->addStyleDeclaration($onthefly);
$xmlbuilt = "cache/mod_novapc/npc$file_number.xml?" . $ppkid;
$npcflash = $RURL . 'modules/mod_novapc/tmpl/npc.swf?' . $ppkid;
$expinst = $RURL . "modules/mod_novapc/tmpl/exp.swf";
if ($compat == 'yes') {
    $ppkout = '<div id="alppk_' . $ppkid . '">
	<object style="outline:none;" type="application/x-shockwave-flash" data="' . $npcflash . '" width="' . $npcwidth . '" height="' . $npcheight . '">
	<param name="movie" value="' . $npcflash . '" />
	<param name="flashvars" value="xmlprovider=' . $xmlbuilt . '" />
	<param name="wmode" value="transparent" />
	<param name="allowscriptaccess" value="always">
	<param name="base" value="' . $RURL . '" />
	<p>' . $nofl . '</p>
	</object></div>';
} else {
    $ppkout = "<div id=\"alppk_$ppkid\"><div id=\"ppk_$ppkid\">$nofl</div>
	<script type=\"text/javascript\">
	var flashvars = { xmlprovider: \"$xmlbuilt\",showVersionInfo: \"false\"};
	var params = { base:\"$RURL\",wmode:\"transparent\",allowscriptaccess:\"always\"};
	var attributes = { style: \"outline:none;\" };
	swfobject.embedSWF(\"$npcflash\", \"ppk_$ppkid\", \"$npcwidth\", \"$npcheight\", \"8.0.0\", \"$expinst\", flashvars, params, attributes);
	</script></div>";
}
echo $ppkout;

?>