//var sec = 10;   // set the seconds
//var min = 01;   // set the minutes

function SetCountdownText(seconds) {

	//store:
	_currentSeconds = seconds;
	
	//get minutes:
	var minutes=parseInt(seconds/60);
	
	//shrink:
	seconds = (seconds%60);
	
	//get hours:
	var hours=parseInt(minutes/60);
	
	//shrink:
	minutes = (minutes%60);
	
	//build text:
	return strText = AddZero(hours) + ":" + AddZero(minutes) + ":" + AddZero(seconds);
	
	//apply:
	
}

function AddZero(num) {
	return ((num >= 0)&&(num < 10))?"0"+num:num+"";
}



function countDown(sec,gid) { 
  sec--;
  
if (document.getElementById) { document.getElementById(gid).innerHTML = SetCountdownText(sec) }
  SD=window.setTimeout("countDown("+sec+",'"+gid+"');", 1000);
if ( sec == '00') { sec = "00"; window.clearTimeout(SD); }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
