var text="content of text here";
var addr = "http://www.google.com";
var delay=50;
var currentChar=1;
var destination="[not defined]";
var cursor = '';
var counter = 0;
var array = ['content of text here'];
var url_array = [ 'http://www.gooogle.com' ];

function type(){
	if (document.getElementById){
		var dest=document.getElementById(destination);
		if (dest){
			if(currentChar % 2 == 0){
				cursor = '_';
			}else{
				cursor ='';
			}
			dest.innerHTML='<a href="' + addr + '">' +  text.substr(0, currentChar)+cursor + '</a>';
			currentChar++
			if (currentChar>text.length){
				currentChar=1;
				
				text=array[counter];
                                addr=url_array[counter];
				counter++;
				if(array.length == counter){
					counter = 0;
				}
				
				setTimeout("type()", 5000);
			}else{
				setTimeout("type()", delay);
			}
		}
	}
}
function startTyping(arr, url_arr, delayParam, destinationParam){
	array = arr;
        url_array = url_arr;
	delay=delayParam;
	currentChar=1;
	destination=destinationParam;
	type();
}

function set_counter(direction){
	
	setTimeout("type()", 5000);
	
	currentChar=1;
	text=array[counter];
        addr= url_array[counter];
	counter++;
	if(array.length == counter){
		counter = 0;
	}
	
	
	if(direction == 'next'){
		counter++;
		type();
	}else{
		counter--;
		type();
	}
}
