﻿var total = 60;

var Timer = function(){   

    this.Interval = 1000;
    this.Enable = new Boolean(false);
    this.TickEvent;
    var timerId = 0;
    var thisObject;

    this.Start = function(){
        this.Enable = new Boolean(true);

        thisObject = this;
		
        if (thisObject.Enable){
			
            thisObject.timerId = setInterval(
            function()
            {
                thisObject.TickEvent(); 
            }, thisObject.Interval);
        }
    };
    
    this.Stop = function(){            
        thisObject.Enable = new Boolean(false);
        clearInterval(thisObject.timerId);
		
    };
	
};

var fMyTimer = null;

function StartTimer(){
	
	fMyTimer = new Timer();
	fMyTimer.Interval = 1000;
	fMyTimer.TickEvent = Tick;
	fMyTimer.Start();
	
}


function Tick(){
	total = total - 1;
	
	if (total >= 1){
		document.getElementById("txtResult").value = total;	
		document.getElementById("divResult").innerHTML = total;
		
	} else {
		document.getElementById("test").style.display = "block";
		document.getElementById("txtResult").style.display = "none";
		document.getElementById("divResult").style.display = "none";
		document.getElementById("hideMe").style.display = "none";
		
	}
	
}