(function($) {
  $(function() {
    if(!$('body#soon').length) {
      $.getFeed({url: 'http://www.franklyecommerce.com/lesson-feed',
                 success: function(feed) {
                   if(!feed || feed.items.length < 1) return false
                   var entry_list = $('<ul></ul>')
                   for(var i = 0; i < feed.items.length && i < 3; i++) {
                     var item = feed.items[i]
                     var publishedDate = new Date(item.updated)
                     var localeDate = publishedDate.toLocaleDateString()
                     var timeAgo = $.timeago(publishedDate)
                     entry_list.append('<li><div class="date" title="' + localeDate + '">' + timeAgo + '</div>'
                                       + '<a class="title" target="_blank" href="' + item.link + '">' + item.title + '</a></li>')
                   }
                   $('<div id="news"><h2>What’s New in Frank’s Files:</h2></div>').prependTo('#footer').append(entry_list)
                 }})
    }
    $('.inline-fancybox-link').fancybox()
    $('#members-videos a').fancybox({
      autoDimensions: false,
      width:          700,
      height:         560,
      overlayOpacity: 0.8,
      overlayColor:   '#000',
      centerOnScroll: true,
      transitionIn:  'elastic',
      transitionOut: 'elastic'
    })
  })
})(jQuery)

function embedFlowplayer(id, video) {
  var flowplayerOptions = {
    log: { level: 'debug', filter: 'com.franklearning.*' },
    key: '#$3ee23bdd3486c509de4',
    playlist: [{url: video, autoPlay: false}],
    plugins: {
      controls: {
        autoHide:             'always',
        timeBgColor:          '#262626',
        timeColor:            '#B1E0FC',
        bufferColor:          '#C78F8E',
        buttonOverColor:      '#FF0000',
        durationColor:        '#ffffff',
        borderRadius:         '0px',
        backgroundGradient:   'high',
        bufferGradient:       'none',
        buttonColor:          '#000000',
        tooltipTextColor:     '#D00000',
        sliderGradient:       'none',
        tooltipColor:         '#C9C9C9',
        progressColor:        '#D00000',
        sliderColor:          '#C9C9C9',
        progressGradient:     'none',
        backgroundColor:      '#929292',
        volumeSliderGradient: 'none',
        volumeSliderColor:    '#D00000',
        height:               24,
        opacity:              1.0
      }
    }
  }

  flowplayer(id, {src: '/sites/all/themes/franklearning/flowplayer/flowplayer.commercial.swf', cachebusting: jQuery.browser.msie,  wmode: 'opaque'}, flowplayerOptions)
}

