

var jzTimetable = {
    
    alpha: [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '?', '"', "'", '.', ',', '/', '‚','î', 'Í','ç', 'Ì','ƒ','æ'],
    linesArray: [],
    delay: 150,
    className: 'jzTimetable',
    goBackOffset: 10,
    maxNumberOfLines: 4,
    cycleLines: true,
    //cycleOrder: 'random', //random, asc, desc
    cycleInterval: 1,
    
    start: function(){
	
	$('.' + jzTimetable.className).each(function(index) {
	    var text = $(this).html();
	    $(this).html('<ul class="' + this.className + '_line" id="' + this.className + '_line_' + index + '"></ul>');
	    jzTimetable.linesArray.push(text);
	    
	    jzTimetable.setLineContent('#' + this.className + '_line_' + index, text);
	    
	    if(index>=jzTimetable.maxNumberOfLines) $(this).hide();
	    
	});
	
	
	if(jzTimetable.cycleLines) jzTimetable.cycleLines(0);                    
    },
    
    setLineContent: function(parentID, content){
		
	    $(parentID).html();
	    
	    for(i=0; i<content.length; i++){
		$(parentID).append('<li id="' +parentID.replace('#', '') + '_char_' + i + '">' + content[i] + '</li>');
		jzTimetable.animateChar(parentID + '_char_' + i, content[i], jzTimetable.getCharAlphaPosition(content[i]), 0);
	    }
    
    },
    
    cycleLines: function(currentIndex){

	
	$('.' + jzTimetable.className).each(function(index) {
	
	    
	    if(index>=currentIndex && index<parseInt(currentIndex+jzTimetable.maxNumberOfLines)){
		$('#' + this.className + '_line_' + index).html('');
		jzTimetable.setLineContent('#' + this.className + '_line_' + index, jzTimetable.linesArray[index]);
		$(this).show();
		
	    }else{
		$(this).hide();
	    } 
	    
	    
	});
	
	currentIndex = parseInt(currentIndex+jzTimetable.maxNumberOfLines);
	if(currentIndex+jzTimetable.maxNumberOfLines>jzTimetable.linesArray.length) currentIndex = 0;
	
	setTimeout("jzTimetable.cycleLines(" + currentIndex + ");", 15000);
    },
    
    animateChar: function(char_id, char, index, goAround){

	    if(char==this.alpha[index]){
		$(char_id).html(char);
		return;
	    }else{
		$(char_id).html(this.alpha[index]);
		
		if(goAround!=1)
		if(index<this.alpha.length){
		    index ++;
		}else{
		    index = 0;
		    goAround ++;
		}
		
		setTimeout("jzTimetable.animateChar('" + char_id + "','" + char + "'," + index + "," + goAround + ")", this.delay);
	    }

	    
	
    },

    
    getCharAlphaPosition: function(char){
	
	for(c=0; c<this.alpha.length; c++){
	    if(char==this.alpha[c]) {
		if(c-this.goBackOffset>=0) return c-this.goBackOffset; else return c;
	    }
	}
	return 0;
	
    }
    
};




jzTimetable.start();
