var Quotator = new Class({
	
	Implements: [Options, Events],
	
	options:{
		json : './js/quotator/quotes.js',
		speed : 6000,
		start : 0,
		encoding : 'iso-8859-1'
	},

	quotes_french:
	 [
		{
			"quote" : "«En tant que fiscaliste, je recommande l'utilisation de cet outil afin de se conformer aisément aux lois fiscales en vigueur.»",
			"author" : "Jocelyn Prévost, CGA",
			"url" : "./testimonials"
		},
		
		{
			"quote" : "«Odotrack est une merveilleuse innovation technologique en matière de fiscalité.»",
			"author" : "Benoit Voyer<br />Montréal",
			"url" : "./testimonials"
		},
		{
			"quote" : "«La gestion du kilométrage n’a jamais été aussi simple et facile.»",
			"author" : "Michel Roy<br />Québec",
			"url" : "./testimonials"
		},
		{
			"quote" : "«Odotrack me simplifie la vie.»",
			"author" : "Nadia Madzarac<br />Directrice de comptes pour Accolade Reaction Groupe Promotionnel",
			"url" : "./testimonials"
		},
		{
			"quote" : "«En plus d’éliminer les problèmes d’impôts, je n’ai pas besoin d’écrire dans le détail chacun de mes déplacements.»",
			"author" : "Marcel Lemieux<br />Québec",
			"url" : "./testimonials"
		}	
	]
	,
	
	quotes_english:
	 [
		{
			"quote" : "«As a tax expert, I recommend using this tool so you can easily comply with tax laws.»",
			"author" : "Jocelyn Prévost, CGA",
			"url" : "./testimonials"
		},
		
		{
			"quote" : "«Odotrack is a wonderful technological innovation in taxation.»",
			"author" : "Benoit Voyer<br />Montreal",
			"url" : "./testimonials"
		},
		{
			"quote" : "«The management of mileage has never been so easy and simple.»",
			"author" : "Michel Roy<br />Quebec",
			"url" : "./testimonials"
		},
		{
			"quote" : "«Odotrack simplifies my life.»",
			"author" : "Nadia Madzarac<br />Account manager for Accolade Reaction Promotion Groupe",
			"url" : "./testimonials"
		},
		{
			"quote" : "«In addition to eliminating the taxation problems, I no longer need to manually write the details of each of my trips.»",
			"author" : "Marcel Lemieux<br />Quebec",
			"url" : "./testimonials"
		}	
	]
	,	

	initialize: function(element, language, options){
		this.setOptions(options);
		this.language = language;
		this.element = $(element);
		this.quotes = eval('this.quotes_'+language);
		this.element.set(
						'html' , 
						"<div id='quote'><a href='" + this.quotes[this.options.start].url + "'>" + this.quotes[this.options.start].quote + "</a></div><div id='quotatorAuthor'>- " + this.quotes[this.options.start].author + "</div>"
					);
				
		setInterval(this.changeQuote.bind(this), this.options.speed);		
		
	},
	
	changeQuote : function(){
		if(this.options.start == this.quotes.length - 1){
        	this.options.start = 0;
		} else{
        	this.options.start++;
      	}
      	
      	this.fadeIn(this.options.start);
      	
	},
	
	fadeIn : function(index){
		var fader = new Fx.Tween(this.element,{property : 'opacity'});
		
	
		fader.start(0).chain(
			function() {
				this.element.set(
					'html', 
					"<div id='quote'><a href='" + this.quotes[this.options.start].url + "'>" + this.quotes[index].quote + "</a></div><div id='quotatorAuthor'>- " + this.quotes[index].author + "</div>"
				); 
				fader.start(1); 
			}.bind(this)
		);
	}
});
