var compFade_interval = new Array(4);
var compFade_interval2 = new Array(4);
var compFade_increment = new Array(4);

compFade_interval['menu01'] = null;
compFade_interval['menu02'] = null;
compFade_interval['menu03'] = null;
compFade_interval['menu04'] = null;

compFade_interval2['menu01'] = null;
compFade_interval2['menu02'] = null;
compFade_interval2['menu03'] = null;
compFade_interval2['menu04'] = null;

compFade_increment['menu01'] = 0;
compFade_increment['menu02'] = 0;
compFade_increment['menu03'] = 0;
compFade_increment['menu04'] = 0;

function compFade_clear(id) {
 disable_events = 0;
 if(compFade_interval[id]) {
  clearInterval(compFade_interval[id]);
  compFade_interval[id] = null;
 }
 if(compFade_interval2[id]) {
  clearInterval(compFade_interval2[id]);
  compFade_interval2[id] = null;
 }
}

function compFade_go_left(id) {
 Right = document.getElementById(id);
 if (Right.style.display == 'block'){
  return false;
 }
 var string = "compFadeLeft('"+id+"')";
 if(compFade_interval[id] == null) {
  disable_events = 1;
  setOpacity(Right,0);
  Right.style.display = 'block';
  compFade_interval[id] = setInterval(string, 50);
 }
}

function compFadeLeft(id) {
 Right = document.getElementById(id);
 var string = "check_compFade_pos('"+id+"')";
 if(compFade_increment[id] >= 4) {
  compFade_clear(id);
  compFade_interval2[id] = setInterval(string, 50);
 }
 else {
  compFade_increment[id]++;
  setOpacity(Right, compFade_increment[id] * 25 );
 }
}

function compFadeRight(id) {
 Right = document.getElementById(id);

 if(compFade_increment[id] <= 0) {
  compFade_clear(id);
  Right = document.getElementById(id);
  Right.style.display = 'none';
 }
 else {
  compFade_increment[id]--;
  setOpacity(Right, compFade_increment[id] * 25 );
 }
}

function check_compFade_pos(id) {
 Left = document.getElementById(id);
 var ulHeight = 0;  
 for(i = 0; i < Left.childNodes.length; i++) {
  ulHeight += Left.childNodes[i].offsetHeight;
 }
 var sf = Left.childNodes[i-1].offsetTop + ulHeight + 15;
 pos = getPos(Left);
// if( (mouseX < Left.offsetLeft) || (mouseX > (Left.offsetLeft + Left.offsetWidth)) || 
//     (mouseY > (Left.childNodes[i-1].offsetTop + ulHeight + 15)) ) {
 if( (mouseX < pos.left) || (mouseX > (pos.left + Left.offsetWidth)) || 
     (mouseY > (pos.top + ulHeight)) ) {
  compFade_clear(id);
  var string = "compFadeRight('"+id+"')";
  compFade_interval[id] = setInterval(string, 50);
 }
}
