var Printer = new Class({
    options: {
    	'aim':'aim','showTime':200, 'waitTimes':5, 'waitTimesNow':0, 'nowIndex':0,'nowTextIndex':0, 'texts':['abcdefghigklmnopqrstuvwxyz']
    },
    initialize: function(options){
        this.setOptions(options);
    },
    play:function(){
    	var self = this;
    	this.interval = window.setInterval( function(){	self.change.apply( this, [ self ]);}, self.options.showTime );
    },
	setIndex:function(index){
		this.options.nowIndex = index;
		this.options.nowTextIndex = 0;
	},
    change:function(self){
		var length = self.options.texts[ self.options.nowIndex ].length;
		if( self.options.nowTextIndex <= length){
			self.prt(self, self.options.texts[ self.options.nowIndex ].substring(0, self.options.nowTextIndex))
		}else{
			if( self.options.waitTimesNow > self.options.waitTimes ){
				if( self.options.nowIndex < self.options.texts.length-1 ){
					self.options.nowIndex++;
					self.options.nowTextIndex = 0;
				}else{
					self.options.nowIndex = 0;
					self.options.nowTextIndex = 0;
				}
				self.options.waitTimesNow = 0;
			}else{
				self.options.waitTimesNow++
			}
		}
    	self.options.nowTextIndex++;
    },
	prt:function(self, text){
		$(self.options.aim).innerHTML = text+'<img src=public/themes/default/images/util/mousehilight.gif />';
	}
});
Printer.implement(new Options);