Some more JS

Hi
I need a function which does the following
function do-the-timer(state,function-to-call,timer-period);
So that the state can be
Stop, Start, Reset-to-Start
The
function-to-call can be anything
myfunction-1 or
myfunction-2 etc
And the
time-period just a value in
mSecs
I have tried the following but have had no joy as every time I call the function it starts another time hence there are loads of timer events running so instead of calling the
myfuction-1 every 5 mins it calls it every time a refresh happens so if you do not do a refresh all is okay but as soon as you do a refresh another instance is started so if you do three refreshes quickly you end up with the original time doing a refresh and at each instance of the three refreshes you get another
Hope this make sense
The calls I have tried are
SetInterval / ClearInterval
And
SetTimeout / ClearTimeout
So any input is apprecisated
Shortie