function picClick(num){
  cell=document.getElementById('cell'+num);
  input=document.getElementById('id'+num);
  check=document.getElementById('check'+num);
  if(input.value!=num){
    cell.style.background="#EAEAEA";
    input.value=num;
    check.style.display='none';
  } else {
    cell.style.background="#6CFF7E";
    input.value='';
    check.style.display='block';
  }
}
function setStatus(num){
  cell=document.getElementById('cell'+num);
  input=document.getElementById('id'+num);
  check=document.getElementById('check'+num);
  if(input.value==num){
    cell.style.background="#EAEAEA";
    check.style.display='none';
  } else {
    cell.style.background="#6CFF7E";
    check.style.display='block';
  }
}
function hideinfo(){
  document.getElementById('infobox').style.display='none';
}
function picInfo(id){
  hideinfo();
  document.getElementById('infopic').src='/img/spacer.gif';
  document.getElementById('jsframe').src='/fetch.js?id='+id;
  document.getElementById('infobox').style.display='block';
}
var DragHandler = {

    // private property.
    _bar : null,
    _box : null,


    // public method. Attach drag handler to an element.
    attach : function(barId) {
        var bar=document.getElementById(barId);
        bar.onmousedown = DragHandler._dragBegin;

        // callbacks
        bar.dragBegin = new Function();
        bar.drag = new Function();
        bar.dragEnd = new Function();

        return bar;
    },


    // private method. Begin drag process.
    _dragBegin : function(e) {
        var bar = DragHandler._bar = this;
        var box = DragHandler._box = document.getElementById(this.className);

        if (isNaN(parseInt(box.style.left))) { box.style.left = '0px'; }
        if (isNaN(parseInt(box.style.top))) { box.style.top = '0px'; }

        var x = parseInt(box.style.left);
        var y = parseInt(box.style.top);

        e = e ? e : window.event;
        box.mouseX = e.clientX;
        box.mouseY = e.clientY;

        bar.dragBegin(bar, x, y);

        document.onmousemove = DragHandler._drag;
        document.onmouseup = DragHandler._dragEnd;
        return false;
    },


    // private method. Drag (move) element.
    _drag : function(e) {
        var bar = DragHandler._bar;
        var box = DragHandler._box;
/*        alert(box);
        document.onmousemove = null;*/

        var x = parseInt(box.style.left);
        var y = parseInt(box.style.top);

        e = e ? e : window.event;
        box.style.left = x + (e.clientX - box.mouseX) + 'px';
        box.style.top = y + (e.clientY - box.mouseY) + 'px';

        box.mouseX = e.clientX;
        box.mouseY = e.clientY;

        bar.drag(bar, x, y);

        return false;
    },


    // private method. Stop drag process.
    _dragEnd : function() {
        var bar = DragHandler._bar;
        var box = DragHandler._box;

        var x = parseInt(box.style.left);
        var y = parseInt(box.style.top);

        bar.dragEnd(bar, x, y);

        document.onmousemove = null;
        document.onmouseup = null;
        DragHandler._bar = null;
    }

}
