var Collection = new Class({
	collection	: null,
  entrys			: null,
	current			: 0,
	
	initialize	: function(state) {
		var $this		= this;
		var $entrys	= $$('div.collection-entry');
		
		if(state && state == 'default') {
				$this.collection	= $('collection');
				
				var $size					= window.getSize();
				var $label				= $$('#collection label')[0];
				var $p						= $$('#collection p')[0];
				var $h						= $size.y-152;
				var $y						= null;
		
				$h < 650 	? $h = 650 	: null;
				$h > 1080 ? $h = 1080 : null;
				
				$this.collection.setStyles({
					'opacity'			: 0,
					'display'			: 'block',
					'height'			: $h+'px',
					'overflow'		: 'hidden',
					'background'	: 'url(http://web79.km1103.aconi.com/wp-content/uploads/kollektion-default.jpg) center center no-repeat'
				});
				
				
				var $s		= $label.getSize();
				var $div	= new Element('div',{
					'html'		: '<!-- x //-->',
					'styles'	: {
						'width'				: ($s.x-40)+'px',
						'height'			:	($s.y+40)+'px',
						'position'		:	'absolute',
						'top'					: '50px',
						'left'				: '0px',
						'background'	: '#ffffff',
						'z-index'			: 30,
						'opacity'			: .6
					}
				});
					
				$label.setStyles({
					'text-transform'	: 'uppercase',
					'top'							:	'58px',
					'z-index'					:	40
				});
				
				$p.setStyles({
					'position'		: 'absolute',
					'top'					: '106px',
					'left'				: '11px',
					'z-index'			:	45,
					'color'				: '#444444'
				});
					
				$div.inject($label,'after');
				
				
				$this.collection.fade('in');
		} else {
			if($entrys.length < 1) {
				return false;
				
				var $size					= window.getSize();
				var $h						= $size.y-152;
				var $y						= null;
			} else {
				$this.entrys			= $entrys;
				$this.collection	= $('collection');
				
				var $navigation		= $('collection-navigation');
				
				var $size					= window.getSize();
				var $h						= $size.y-152;
				var $y						= null;
				
				$h < 650 	? $h = 650 	: null;
				$h > 1080 ? $h = 1080 : null;
				
				$this.collection.setStyles({
					'opacity'		: 0,
					'display'		: 'block',
					'height'		: $h+'px',
					'overflow'	: 'hidden'
				});
				
				$entrys.each(function($entry) {
					var $label			= $entry.getChildren('label')[0];
					var $images			= $entry.getChildren('div.collection-images')[0];
					var $background	= $entry.getChildren('span.collection-background')[0].get('html');
					
					$entry.setStyles({
						'width'				: '100%',
						'height'			: $h+'px',
						'background'	: 'url('+$background+') center center no-repeat',
						'overflow'		: 'hidden',
						'position'		: 'absolute',
						'top'					: '0px',
						'left'				: '0px'
					});
					
					if(Browser.chrome) {
						var $s	= {x:377,y:600};
					} else {
						var $s	= $images.getSize();
					}
					
					var $div	= new Element('div',{
						'html'		: '<!-- x //-->',
						'styles'	: {
							'width'				: ($s.x+20)+'px',
							'height'			:	($s.y+20)+'px',
							'position'		:	'absolute',
							'top'					: (($h*.5)-(($s.y+20)*.5)).round()+'px',
							'right'				: '0px',
							'background'	: '#ffffff',
							'z-index'			: 10,
							'opacity'			: .6
						}
					});
					
					$images.setStyles({
						'top'						: (($h*.5)-300).round()+'px',
						'z-index'				: 20
					});
					
					$div.inject($images,'after');
					
					var $s		= $label.getSize();
					var $div	= new Element('div',{
						'html'		: '<!-- x //-->',
						'styles'	: {
							'width'				: ($s.x-40)+'px',
							'height'			:	($s.y+22)+'px',
							'position'		:	'absolute',
							'top'					: (parseInt($images.getStyle('top').split('px').join(''))-10)+'px',
							'left'				: '0px',
							'background'	: '#ffffff',
							'z-index'			: 30,
							'opacity'			: .6
						}
					});
					
					$label.setStyles({
						'top'			:	$images.getStyle('top'),
						'z-index'	:	40
					});
					
					if($y == null) {
						$y = (parseInt($images.getStyle('top').split('px').join(''))+($s.y+15)).round();
					}
					
					$div.inject($label,'after');
				});
				
				$navigation.setStyles({
					'top'	: $y+'px'
				});
				
				$('next').addEvent('click',function() {
					if(++$this.current >= $this.entrys.length) {
						$this.current = 0;
					}
					
					$this.change($this.current);
				});
				
				$('prev').addEvent('click',function() {
					if(--$this.current < 0) {
						$this.current = $this.entrys.length-1;
					}
					
					$this.change($this.current);
				});
				
				$this.change(0);
			}	
		}
	},
	
	change: function(id) {
		var $this = this;
		
		$this.collection.setStyle('opacity',0);
		
		$this.entrys.each(function(item) {
			item.setStyle('opacity',0);
		});
		
		$this.entrys[id].setStyle('opacity',1);
		$this.collection.fade('in');
	}
});

