<?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the id=main div and all content after
 *
 * @package Inspiredise
 */
?>
<?php 
global $theme_options;

if(isset($theme_options['footer_show_twitter_navigation']) && $theme_options['footer_show_twitter_navigation']) {
  $footer_show_twitter_navigation = 'true';
} else {
  $footer_show_twitter_navigation = 'false';
}

if($theme_options['footer_twitter_autoplay']) {
  $footer_twitter_autoplay = 'true';
} else {
  $footer_twitter_autoplay = 'false';
}

?>
<?php if(isset($theme_options['footer_show_twitter']) && $theme_options['footer_show_twitter']): ?>
<div class="content-block twitter">
  <div class="container">
    <div class="row">
      <div class="span12 twitter-item">
        <script type="text/javascript">
        (function($){
        $(document).ready(function() {
          
          // Show twitter after 1 second to not freeze the other page scripts
          setTimeout(initTwitter, 1000);

          function initTwitter()
          {
            $('.twitter-item').tweet({
             modpath: '<?php echo get_template_directory_uri();?>/js/twitter/index.php',
             count: <?php echo $theme_options['footer_twitter_tweets_count']; ?>,
             username: "<?php echo $theme_options['footer_twitter_username']; ?>",
             template: '<div class="twitter-icon"><i class="fa fa-twitter"></i></div><p class="text-center"> {text} </p><p class="twitter-meta text-center"> <a href="http://twitter.com/<?php echo $theme_options["footer_twitter_username"]; ?>" target="_blank">@<?php echo $theme_options["footer_twitter_username"]; ?></a><span class="time">, {time}</span> </p> </div>',
             loading_text: '<div class="twitter-icon"><i class="fa fa-twitter"></i></div>',

            });
            
            $('.twitter-item').flexslider({
              selector: ".tweet_list > li",
              directionNav: <?php echo $footer_show_twitter_navigation; ?>,
              slideshow: <?php echo $footer_twitter_autoplay; ?>,
              controlNav: false,
              slideshowSpeed: <?php echo $theme_options['footer_twitter_speed']; ?>,
              animation: "<?php echo $theme_options['footer_twitter_animation']; ?>",
              prevText: "",
              nextText: "", 
            });
          }
          
        });
        })(jQuery);
        </script>
      </div>
    </div>
  </div>
</div>
<?php endif; ?>
<?php if ( is_active_sidebar( 'footer-sidebar' ) ) : ?>
<div class="footer-sidebar container">
  <ul id="sidebar">
    <?php dynamic_sidebar( 'footer-sidebar' ); ?>
  </ul>
</div>
<?php endif; ?>
<footer>

  <ul class="social footer-social unstyled">
<?php
if(isset($theme_options['footer_social_icons_repeater'])) {
  foreach( $theme_options['footer_social_icons_repeater'] as $repeater_item_number => $repeater_item ){
    $repeater_counter = 0;
    foreach( $repeater_item as $repeater_item_key => $repeater_item_value ){
      if($repeater_counter == 0) {
         $social_service = $repeater_item_value;
      }
      if($repeater_counter == 1) {
         $social_service_url = $repeater_item_value;
      }
      $repeater_counter++;
      if($repeater_counter > 1) {
        $repeater_counter = 0;
      }
    }
    echo '<li><a href="'.$social_service_url.'" target="_blank"><i class="fa fa-'.$social_service.'"></i></a></li>';
  }
}

?>
  </ul>
  <p class="copyright"><?php echo $theme_options['footer_copyright_editor']; ?></p>
</footer>

<?php wp_footer(); ?>

</body>
</html>