/*

	Event Preview
	Script: eventpreview.js
	
	Author: Philipp Steingrebe - visit www.steingrebe.de
	All rights reserved (c) 2010
	
*/

EventPreview = new Class({
	Implements : [Events, Options],
	initialize : function(cont, options){
		this.setOptions(options);
		this.container = $(cont).setStyle('position', 'relative');
		this.size = this.container.getSize();
		this.concerts = [];
		
		this.frame = this.container;
		
		this.title = $('previewTitle').addEvent('click', this.redirect.bind(this));
		this.date = $('previewDate').addEvent('click', this.redirect.bind(this));
		this.marker = $('previewMarker');
		
		this.preview = new Preview(this.frame).addEvent('change', this.change.bind(this));
	},
	addConcert : function(src, title, date, url, status){
		this.concerts.push({
			src : src,
			title : title,
			date : date,
			url : url,
			status : status
		});
		this.preview.addImage(src);
		return this;
	},
	change : function(index){
		this.title.set('text', this.concerts[index].title);
		this.date.set('text', this.concerts[index].date);	
		this.url = this.concerts[index].url;
		
		if(this.concerts[index].status == 'available')
			this.marker.set('class', '');
		else
			this.marker.set('class', this.concerts[index].status);
	},
	redirect : function(){
		window.location.href= this.url;
	},
	start : function(){
		this.preview.start();			
	}
});
