/* PPC: Customized */

// when the DOM is ready...
$(document).ready(function () {
  // load the ticker
	createTicker();
}); 

function createTicker(){
	// put all list elements within #ticker-area into array
	$(".colour-box").css({ "text-indent": "0" });
	var tickerLIs = $(".colour-box").children();
	tickerItems = new Array();
	tickerLIs.each(function(el) {
		tickerItems.push( jQuery(this).html() );
	});
	i = 0
	rotateTicker();
}

function rotateTicker(){
	if( i == tickerItems.length ){
	  return false;
	}
  tickerText = tickerItems[i];
	c = 0;
	typetext();
	setTimeout( "rotateTicker()", 5000 );
	i++;
}

var isInTag = false;
var lastChar;
var thisChar;
function typetext() {	
	lastChar = thisChar;
	thisChar = tickerText.substr(c, 1);
	if( thisChar == '<' ){ isInTag = true; }
	if( thisChar == '>' ){ isInTag = false; }
	$('.colour-box p').html("&nbsp;" + tickerText.substr(0, c++));
	if(c < tickerText.length+1)
		if( isInTag ){
			typetext();
		}else{
			if (lastChar == '.' || lastChar == '?' || lastChar == '!')
				setTimeout("typetext()", 380);
			else
				setTimeout("typetext()", 28);
		}
	else {
		c = 1;
		tickerText = "";
	}	
}


