
var secs
var timerID = null
var timerRunning = false
var delay = 750
var colore1 = "#cc0000"
var colore2 = "#cccccc"
var colore3 = "#E9EAEC"
var colore4 = "#000B6F"

var resto
var id
var obj_type



//function fColor(colore)
function fColor(arg_resto)
	{ 
	
        if (arg_resto==0) {      
           document.getElementById(id).style.borderBottomColor=colore1;
	         document.getElementById(id).style.borderLeftColor=colore1;   
        }   
       else {
        document.getElementById(id).style.borderBottomColor=colore2;
	      document.getElementById(id).style.borderLeftColor=colore3;
       } 

	//document.getElementById(id).style.backgroundColor=colore;
	//document.getElementById(id).style.borderColor=colore;
	
	//document.getElementById(id).style.borderBottomColor=colore;

	//document.getElementById(id).style.borderLeftColor=colore;
	} 
	
	function fColor2(arg_resto)
	{ 
	      
        if (arg_resto==0) {      
           document.getElementById(id).style.color=colore1;
        }   
       else {
        document.getElementById(id).style.color=colore4;
       } 

	} 

function InitializeId(id1, obj_type1)
{
    // Set the length of the timer, in seconds
    id = id1
    obj_type = obj_type1

}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 40
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{

    
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("ciao")
    }
    else
    {
        // SPecificare cosa fare ad ogni "delay"
        //self.status = secs
        resto = secs % 2
        if (obj_type == 'td')
            fColor(resto)
        if (obj_type == 'a')
           fColor2(resto)        
//        if (resto==0) {      
//           fColor(colore1)   
//        }   
//       else {
//        fColor(colore2)
//       }
          
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}




