<?php

if(!isset($_REQUEST['rep'])) {
    include_once dirname(__FILE__).'/common.php';
    header('Location: ' . URL_ROOT . "$C_default_rep/select.php" );
    exit();
}

$rep = $_REQUEST['rep'];
include dirname(__FILE__).'/'.$rep.'/config.php';

include_once 'common.php';

/**
 * Do we already have a valid Access Token or need to go get one?
 */
if (!isset($_SESSION['TWITTER_ACCESS_TOKEN']) && isset($_GET['CONNECT']) ) {
    /**
     * Guess we need to go get one!
     */
    $token = $consumer->getRequestToken();
    $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);

    /**
     * Now redirect user to Twitter site so they can log in and
     * approve our access
     */
    $consumer->redirect();
}


$big_visual_url = URL_ROOT."/$rep/images/big-visuel.jpg";
if($translate->_('config__client_visual') != 'config__client_visual' && $translate->_('config__client_visual') != null ) {
    $big_visual_url = URL_ROOT."$rep/".$translate->_('config__client_visual');
}

$head_logo = URL_ROOT."$rep/images/head-logo.png";
if($translate->_('config__head_logo') != 'config__head_logo' && $translate->_('config__head_logo') != null ) {
    $head_logo = URL_ROOT."$rep/".$translate->_('config__head_logo');
}

    $embed = (isset($_REQUEST['embed']) && $_REQUEST['embed']);
    $videoWidth = ( $embed ? 442 : 480 );
    $videoHeight = ( $embed ? 250 : 320 );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html lang="<?php echo($actual); ?>">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Live Video and Annotation</title>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />

    <!-- FONT -->
    <link href='<?php echo(registry_url('PT-Sans_Narrow','font'))?>' rel='stylesheet' type='text/css'>
    <link href='<?php echo(registry_url('PT-Sans','font'))?>' rel='stylesheet' type='text/css'>
    
    <!-- CSS -->
    <link rel="stylesheet" href="<?php echo(registry_url('fancybox','css'));?>" type="text/css" media="screen">
    <link rel="stylesheet" href="<?php echo(registry_url('tweetcast','css'));?>?42" type="text/css" media="screen, projection"/>

    <!-- JAVASCRIPT -->
    <script type="text/javascript" src="<?php echo(registry_url('jquery','js'))?>"></script>
    
    <script type="text/javascript">
    
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-23581291-1']);
      _gaq.push(['_trackPageview']);
      _gaq.push(['_setAllowAnchor', true]);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    
    </script>
    
  </head>
  <body>
    <div id="sendUsFeedBack"><a href="<?php echo($C_feedback_form_url); ?>" target="_blank"><img src="<?php echo(URL_ROOT); ?>images/sendusfeedback.png"></a></div>

        <div id="container">
            
                <div class="barre">
                    <img id="headlogo" src="<?php echo($head_logo); ?>" width="171" height="63" />
                    <div id="minilogo"></div>
                    <ul class="menu">
                        <li>
                            <a href="<?php echo(URL_ROOT); ?>" class="menuLink">
                                <?php print $translate->_("Accueil"); ?>
                            </a>
                        </li>
                        <li>
                            <a href="<?php echo($translate->_('config__link')); ?>" class="menuLink" target="_blank" id='Program'>
                                <?php print $translate->_("Programme"); ?>
                            </a>
                        </li>
                        <li>
                            <a href="../about.php" class="menuLink" >
                                <?php print $translate->_("A propos"); ?>
                            </a>
                        </li>
                    </ul>
                    <ul class="menu">
                        <li>
                            <a href="<?php URL_ROOT ?>client.php?lang=ja_JP" class="menuLink" >
                                <img src='<?php echo(URL_ROOT); ?>images/flag_jp.gif'<?php if($actual!="ja_JP"){echo("style='opacity: .5;'"); } ?> />
                                <?php print $translate->_("Japonais"); ?>
                            </a></li>
                        <li>
                            <a href="<?php URL_ROOT ?>client.php?lang=fr" class="menuLink">
                                <img src='<?php echo(URL_ROOT); ?>images/flag_fr.gif' <?php if($actual!="fr"){echo("style='opacity: .5;'"); } ?> />
                                <?php print $translate->_("Français"); ?>
                            </a>
                        </li>
                        <li>
                            <a href="<?php URL_ROOT ?>client.php?lang=en" class="menuLink">
                                <img src='<?php echo(URL_ROOT); ?>images/flag_en.gif' <?php if($actual!="en"){echo("style='opacity: .5;'"); } ?> />
                                <?php print $translate->_("Anglais"); ?>
                            </a>
                        </li>
                    </ul>
                </div>
<?php
    $basepath = dirname(__FILE__)."/";
    $partenaires = $translate->_('config__partenaires');
    foreach ($config['event_list'] as $i => $rep) {
        
        include("$basepath$rep/config.php");
        
        set_config_translations($config, $translate);
            
        $tail_img = $translate->_('config__archive_img');
        if(is_array($tail_img)) {
            $tail_img = $tail_img[0];
        }
        $archive_title = $translate->_('config__archive_title');
        if(is_array($archive_title)) {
            $archive_title = $archive_title[0];
        }
        $archive_description = $translate->_('config__archive_description');
        if(is_array($archive_description)) {
            $archive_description = $archive_description[0];
        }
    
?>
            <div class="archivesVideoBox">
                <a href="<?php echo URL_ROOT . $rep ?>">
                    <img src="<?php echo URL_ROOT . "$rep/$tail_img" ?>" width="270" height="150"/>
                </a>
                <h3 class="AVBtitle"><?php echo $archive_title ?></h3>
                <p class="AVBtext"><?php echo $archive_description; ?></p>
            </div>
<?php

    }

 ?>
            </div>
            <div class="footer">
                <hr />
         <?php
                include  dirname(__FILE__).'/'.$rep.'/config.php';
                echo $partenaires;
                
                if (isset($_SESSION['TWITTER_ACCESS_TOKEN'])){
                    echo("| <a href='clear.php' class='footerLink'>".$translate->_("D&eacute;connexion")."</a>");
                }
         ?>
            </div>
        </div>
  </body>
</html>