/*!
 * Galleria Classic Theme
 * http://galleria.aino.se
 *
 * Copyright (c) 2010, Aino
 * Licensed under the MIT license.
 */

(function($) {

Galleria.addTheme({
    name: 'classic',
    author: 'Galleria',
    version: '1.2',
    css: 'galleria.classic.css',
    defaults: {
        transition: 'slide',
        show_caption: false,
        thumb_crop: 'height'
    },
    init: function(options) {
      

        
        this.addElement('info-link'); /*need to pull title of image into info-link*/
        this.append({
            'info' : ['info-link']
        });
        
        
       
        
        this.$('loader').show().fadeTo(200, 1);
        this.$('counter').show().fadeTo(200, 1);
        
        this.$('thumbnails').children().hover(function() {
            $(this).not('.active').children().stop().fadeTo(100, 1);
        }, function() {
            $(this).not('.active').children().stop().fadeTo(400, 1);
        }).not('.active').children().css('opacity',1);
        
        //commenting out the below lines keeps the right and left arrows from disappearing when not hovered
        
        //this.$('container').hover(this.proxy(function() {
        //    this.$('image-nav-left,image-nav-right,counter').fadeIn(200);
       // }), this.proxy(function() {
       //     this.$('image-nav-left,image-nav-right,counter').fadeOut(500);
       // }));
        
        //this.$('image-nav-left,image-nav-right,counter').hide();
        
        var elms = this.$('info-link,info-text').click(function() {
            elms.slideToggle(400);
            
        });
        
        
        $('.galleria-thumbnail-list').css("height", "50px");
        
        
        if (options.show_caption) {
            elms.trigger('click');
        }
        
        this.bind(Galleria.LOADSTART, function(e) {
        	if (this.$('info-link').css("display") == "none") {
        		this.$('info-text').slideToggle(1);
    		}
        	
            if (!e.cached) {
                this.$('loader').show().fadeTo(200, .4);
            }
            
            
        });

        this.bind(Galleria.LOADFINISH, function(e) {
        	
            this.$('loader').fadeOut(200);
            
            if (this.$('info-link').css("display") == "none") {
            
           		 if (this.hasInfo()) {
             		   this.$('info-text').delay(800).slideToggle(600);
           		 } else {
              		   this.$('info-text').delay(800).slideToggle(600);
           		}
      		  }
            
        });
        
      
        
        this.bind(Galleria.LOADSTART, function(e) {
            $(e.thumbTarget).css('opacity',1).parent().addClass('active')
                .siblings('.active').removeClass('active').children().css('opacity',1);
        })
        
    }
});

})(jQuery);

