//these variables allow multiple functions to be dynamically added/removed
//from document mouse events

var docOnclickIndex = 0;
var afDocOnclicks = []; //array of functions to execute when document.onclick
document.onclick = function(event) {
  for(var i=0; i<afDocOnclicks.length; i++){
    if(typeof afDocOnclicks[i] != "undefined")
      afDocOnclicks[i].dofunc(event);
  }
};

var docOnmouseupIndex = 0;
var afDocOnmouseups = []; // array of functions to execute when document.onmouseup
document.onmouseup = function(event) {
  for(i=0; i<afDocOnmouseups.length; i++){
    if(typeof afDocOnmouseups[i] != "undefined")
     afDocOnmouseups[i].dofunc(event);
  }
};

var docOnmousedownIndex = 0;
var afDocOnmousedowns = [];
document.onmousedown = function(event) {
  for(i=0; i<afDocOnmousedowns.length; i++){
    if(typeof afDocOnmousedowns[i] != "undefined")
      afDocOnmousedowns[i].dofunc(event);
  }
};

var docOnmousemoveIndex = 0;
var afDocOnmousemoves = [];
document.onmousemove = function(event) {
  for(i=0; i<afDocOnmousemoves.length; i++){
    if(typeof afDocOnmousemoves[i] != "undefined")
      afDocOnmousemoves[i].dofunc(event);
  }
};


