/**
 * @preserve Galleria Classic Theme 2011-08-01
 * http://galleria.aino.se
 *
 * Copyright (c) 2011, Aino
 * Licensed under the MIT license.
 */

/*global jQuery, Galleria */

Galleria.requires(1.25, 'This version of Featured theme requires Galleria 1.2.5 or later');

(function($) {

Galleria.addTheme({
    name: 'featured',
    author: 'Galleria',
    css: 'galleria.featured.css',
    defaults: {
        transition: 'slide',
        thumbCrop:  'height',
        thumbnails: false,
        carousel: false,
        autoplay: 10000,
        showInfo: false
    },
    init: function(options) {

        // add some elements
        this.addElement('info-link','info-close');
        this.append({
            'info' : ['info-link','info-close']
        });

        // cache some stuff
        var info = this.$('info-link,info-close,info-text'),
            touch = Galleria.TOUCH,
            click = touch ? 'touchstart' : 'click';

        // show loader & counter with opacity
        this.$('loader,counter').show().css('opacity', 0.4);

        // some stuff for non-touch browsers
        if (! touch ) {
            this.addIdleState( this.get('image-nav-left'), { left:-50 });
            this.addIdleState( this.get('image-nav-right'), { right:-50 });
            this.addIdleState( this.get('counter'), { opacity:0 });
        }

        // enable keyboard
        this.attachKeyboard({
            left: this.prev,
            right: this.next,
            space: function(){
                this.playToggle(3000);
            },
            'return': function(){
                this.toggleFullscreen();
            }
        });

        this.bind('loadstart', function(e) {
            if (!e.cached) {
                this.$('loader').show().fadeTo(200, 0.4);
            }
        });

        this.bind('loadfinish', function(e) {
            this.$('loader').fadeOut(200);
        });
    }
});

}(jQuery));

