var timerStarted=false;
var startTime=0, stopTime=0, timeTaken=0;

function StartTimer()
{
  if( !timerStarted)
  {  
     startTime = new Date();
     startTime=startTime.getTime();// get time in milliseconds
     timerStarted = true; //Timer Enabled          
  }
}


function StopTimer()
{
  if( startTime ==0 )
   {
     // Change myForm to your Form name and myhiddenfield to your hiddenfield name
     window.document.quoteform.flashgordon.value=0;          
   }
  else
   {
     stopTime = new Date();
     stopTime=stopTime.getTime();
     timeTaken = (stopTime - startTime)/(1000);
     // Change myform to Your Form name and myhiddenfield to your hiddenfield name
     window.document.quoteform.flashgordon.value= timeTaken;
   }
   //Reset the Timer
   ResetTimer();
}

function ResetTimer()
{
  //Reset Timer Info
  startTime=0;
  timerStarted=false; // Disable Timer
}

StartTimer();