/************************************************************************
 * 		Status Box für das Logging										*
 * 		C 2008 by René Lange & Thomas Müller & Steve Rohrlack @ mindbox	*
 ************************************************************************/

// Statusbox für Anzeige von Nachrichten
var StatusBox = new Class({
	maxWidth : 250,
	messageMapper : new Array(),
	
	initialize : function (msg){		
		this.fillMapper();
		
		this.sb = new Element('div',{'id':'statusBox'})
		this.sb.setStyles({
			'border' : '2px solid #2F6D90',
			'background-color' : '#FFFFFF',
			'padding' : '3px',
			'padding-right' : '0',
			'border-right-width' : '0px',
			'position' : 'absolute',
			'display' : 'none',
			'overflow' : 'hidden',
			'width' : 0,
			'left' : window.getScrollWidth()
		});
		this.sbContent = new Element('div',{'id':'statusBoxContent'})
		this.sbContent.setStyles({
			'width' : this.maxWidth,
			'white-spaces' : 'nowrap'
		});
		
		this.slider = this.sb.effects({duration: 2000, transition: Fx.Transitions.Sine.easeInOut});
		
		this.opac = new Fx.Tween(this.sbContent,'opacity',{duration:3000});
		this.sb.adopt(this.sbContent);
		this.sb.injectInside(document.body);
		
		if(msg){
			this.showBox(msg);
		}
	},
	
	showBox : function(msg){
		// Nachricht mappen, falls sie eingetragen wurde
		var index = this.messageMapper.inArray(msg, 'where');
		if (index != false) {
			msg = this.messageMapper[index][1];
		}
		
		var top = (window.getScrollTop()+150);
		var width = this.maxWidth;
		
		this.sb.setStyles({
			'top' : top,
			'display' : 'block'
		});
		this.sbContent.setHTML(msg);
		
		this.slider.start({
			'width' : width,
			'left' : window.getWidth() - width,
			'opacity' : 1
		}).chain(function(){
			this.start.delay(3000, this, {
				'width' : 0,
				'left' : window.getWidth(),
				'opacity' : 0
			});
		}).chain(function(){
			this.sb.setStyles({
				'display' : 'none',
				'opacity' : 1
			})
			this.sb.removeClass(this.sb.getProperty('class'));
			this.resetColor();
		}.bind(this));
	},
	
	resetColor : function(){
		this.setColor({
			'border' : '2px solid #2F6D90',
			'border-right' : '0px',
			'color' : '#000'
		});
	},
	
	setColor : function(sbStyles){
		this.sb.setStyles(sbStyles);
	},
	
	resizeBox : function(){
		
	},
	
	fillMapper : function(){
		this.messageMapper = new Array();	
		this.messageMapper.push(new Array('def_stl', 'Saved Tour loaded'));	
		this.messageMapper.push(new Array('def_saved', 'Saved Tour loaded'));	
		this.messageMapper.push(new Array('def_rtl', 'Ready Tour loaded'));	
		this.messageMapper.push(new Array('def_dm', 'Map successfully updated'));	
		this.messageMapper.push(new Array('def_em', 'Entry successfully moved'));	
		this.messageMapper.push(new Array('def_ems', 'Entry successfully set as starting point'));	
		this.messageMapper.push(new Array('def_ems', 'Accomodation successfully changed'));	
		this.messageMapper.push(new Array('def_tnc', 'Tour Name successfully changed'));
		this.messageMapper.push(new Array('def_tdc', 'Days of Tour successfully changed'));
		this.messageMapper.push(new Array('def_ts', 'Tour saved'));
		this.messageMapper.push(new Array('def_td', 'Tour deleted'));
		this.messageMapper.push(new Array('def_tdsl', 'Length of Tour wasn\'t changed'));
		this.messageMapper.push(new Array('def_aec', 'Accomodation was changed'));
		this.messageMapper.push(new Array('def_stl', 'Saved Tour loaded'));	
		
	}
});