var WordPressGallery = new Class({

	Extends: SlideShow,
	
		options: {
			inject: false,
			elementAttributes: {
				'class': 'transition:crossFade duration:1000'
			},
			autoStart: false
		},

	initialize: function(element, options){
		this.setOptions(options);
		this.element = document.id(element);
		this.storeHouse = new Storehouse().dispose(this.element, 'el');
		this.elements = [];
		this.build();
		this.parent(element, options);
		if(this.options.autoStart) this.play();
	},
	
	build: function(){
		this.makeElements().inject();
		return this;
	},
	
	makeElements: function(){
		var anchors = this.element.getElements('a');
		this.element.getElements('a').each(function(link, index){
			this.elements.include(this.makeElement(link));
		}, this);
		this.storeHouse.dispose(anchors, 'oldAnchors');
		return this;
	},
	
	makeElement: function(link){
		var bg = {
			'styles': { 
				'background-image': 'url(' + link.get('href') + ')',
				'background-repeat': 'no-repeat',
				'background-position': 'center center'
				}
			};
		return new Element('div', $merge(bg, this.options.elementAttributes));
	},
	
	inject: function(){
		this.element.empty().adopt(this.elements);
		if(this.options.inject){
			var inject = this.options.inject;
			this.element.inject(inject.element, inject.where);
		} else {
			this.storeHouse.inject('el');
		}
		
		return this;
	}

});


