/* see: http://www.quirksmode.org/ */
var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name) {
  if (document.getElementById) {
    this.obj = document.getElementById(name);
    this.style = document.getElementById(name).style;
  } else if (document.all) {
    this.obj = document.all[name];
    this.style = document.all[name].style;
  } else if (document.layers) {
    this.obj = document.layers[name];
    this.style = document.layers[name];
  }
}

// hide/show divs
function hideLayer(id){
  if (!DHTML) return;
  var x = new getObj(id);
  x.style.visibility="hidden";
}
function showLayer(id) {
  if (!DHTML) return;
  var x = new getObj(id);
  x.style.visibility="visible";
}
function toggleVisibility(id) {
  if (!DHTML) return;
  var x = new getObj(id);
  if ( x.style.visibility != "visible" ) {
    x.style.visibility="visible";
  } else {
    x.style.visibility="hidden";
  }
}

// manipulate the size of boxes
function changeHeight(id,num) {
  if (!DHTML) return;
  var o = new getObj(id);
  var y = o.style.height.split('px');
  var ny = eval(y[0]) + num;
  o.style.height = ny;
}
function changeWidth(id,num) {
  if (!DHTML) return;
  var o = new getObj(id);
  var x = o.style.width.split('px');
  var nx = eval(x[0]) + num;
  o.style.width = nx;
}

/* multiclock script */
speed = 60000;
len = 14;
tid = 0;
num = 0;
clockA = new Array();
offsetA = new Array();
dd = new Date();
/**
 * Function to pad the time values with leading 0 if less than 10.
 */
function formatTime(time) {
  if (time < 10) {
    time = "0" + time;
  }
  return time;
}
function doDate(){
  for (i=0; i<num; i++) {
    dt = new Date();  
    if (offsetA[i] != 0) {
      gt = dt.getTime();
      gt = gt + offsetA[i];
      dt.setTime(gt);
    }
   clockA[i].date.value = (dt.getMonth()+1) + "/" + dt.getDate() +" "+ formatTime(dt.getHours()) + ":" + formatTime(dt.getMinutes());
  }
  tid=window.setTimeout("doDate()",speed);
}
function startLong(diff) {
  clockA[num] = document.forms[num];
  offsetA[num] = (dd.getTimezoneOffset() + diff)*60*1000;
  if (num == 0)  
    tid=window.setTimeout("doDate()",0);
  num++;
}
function cleartid() {
  window.clearTimeout(tid);
}
/* FIXME: don't really need each input in own form.*/
function ServerClock(diff){
  document.write('<FORM name="form'+num+'"><input name="date" size="');
  document.write(len);
  document.write('" value="javascript clock" /><\/FORM>');
  startLong(diff);
}
/* end multiclock */
