var id, this_color
var blink_thread_var1  = 0
var blink_thread_var2  = true
var blink_thread_color = '#000000 #202020 #404040 #606060 #808080 #a0a0a0'
var doc=document

function stop_thread(thread_id)
{ clearTimeout(thread_id); 
}

function ObjDate()
{ var dt=new Date();
  this.listMonth = 'Januari Februari Maret April Mei Juni Juli Agustus September Oktober November Desember'
  this.listDay   = 'Minggu Senin Selasa Rabu Kamis Jumat Sabtu'
  var maxDay     = '31 28 31 30 31 30 31 31 30 31 30 31'
  var tm         = 'malam sore siang pagi'
  this.listMonth = this.listMonth.split(' ')
  this.listDay   = this.listDay.split(' ')
  maxDay         = maxDay.split(' ')
  tm             = tm.split(' ')
  this.H         = dt.getHours()
  this.m         = dt.getMinutes()
  this.s         = dt.getSeconds()
  this.d         = dt.getDate()
  this.D         = dt.getDay()
  this.M         = dt.getMonth()
  this.yyy       = dt.getYear()
  this.yyyy      = dt.getYear()
  this.HH        = (dt.getHours()<10 ? '0':'')+dt.getHours()
  this.mm        = (dt.getMinutes()<10 ? '0':'')+dt.getMinutes()
  this.ss        = (dt.getSeconds()<10 ? '0':'')+dt.getSeconds()
  this.dd        = (dt.getDate()<10 ? '0':'')+dt.getDate()
  this.ddd       = this.listDay[dt.getDay()]
  this.dddd      = this.listDay[dt.getDay()]
  this.MM        = (dt.getMonth()<10 ? '0':'')+dt.getMonth()
  this.MMM       = (this.listMonth[dt.getMonth()]).substr(0,3)
  this.MMMM      = this.listMonth[dt.getMonth()]
  this.y         = (((dt.getYear()).toString()).substr(2,1)=='0' ? 
                   ((dt.getYear()).toString()).substr(3) : ((dt.getYear()).toString()).substr(2))
  this.yy        = ((dt.getYear()).toString()).substr(2)
  this.maxDay    = maxDay[dt.getMonth()]
  if (dt.getMonth()=='1' && (dt.getYear() % 4)==0) this.maxDay++
  if (this.yy<10) this.yy = '0' + this.yy
  this.time      = this.H>18 ? tm[0] : this.H>14 ? tm[1] : this.H>10 ? tm[2] :
                   this.H>3 ? tm[3] : tm[0]
}

function run_clock(id_name)
{ if (id_name==null || id_name=='') return null
  var dt=new ObjDate()
  for (i=0;i<document.all.length; i++)
  if (document.all.item(i).id==id_name)
  { document.all.item(i).innerHTML = dt.dd+' '+dt.MMM+' '+dt.yy+'/ '+
                                     dt.HH+":"+dt.mm+":"+dt.ss
    break
  }
  clock_thread = setTimeout('run_clock(\''+id_name+'\')', 1000);
}

function run_blink(id_name, text, color, counter)
{ var i, tmp
  if (id_name==null || id_name=='') return null
  if (text==null || text=='') return null
  if (color==null || color=='')
     color = blink_thread_color
  colors = color.split2(' ')
  colors = colors.concat(colors.reverse())
  if (counter==null || counter=='' || counter<0 || counter>=colors.length)
    counter = 0
  for (i=0;i<document.all.length; i++)
  if (document.all.item(i).id==id_name)
  { document.all.item(i).innerHTML = '<font color="' + colors[counter] +
                                     '">' + text + '</font>'
    //document.all.item(i).innerHTML = colors[counter] + text + counter
    break
  }
  counter ++;
  blink_thread = setTimeout('run_blink(\'' + id_name + '\', \'' + text + '\', \'' +
                            color + '\', \'' + counter + '\')', 100);
}

String.prototype.trim = function()
{ return this.replace(/(^\s*)|(\s*$)/g, '');
}

String.prototype.fixSpace = function()
{ return (this.trim()).replace(/(\s)+/g, ' ')
}

String.prototype.split2 = function(sparator)
{ var str = this.fixSpace()
  return str.indexOf(' ')>0 ? str.split(sparator) : new Array(str)
}

function tag_attr(id, align, top, left, width, height, border, src, className, 
                    additionalObject, position, display, padding)
{ var txt   = new String()
  var tmp   = new Array()
  var list = 'align top left width height border src className position display padding'.split(' ')
  var block = 'doc.all.' + id + (additionalObject!='' && additionalObject!=null ? 
           '.'+additionalObject : '')
  for (i=0; i<list.length; i++)
  { if (eval(list[i])!='' && eval(list[i])!=null || eval(list[i])=='0')
    { txt = list[i] + '=\'' + eval(list[i]) + '\''
      //document.write(block+'.'+txt + '<br>\n')
      eval(block+'.'+txt)
      tmp[tmp.length] = txt
    }
    
  }
  //document.writeln(block+'->'+tmp.join(' ')+'<br>\n')
}
