
	wps.quotes = function(options){
		this.instID = 'wps.quotes.' + parseInt(Math.random()*1000000);
		this.container = options.get('container') || $('quotes');
		this.shadowContainer = options.get('shadowContainer') || $('quoteShadow');
		this.defaultQuote = options.get('defaultQuote') || 'Richt zorg in zijn kern';
		this.speed = options.get('speed') || 10000;
		this.fontSize = options.get('fontsize') || 35;
		this.state=0;
		if (this.is_ie()){
			this.avgCharWidth = 15;
		}else{
			this.avgCharWidth = 22;
		}
		this.defaultFontSize = parseInt(this.container.style.fontSize)||30;
	}
	
	wps.quotes = wps.quotes.extendsFrom(wps.base);
	
	wps.quotes.prototype.setQuotes = function(hash){
		this.quotes = hash.toArray();
	}
	
	wps.quotes.prototype.draw = function(){
		if (this.state ==0){
			this.container.style.fontSize = this.defaultFontSize + 'px';
			this.shadowContainer.style.fontSize = this.defaultFontSize + 'px';
			Element.update(this.container, this.defaultQuote);
			Element.update(this.shadowContainer, this.defaultQuote);
			this.state =1;
			this.show();
			setTimeout(this.setTimed.bind(this), 5000);
		}else{
			if (!this.activeQuote){
				var quote = this.getRndQuote();
				this.activeQuote = quote;
			} 
			/*var rows = (this.activeQuote.length * this.avgCharWidth) / parseInt(this.container.getStyle('width'))  + 1;
			var maxHeight = parseInt(this.container.getStyle('height'));
			if (rows > 1){
				var maxFontSize = (maxHeight/rows);
				if (maxFontSize < 9) maxFontSize = 9;
			}else{
				var maxFontSize = this.defaultFontSize;
			}
			//console.log((quote.length * 23)+ '//' + this.container.getStyle('width') + '// Rows: ' + rows + '// estimated size:' + maxFontSize);
			this.container.style.fontSize = maxFontSize + 'px';
			this.shadowContainer.style.fontSize = maxFontSize + 'px';
			*/
			this.container.style.fontSize = '13px';
			this.shadowContainer.style.fontSize = '13px';
			Element.update(this.container, this.activeQuote);
			Element.update(this.shadowContainer, this.activeQuote);
			this.state =0;
			this.show();
			setTimeout(this.setTimed.bind(this), this.speed);
		}
	}
	
	wps.quotes.prototype.setTimed = function(){
		this.hide()
		var func = (function(){this.draw()}).bind(this)
		setTimeout(func, 1500);
	}
	
	wps.quotes.prototype.getRndQuote = function(){
		var cnt = this.quotes.length;
		var rnd = this.getRnd(0, cnt);
		var quote =this.quotes[rnd]; 
		return quote.value + '  -  ' + quote.key; 
	}
	
	wps.quotes.prototype.getRnd = function(min,max){
		return parseInt((min + (max-min)*Math.random())); 
	}
	
	wps.quotes.prototype.show = function(){
		new Effect.Appear(this.container, {duration:'1.5'});
		setTimeout(
			(function(){new Effect.Appear(this.shadowContainer, {duration:'1.5'});}).bind(this),
			100
		);
	}
	
	wps.quotes.prototype.hide = function(){
		new Effect.Fade(this.container, {duration:'1.5'});
		setTimeout(
			(function(){new Effect.Fade(this.shadowContainer, {duration:'1.5'});}).bind(this),
			100
		);
	}
	