//user configurables
var delayTime = 20; //delay between showing each letter

//constants
var htmlStr;
var strLen;
var tempStr="";
var n=0;
var strAR = new Array();
var tempInterval = new Array();

//jQuery
$(document).ready(function(){
	
	/* prepText(); */
	
	startAnim();
	
	startAnim2();
  
  	/* blockMove ();  */
  	
});

//functions
function startAnim(){
	$('.text-you-home').delay(1000).css("opacity","0").animate({
		opacity: .9
		}, 1500, function() {
		// Animation complete.
		$('.text-you-home').css("opacity","1")
	});
}


function startAnim2 (){
	$('.text-section').delay(2500).css("opacity","0").animate({
		opacity: .9
		}, 500, function() {
		// Animation complete.
		//renText(0);
	});
}

function blockMove (){
	$('.text-section').delay(700).css("opacity","0").animate({
		opacity: .9
		}, 1500, function() {
		// Animation complete.
		renText(0);
	});
}

function prepText(){
	/* str.replace("Microsoft", "W3Schools") */
	
	htmlStr = $(".text-section p").html();
	htmlStr = htmlStr.replace(/<br>/g, "<br />");
	strAR = htmlStr.split("");
	strLen = strAR.length-1;
	
	$(".text-section p").html(""); //clear out the text on screen
}

function renText(n){
	tempStr = tempStr + strAR[n];
	$(".text-section p").html(tempStr);
	
	if (n < strLen){
		n++;
		tempInterval[n] = window.setTimeout("renText(" + n + ")",delayTime);
	}
}
