var PressViewer = new Class({

	//implements
	Implements: [Options],

	//origColor: null,
	positionsArray: new Array(),	//to store item positions			
	curIndex: null,  				
	prevIndex: null,				
	curPic: null,					
	prevPic: null,

	//options
	options: {
		stage: null,
		thumbs: null,
		items: new Array(),
		transitionTime: 1000
	},
	
	
	
	//initialization
	initialize: function(options) {		
		//set options
		this.setOptions(options);
		
		var self = this;		
		
		self.options.stage.setStyles({
			'position': 'relative'
			
		});
		
		
		self.options.items.each(function(el, k){
			
			el.setStyles({
				'top' : 0,
				'left': 0,
				'position' : 'absolute',
				'opacity' : 0
			});
			
			
			
			
		});
		
		
		self.options.thumbs.each(function(el, k){
			
			el.set('tween', {
				'duration' : 200,
				'ease' : 'cubic:out'
			});
			
			el.store('index', k);
			
			el.addEvents({
				
				'mouseenter' : function(e){
					this.tween('opacity', .5)
				},
				
				'mouseleave' : function(e){
					if(this.retrieve('index') != self.curIndex){
						this.tween('opacity', 1)
					}
				},
				
				'click' : function(e){
					
					if(e){
						e.stop();
						//parent.location.hash = self.options.thumbs[k].get('href');
					}
					
					if(self.prevIndex != null){
						var prevItem = self.options.items[self.prevIndex];
						prevItem.fade('out');
					}
					
					var target = self.options.items[k];
					
					var prevThumb = self.options.thumbs[self.curIndex];
					if(prevThumb != undefined) prevThumb.tween('opacity', 1);
					
					target.fade('in');
					self.prevIndex = k;
					self.curIndex = k;
					this.tween('opacity', .5);
					
				}
				
			});
			
		})
		
		self.start();
		
	},
	
	start: function() {
		
		var self = this; 
		
		self.options.thumbs[0].fireEvent('click');
	}
	
	
	
});