function writeGMT()
{
  s=self.location.search;
  s2=s.substring(0,1);
  if (s2 == "?")
  {
     i=s.indexOf("?");
     s1=s.substring(1,3);
     document.TimeSelect.GMTSelect.selectedIndex=parseInt(s1,10);
  }
  else
  {
     now=new Date();
     document.TimeSelect.GMTSelect.selectedIndex=12-(now.getTimezoneOffset()/60);
     if (parent.GMT != null) 
        document.TimeSelect.GMTSelect.selectedIndex=12-parent.GMT; 
   }
}

function updateTime()
{
  parent.GMT=12-document.TimeSelect.GMTSelect.selectedIndex;
  location.replace(self.location.protocol+"//"+self.location.host+self.location.pathname+"?"+document.TimeSelect.GMTSelect.selectedIndex);
}

function parseDate(s,n)
{
  var day=s.substring(0,2);
  var month=s.substring(3,5);
  var year=s.substring(6,10);
  var hour=s.substring(11,13);
  var minute=s.substring(14,16);
  TempDate=new Date(year,(month-1),(day),(hour),(minute),0);
  TempDate1=new Date(TempDate.getTime()+(n*3600000));
  minute=TempDate1.getMinutes();
  hour=TempDate1.getHours();
  day=TempDate1.getDate();
  month=TempDate1.getMonth()+1;
  year=TempDate1.getYear();
  if (day<10)
     day="0"+day;
  if (month<10)
     month="0"+month;
  if (year<1000)
     year+= 1900;
  z=new String(year);
  year1=z.substring(2,4);
  if (minute<10)
     minute="0"+minute;
  if (hour<10)
     hour="0"+hour;
  return("["+day+"."+month+"."+year1+" "+hour+":"+minute+"]&nbsp;");
}
  
function wt(s)
{
  document.write(parseDate(s,(document.TimeSelect.GMTSelect.selectedIndex-12)));
}

function wr(s)
{
  t1=0;
  t2=s.indexOf("|",t1);
  s01=parseTime(s.substring(t1,t2),(document.TimeSelect.GMTSelect.selectedIndex-12));
  if (cr == 1)
  {
    document.write(rb1+cb1+s01+ce);
    cr=0;
  }
  else
  {
    document.write(rb2+cb1+s01+ce);
    cr=1;
  }
  t1=t2+1;
  t2=s.indexOf("|",t1);
  z=s.substring(t1,s.length);
  document.write(cb1+z+ce);
}

function we(s)
{
  t1=0;
  t2=s.indexOf("|",t1);
  for(i=1; i<3; i++)
  {
      t2=s.indexOf("|",t1);
      z=s.substring(t1,t2);
      t1=t2+1;
      document.write(cb2+z+ce);
  }
  z=s.substring(t1,s.length);
  document.write(cb2+z+ce+re);
}

function parseTime(s,n)
{
  var day=parseInt(s.substring(0,2),10);
  var month=parseInt(s.substring(3,5),10);
  var year=parseInt(s.substring(6,10),10);
  var hour=parseInt(s.substring(11,13),10);
  var minute=parseInt(s.substring(14,16),10);
  if (!isNaN(hour))
  {
     TempDate=new Date(year,(month-1),(day),(hour),(minute),0);
     TempDate1=new Date(TempDate.getTime()+(n*3600000));
     hour=TempDate1.getHours();
     minute=TempDate1.getMinutes();
     day=TempDate1.getDate();
     month=TempDate1.getMonth()+1;
     year=TempDate1.getYear();         
  }
  if (day<10)
     day="0"+day;
  if (month<10)
      month="0"+month;
  if (year<1000)
      year+= 1900;
  if (minute<10)
      minute="0"+minute;
  if (hour<10)
      hour="0"+hour;
  if (day!=timeNow)
  {
      writeHeader(day,month,year);
      timeNow=day;
   }
   if (isNaN(hour))
       return("&nbsp");
   else
   return(hour+":"+minute);
}

function writeHeader(x,y,z)
{
  Time=new Date(z,y-1,x);
  n=Time.getDay()
  s1=new String();
  if (n==0)
     s1="Воскресенье ";
  if (n==1)
     s1="Понедельник ";
  if (n==2)
     s1="Вторник ";
  if (n==3)
     s1="Среда ";
  if (n==4)
     s1="Четверг ";
  if (n == 5)
     s1="Пятница ";
  if (n==6)
     s1="Суббота ";
  document.write(line);
  document.write(lb+s1+x+"."+y+"."+z+le);
  document.write(line);
  cr=1;
}

function ref(n,m,l)
{
  if(n!=1)
     self.location.reload(true);
  else
     CheckForObject(m,l);
  timerId = setTimeout("ref(0,0,0)",900000);
}

