Each animate function (lipAnimate, eyeAnimate, etc.) creates a function assigned to the doMove variable.
The problem is that doMove not declared with the var keyword, so you make it global and, as such, it is overwritten with every new call to the "animate" function.
You will need to make it local so that they are not destroyed. But now your setInterval calls doMove , passing a String that expects doMove be global. Instead, it should pass a direct link.
One of the functions has been fixed here. Make the same corrections to the rest.
function lipAnimate(){ var delaylip = 250; var repeatslip = 0; var timeslip = 4; var ilip = 1; var jlip = 0; // Make doMove local function doMove() { if( ilip < timeslip ){ // Chain jQuery functions instead of repeating DOM selection $('#lip').removeClass('lip4') .removeClass('lip'+ilip) .addClass('lip'+(ilip+1)); } else if ( ilip == timeslip ) { $('#lip').removeClass('lip4') .addClass('lip1'); } ++ilip; if( ilip >= timeslip ) { if (jlip < repeatslip || repeatslip == 0) { ilip = 1; jlip++; } else { clearInterval( intervallip ) ; } } } // pass a reference instead of a string var intervallip = setInterval ( doMove, delaylip ); }
In general, it would be better if you only made one function that took parameters instead of creating four almost identical functions.
animatePart(250,0,4,1,0,'#lip','lip',4); animatePart(250,0,3,1,0,'#eye','eyes',3); animatePart(500,0,4,1,0,'#lhs','lft_hnd_',4); animatePart(500,0,4,1,0,'#rhs','rit_hnd_',4); function animatePart(delay,repeats,times,i,j,sel,cls,clsNum){ function doMove() { if( i < times ){ // Chain jQuery functions instead of repeating DOM selection $( sel ).removeClass( cls + clsNum ) .removeClass( cls + i ) .addClass( cls + ( i + 1 ) ); } else if ( i == times ) { $( sel ).removeClass( cls + clsNum ) .addClass( cls + 1 ); } ++i; if( i >= times ) { if (j < repeats || repeats == 0) { i = 1; j++; } else { clearInterval( interval ) ; } } } var interval = setInterval ( doMove, delay ); }