/*!
 * Galleria Classic Theme
 * http://galleria.aino.se
 *
 * Copyright (c) 2010, Aino
 * Licensed under the MIT license.
 */

(function($) {

Galleria.addTheme({
    name: 'pritchard',
    author: 'Jeffrey Windler, llc',
    version: '1.0',
    css: 'galleria.pritchard.css',
    defaults: {
        transition: 'flash',
		carousel_steps: 2,
		keep_source: true,
        show_caption: false,
		thumb_fit: false,
		thumb_crop: true,
		image_margin: 3
    },
    init: function(options) {
		
				
		this.$('loader').show().fadeTo(200, .4);
		
		this.bind(Galleria.THUMBNAIL, function(e){
			$(e.thumbTarget).hide().parent().hide().css('border-color','#b3a084');
			$(e.thumbTarget).parent().not('.active').fadeTo(400, 1).children().fadeTo(400, .4);
			$(e.thumbTarget).parent('.active').fadeTo(400, 1).children().fadeTo(400, 1);
		});
        
        
		this.$('thumbnails').children().hover(function() {
            $(this).not('.active').children().stop().fadeTo(100, 1);
		}, function() {
            $(this).not('.active').children().stop().fadeTo(400, .4);
        }).not('.active').children().css('opacity',.4);
		
        
        this.$('stage').hover(this.proxy(function() {
            this.$('image-nav-left,image-nav-right').fadeIn(200);
        }), this.proxy(function() {
            this.$('image-nav-left,image-nav-right').fadeOut(500);
        }));
		
		
		
		this.addElement('projTitle');
		this.addElement('projFooter');
		this.appendChild('container','projTitle');
		this.appendChild('container','projFooter');
        
		this.get('projTitle').appendChild(projTitle);
		this.get('projFooter').appendChild(projBack);
		
		
		
		
		
        this.$('image-nav-left,image-nav-right,counter').hide();
        
        var elms = this.$('info-link,info-close,info-text').click(function() {
            elms.toggle();
        });
        
        if (options.show_caption) {
            elms.trigger('click');
        }
        
        this.bind(Galleria.LOADSTART, function(e) {
            if (!e.cached) {
                this.$('loader').show().fadeTo(200, .4);
            }
            if (this.hasInfo()) {
                this.$('info').show();
            } else {
                this.$('info').hide();
            }
        });

        this.bind(Galleria.LOADFINISH, function(e) {
            this.$('loader').fadeOut(200);
        });
        this.bind(Galleria.LOADSTART, function(e) {
            $(e.thumbTarget).css('opacity',1).parent().css('outline-color', '#b3a084').addClass('active')
				.siblings('.active').css('background-image','url(../../../src/themes/classic/pritchard-visited.png)').css('outline-color', '#fcfaf3')
				.removeClass('active').children().stop().fadeTo(200, .4);
		});
    }
});

})(jQuery);
