
	var timerID = 0;
	var tStart  = null;

	function UpdateTimer() {
	
   		if(timerID) {
      		clearTimeout(timerID);
      		clockID  = 0;
   		}

	   	if(!tStart) {
	      	tStart = new Date();
		}

	   	var tDate = new Date();
	   	var tDiff = tDate.getTime() - tStart.getTime();
	
	   	tDate.setTime(tDiff);
	   	
	   	document.temptationItemForm.theTimeCounterCheck.value = tDate.getMinutes() + ':' + tDate.getSeconds();	   		  
	
	   	document.temptationItemForm.theTime.value = "Your shopping session has been timed to expire in 20mins." + 
	   										"You have used up [ " +
	   										tDate.getMinutes() + " m : " 
	   										+ tDate.getSeconds() + " s ] of the allocated 20mins.";
	   
	   	document.getElementById('counter').innerHTML = document.temptationItemForm.theTime.value;	   		 
	   	
	   	timerID = setTimeout("UpdateTimer()", 1000);	   	
	   	
	   	//if(document.temptationItemForm.theTimeCounterCheck.value == '1:50') {
	   	if(document.temptationItemForm.theTimeCounterCheck.value == '20:0') {
	   		Stop();
	   		document.getElementById('counter').innerHTML = 'Your session has timed out.';
	   	}	   	
	}

	function Start() {
	   
	   tStart = new Date();	
	   document.temptationItemForm.theTime.value = "00:00";	   	
	   timerID  = setTimeout("UpdateTimer()", 1000);
	}

	function Stop() {
	
		if(timerID) {
			clearTimeout(timerID);
	      	timerID  = 0;
	   	}
	
	   tStart = null;
	}
	
	function Reset() {
	   
	   tStart = null;	
	   document.temptationItemForm.theTime.value = "00:00";
	}
