AE Keyframe Control through checkboxes
If you look at the part where you have 


if (headIntro==false){
    y =linear(time,t1,t2,v2,v2); //this is calculated first
}

if (headOutro==false){
    y =linear(time,t3,t4,v3,v3); //this is calculated next, overwriting previous value
}  


when headOutro == false is true, the value for y will be calculated using the value returned by the second linear expression, so no matter what it was previously calculated to be it will always return y = linear(time, t3,t4,v3,v3);.

change it to

if (headIntro==false &amp;&amp; time &lt; t2){
    y =linear(time,t1,t2,v2,v2);
}

if (headOutro==false &amp;&amp; time &gt; t3){
    y =linear(time,t3,t4,v3,v3);
}  


so now the linear expressions will only be calculated when the time is in the intro or outro sections respectively.