your problem is that you use recursion without a condition to terminate ,
in your case you shouldn't be using recursion at all try using setInterval(functionName, milliseconds)
instead.
setInterval will call functionName
once every milliseconds
function myWay() { // make n and theArray in the outer scope of the function
$('#left-title-bar').hide(500,function (){
$('#left-title-bar').css("background",""+ theArray[number] + "");
$('#left-title-bar').show(500);
if (number==3) {
number = 0;
} else {
number = number+1;
}
}); //delay will not pause the code
}
setInterval(myway,2000) //will run myway once each 2 seconds
Edit : wait for the picture to change before changing it