in reply to Boolean counter?
I tend to use
$toggle *= -1;
Update: I stand corrected, thanks LanX. I often use that for alternating rows but it's wrong here.
Your idea works the following way - even if it doesn't look as elegant any more:
$toggle = -1 * ($toggle - 0.5) + 0.5;