var EchoesWorks = function (options) {
	var defaults;
	defaults = {
		element: 'slide',
		auto: false
	};

	if (options === undefined) {
		console.log("Default Options is Empty, use default options...");
		options = {};
	}

	EchoesWorks.defaults(options, defaults);

	this.options = options;
	if (options.source) {
		this.source = this.options.source;
	}
	this.element = this.options.element;
	this.playing = false;
	this.data = [];
	this.fps = 10;
	this.time = 0;
	if (this.options.auto) {
		this.play();
	}
	this.init();
};

EchoesWorks.prototype.init = function () {
	var that = this;

	that.slide();
	EchoesWorks.triggerEvent("ew:slide:init");

	if (window.slide) {
		window.slide.auto = that.options.auto;
		that.parser();
		setInterval(function () {
			that.update();
		}, 1000 / this.fps);
	}
};

EchoesWorks.prototype.stop = function () {
	console.log("total time:", this.time);
	this.playing = false;
	this.time = 0;
};

EchoesWorks.prototype.pause = function () {
	this.playing = false;
};

EchoesWorks.prototype.play = function () {
	this.playing = true;
};

EchoesWorks.prototype.update = function () {
	if (this.playing) {
		this.time += 1 / this.fps;
	}
	this.applyEchoes();
};

function showCode(that, currentSlide) {
	var url = EchoesWorks.fn.rawGitConvert(that.data.codes[currentSlide]);
	EchoesWorks.get(url, function (response) {
		document.querySelector('pre').innerHTML = response;
		document.querySelector('slide').classList.remove('full');
		document.querySelector('code').classList.remove('hidden');
	});
}

function showWords(that, currentSlide) {
	var words = that.data.words[currentSlide];
	//To do use stand speak speed 
	//var standSpeakSpeed = 60 / 240 * 100;

	if(EchoesWorks.isObject(words)){
		if(that.time < that.parser.parseTime(that.data.times)[currentSlide + 1]){
			document.querySelector('words').innerHTML = words[0].word;
		}
	} else {
		document.querySelector('words').innerHTML = words;
	}
}

function hiddenWords() {
	document.querySelector('slide').classList.add('full');
	document.querySelector('words').classList.add('hidden');
}

function hiddenCode() {
	document.querySelector('slide').classList.add('full');
	document.querySelector('code').classList.add('hidden');
}

EchoesWorks.prototype.applyEchoes = function () {
	var that = this;
	var isDataValid = that.parser.data && that.parser.data.codes !== undefined && that.parser.data.codes.length > 0;
	if (isDataValid) {
		that.data = that.parser.data;
		var times = that.parser.parseTime(that.data.times);
		var currentSlide = window.slide.slide();

		if (parseFloat(that.time) > times[currentSlide] && window.slide.auto) {
			window.slide.next();
			if (that.data.codes[currentSlide]) {
				showCode(that, currentSlide);
			} else {
				hiddenCode();
			}
			if (that.data.words[currentSlide]) {
				showWords(that, currentSlide);
			} else {
				hiddenWords(that, currentSlide);
			}
		}
	}
};


EchoesWorks.version = EchoesWorks.VERSION = '0.1.1';

root.EchoesWorks = EchoesWorks;
root.EW = EchoesWorks;
@@ -1644,10 +1644,9 @@
 peed
- 
 %0A
+
 %09//v
@@ -1723,82 +1723,354 @@
 %7B%0A%09%09
-if(that.time %3C that.parser.parseTime(that.data.times)%5BcurrentSlide + 1%5D
+var nextTime = that.parser.parseTime(that.data.times)%5BcurrentSlide + 1%5D;%0A%09%09if(that.time %3C nextTime && words.length %3E 1)%7B%0A%09%09%09var length = words.length;%0A%09%09%09var currentTime = that.parser.parseTime(that.data.times)%5BcurrentSlide%5D;%0A%09%09%09var time = nextTime - currentTime;%0A%09%09%09var average = time / length * 1000;%0A%09%09%09var i = 0;%0A%0A%09%09%09setInterval(function(
 )%7B%0A
+%09
 %09%09%09d
@@ -2122,17 +2122,17 @@
 rds%5B
-0
+i
 %5D.word;%0A
 %09%09%7D%0A
@@ -2127,16 +2127,43 @@
 %5D.word;%0A
+%09%09%09%09i ++ ;%0A%09%09%09%7D, average);%0A
 %09%09%7D%0A%09%7D e

add interval function for word