rendered paste body/**
* After the document has finished loading
*/
$(document).ready(function() {
loadBlock('/mothersclick.com/front/qa', '#front-qa');
loadBlock('/mothersclick.com/front/group', '#front-group');
});
function loadBlock(path, id) {
$.getJSON(path, function(json) {
var newIndex;
var lastIndex;
interval = Math.floor(Math.random() * 2000 + 2000);
setInterval(function() {
// avoid calling the same index twice in a row
do {
newIndex = Math.floor(Math.random() * json.length);
}
while (newIndex == lastIndex);
$(id +' li:last').hide('slow', function(){
$(this).remove();
});
$(json[newIndex]).hide().prependTo(id).show('slow');
interval = Math.floor(Math.random() * 2000 + 2000);
lastIndex = newIndex;
}, interval);
});
}