<?php

/**
 * initialise block
 */
function amazon_familyfestivalblock_init()
{
    // Security
    pnSecAddSchema( 'Amazon:FamilyFestivalblock:', 'Block title::' );
}

/**
 * get information on block
 */
function amazon_familyfestivalblock_info()
{
    // Values
    return array( 'text_type' => 'FamilyFestival',
                  'module' => 'Amazon',
                  'text_type_long' => 'Family Festival',
                  'allow_multiple' => true,
                  'form_content' => false,
                  'form_refresh' => false,
                  'show_preview' => true );
}

/**
 * display block
 */
function amazon_familyfestivalblock_display( $blockinfo )
{
    // Security check
    if ( !pnSecAuthAction( 0,
                           'Amazon:FamilyFestivalblock:',
                           "$blockinfo[title]::",
                           ACCESS_READ ) )
    {
        return;
    }

    $output = new pnHTML();
    $output->SetInputMode( _PNH_VERBATIMINPUT );

    $blockHTML  = '<div align="center" style="position: relative; top: 0px; left: 0px; z-index: 0;">';
    $blockHTML  = '<script type="text/javascript" src="/player/swfobject.js"></script>';

    $blockHTML_imagerotator .= 
<<<EOT

<div id="rotateplayer" style="position: relative; top: 0px; left: 0px; z-index: -1;">This text will be replaced</div>
 
<script type="text/javascript">
var so = new SWFObject('/player/imagerotator.swf','mpl','150','200','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('wmode','opaque');
so.addVariable('transition','fade');
so.addVariable('height','200');
so.addVariable('width','150');
so.addVariable('screencolor','0xFFFFFF');
so.addVariable('file','/video/imagelist.xml');
so.addVariable('shownavigation','false');
so.addVariable('linkfromdisplay','true');
so.addVariable('menu','false');
so.write('rotateplayer');
</script>

EOT
;

////////////////////
    $blockHTML .= 
<<<EOT

<script type="text/JavaScript">
<!--
  function popup_video(url){
    var name = 'video';
    var features = 'width=400,height=300,scrollbars=no,toolbars=no,resizable=yes,status=no';
    new_window = window.open(url,name,features);
    new_window.focus();
  }
//-->
</script>


 
<div id="rotatevideo" style="position: relative; top: 0px; left: 0px; z-index: 0;"></div>
<script type="text/javascript">
var so_rv = new SWFObject('/player/player.swf','mpl','175','136','8');
so_rv.addParam('allowscriptaccess','always');
so_rv.addParam('allowfullscreen','false');
so_rv.addParam('wmode','opaque');
so_rv.addVariable('width','175');
so_rv.addVariable('height','136');
so_rv.addVariable('file','/video/demoplaylist.xml');
so_rv.addVariable('searchbar','false');
so_rv.addVariable('showicons','true');
so_rv.addVariable('shownavigation','true');
so_rv.addVariable('autostart','true');
so_rv.addVariable('repeat','true');
so_rv.addVariable('linkfromdisplay', 'true');
so_rv.addVariable('linktarget', '_self');
so_rv.addVariable('screencolor','0xFFFFFF');

// so_rv.addVariable('displayheight','136');
// so_rv.addVariable('autoscroll','true');

so_rv.write('rotatevideo');
</script>




<div align="center">
  <div style="padding-bottom:1px;">
    Click on video for more.
  </div>
</div>


EOT
;

////////////////////



//    $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="http://www.thedenverchannel.com/7everydayhero/15630142/detail.html" target="_blank"><img src="/images/banners/7EverydayHero.gif" width="150" height="200" border="0" alt="Click to see Kids\' Pages and Ellen awarded the 7Everyday Hero by 7 News!" title="Click to see Kids\' Pages and Ellen awarded the 7Everyday Hero by 7 News!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//    $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="http://www.thedenverchannel.com/7everydayhero/15630142/detail.html" target="_blank"><img src="/images/banners/7EverydayHero.gif" width="150" height="200" border="0" alt="Click for Family Festival & Information Fairs - 2008!" title="Click for Family Festival & Information Fairs - 2008!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//    $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5184"><img src="/images/events/FamilyFestival-2008-banner2.jpg" width="150" height="100" border="0" alt="Click for Family Festival & Information Fairs - 2008!" title="Click for Family Festival & Information Fairs - 2008!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
    $blockHTML .= '</div>';

    $output->Text( $blockHTML );

    // Populate block info and pass to theme
    $blockinfo['content'] = $output->GetOutput();
    return themesideblock( $blockinfo );
}

/**
 * modify block settings
 */
function amazon_familyfestivalblock_modify( $blockinfo )
{
    // Create output object
    $output = new pnHTML();

    // Get current content
    $vars = pnBlockVarsFromContent( $blockinfo['content'] );

    // Defaults
    if ( empty( $vars['numitems'] ) )
    {
        $vars['numitems'] = 5;
    }

    // Create row
    $row = array();
    $output->SetOutputMode( _PNH_RETURNOUTPUT );
    $row[] = $output->Text( _NUMITEMS );
    $row[] = $output->FormText( 'numitems',
                                pnVarPrepForDisplay( $vars['numitems'] ),
                                5,
                                5 );
    $output->SetOutputMode( _PNH_KEEPOUTPUT );

    // Add row
    $output->SetInputMode( _PNH_VERBATIMINPUT );
    $output->TableAddRow( $row, 'left' );
    $output->SetInputMode( _PNH_PARSEINPUT );

    // Return output
    return $output->GetOutput();
}

/**
 * update block settings
 */
function amazon_familyfestivalblock_update( $blockinfo )
{
    $vars['numitems'] = pnVarCleanFromInput( 'numitems' );

    $blockinfo['content'] = pnBlockVarsToContent( $vars );

    return $blockinfo;
}

?>
