depoimentos = [];

//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/shuffle [v1.0]

shuffle = function(o){ //v1.0
	for (var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

$(document).ready(function(){
	
	$.getJSON('/js/depoimentos_pt.json', function(data){
		for (key in data){
			depoimentos.push(data[key]);
		}
		depoimentos = shuffle(depoimentos);
		if (depoimentos.length < 5){
			$('#depoimento .proximo').css('visibility','hidden');
		}
		proximo();
	});
	
	function proximo() {
		dep = depoimentos.shift();
		$('#depoimento blockquote p').text(dep.quote);
		$('#depoimento .autor cite').text(dep.autor);
		depoimentos.push(dep);
	}
	
	$('#depoimento .proximo a').click(function(event) {
		proximo();
		return false;
	});
});
