//class is in  
var Typewriter = new Class({  
      
    //implements  
    Implements: [Options],  
  
    //options  
    options: {  
        container: $$('body')[0],  
        message: '',  
        delay: 150,  
        cursor: 0,  
        variance: 0,  
        backChar: '|',  
        backDelay: 30  
    },  
      
    //initialization  
    initialize: function(options) {  
        //set options  
        this.setOptions(options);  
    },  
      
    //start the Typewriter  
    start: function() {  
          
        //for every letter  
        for(x = 0; x < this.options.message.length; x++)  
        {  
            var pace = (this.options.delay * x) + $random(0,this.options.variance);  
            var current = this.options.message.charAt(x);  
              
            //spit out the letter  
            if(current != this.options.backChar)  
            {  
                var go = this.setLetter.delay(pace,this);  
            }  
            else  
            {  
                var go = this.deleteLetter.delay(pace + this.options.backDelay,this);  
            }  
              
        }  
    },  
      
    //place the newest letter in the container  
    setLetter: function() {  
          
        this.options.container.set('html',this.options.container.get('html') + '' + this.options.message.charAt(this.options.cursor));  
          
        //increment cursor  
        this.options.cursor++;  
    },  
      
    //deletes a letters -- goes backward  
    deleteLetter: function() {  
          
        this.options.container.set('html',this.options.container.get('html').substr(0,this.options.container.get('html').length - 1));  
          
        //increment cursor  
        this.options.cursor++;  
    }  
      
});  