﻿/**
 * MooTools
 * Typewriter Effect Class by davidwalsh-dot-name ! grazie
 */

//class is in
var Typewriter = new Class({
	
	//implements
	Implements: [Options],

	//options
	options: {
		container: $$('body')[0],
		message: '',
		delay: 150,
		cursor: 0
	},
	
	//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++)
		{
			//spit out the letter
			var id = this.setLetter.delay(this.options.delay * x,this);
		}
	},
	
	//place the newest letter in the container
	setLetter: function() {
		
		if (this.options.message.charAt(this.options.cursor)!='»')
		{
			this.options.container.set('html',this.options.container.get('html') + '' + this.options.message.charAt(this.options.cursor));
		
			//increment cursor
			this.options.cursor++;
		}
		else
		{
			this.options.container.set('html',this.options.container.get('html') + '' + this.options.message.charAt(this.options.cursor));
			
			// fertig
			(function(){ type('s'); }).delay(2000);
		}
	}
});

function type(was){
	if (!was || was=='') {
		$('type').set('text', '');
		var t = new Typewriter({
			container: $('type'),
			message: shout_t[count],
			delay:100
		}).start();

		// zaehler
		if (count==maxcount) {
			count = 0;
		} else {
			count++;
		}
	}
	else
	{
		var text = $('type').get('html');
		var zahl	= (count!=0)
					? count-1
					: maxcount;

		$('type').set('html', text + ' ' + shout_s[zahl]);
	}
}

window.addEvent('domready', function() {
	var m0 = new Array('com', '.', 'schmid', '-', 'moritz', '&#64;', 'info');
	var hello = m0[6]+m0[5]+m0[4]+m0[3]+m0[2]+m0[1]+m0[0];
	$('m1').set('html', hello);
	$('m2').set('html', '<a href="mailto:' + hello + '">' + hello + '<\/a>');
	type.delay(500);
	type.periodical(16000);
});




