// when the DOM is ready...
$(document).ready(function () {
  // load the ticker
	var scroller = Bc.Scroll("typewriter");
	$('#be_writer').show();
});

var Bc = {};
Bc.Scroll = function(containerId){
	var _items = [];
	var _index = 0;
	var _rotateInterval = 1500;
	var _containerId;
	var _container;
	function _init(containerId){
		_containerId = containerId;
		_container = $('#'+_containerId);
		
		var list = $("#"+_containerId+" ul").children();
		list.each(function(el) {
			_items.push( jQuery(this).html() );
		});
		//Shuffle items
		_items.sort(function() {
				return 0.5 - Math.random();
			});
		//Start showing items
		_rotate();
	}
	
	function _rotate(){
		if( _index == _items.length ){
	  		_index = 0;
		}
		_container.html(_items[_index]);
		setTimeout( function(){_rotate();}, _rotateInterval );
		_index++;
	}
	
	//constructor
	_init(containerId);
};
