$.fn.colorVideo = function(options) {
    options = $.extend({
        
    }, options);
    
    return this.each(function(){
        var $this = $(this);
        var href = $this.find('h3 > a').attr('href');
        $play = $('<a href="'+href+'" class="play" title="Play Video">►</a>').click(function(){
            // do something?
        });
        
        var $overlay = $('<div class="video-overlay"><a href="#" class="more" title="More Info">?</a></div>').prepend($play).appendTo($this.find('.image'));
        $overlay.find('a.more').click(function(){
            var $popup = $this.find('.video-description');
            if($popup.length == 0) { 
                $.get(href, {format: 'ajax'}, function(response) {
                    $popup = $(response).hide().attr('id', $this.attr('id') + '-description').prependTo($this);
                    $popup.append($('<a class="close" href=#" title="Click to close."><span class="ui-icon ui-icon-close"></span></a>').click(function(){$popup.toggle();return false;}));
                    var o = $this.offset();
                    //var left = $this.closest('div.section').hasClass('last');
                    $popup.css({
                        zIndex: 1001,
                        position: 'absolute',
                        height: $this.height() -2,
                        top: 0,
                        left: ($this.position().left > 400? -403 : 191)
                    }).show();   
                }, 'html');
            } else {
                $popup.toggle();
            }
            
            return false;
        });
        $this.hover(function(){$overlay.fadeIn()}, function(){$overlay.fadeOut()});
    });
}



$().ready(function(){
    $('#all-videos').unbind('.tabs').attr('href', Ctrl.Config.baseUrl + '/videos');
    
    $('#content .rowA .video').colorVideo();
    
    /*$('#content .rowA .ctrl-paginator').colorPaginator({
        type: 'vertical',
        nextText: '▼',
        prevText: '▲'
    });*/
    
    $('#content .rowB .ctrl-paginator').colorPaginator({
        nextText: 'Next ►',
        prevText: '◄ Prev'
    });

    $('#now-playing > h2').click(function(e){
        e.stopPropagation();
        $('#now-playing > .inside').slideToggle();
        
        return false;
    });
    
});

