var n_hour=0;
var n_min=0;

function timestart(hh, mm)
{
 var time=new Date();
 m=time.getMinutes();
 h=time.getHours();
 n_hour=h-hh;
 n_min=m-mm;
}

function sow_time(el, diff, type)
{
  var time=new Date();
  m=time.getMinutes();
  h=time.getHours();
  s=time.getSeconds();
  m=m-n_min;
  if(m>=60)
  {
    m-=60;
    h++;
  }
  if(m<0)
  {
    h--;
    m+=60;
  }
  h=h-n_hour+diff;
  if(h>=24)
    h-=24;
  if(h<0)
    h+=24;
  sh=''+h;
  sm=''+m;
  if(h<10)
    sh='0'+h;
  if(m<10)
    sm='0'+m;
 if(type=='second')
 {
    document.getElementById(el).innerHTML = sh+":"+sm;
 }
 else
 {
   document.getElementById('h-1').src = "./img/num_"+sh.charAt(0)+".gif"; 
   document.getElementById('h-2').src = "./img/num_"+sh.charAt(1)+".gif"; 
   document.getElementById('m-1').src = "./img/num_"+sm.charAt(0)+".gif"; 
   document.getElementById('m-2').src = "./img/num_"+sm.charAt(1)+".gif"; 
 }
}

function fulltime (type)  
{
 if(type=='second')
 {
  sow_time('time_1', 0, type);
  sow_time('time_2', 1, type);
  sow_time('time_3', 0, type);
  sow_time('time_4', 1, type);
 }
 if(type=='front')
 {
  sow_time('time', 0, type);
 }
 setTimeout("fulltime('"+type+"')",1000) 
}
