var MovingSPEED = 5;
var MovingTIMER = 30;

// Here we handling of mouse //
function SideddMenu(control,digit)
{
  var header = document.getElementById(control + '-ddheader');
  var content = document.getElementById(control + '-ddcontent');
  //alert(control);
  //alert(digit);
  clearInterval(content.timer);
  if(digit == 1)
  {
    if(content.status=="expand")
    {
        SideddMenu(control,-1);
        return;
    }
    SideSelectPane(control);
    clearTimeout(header.timer);
    if(content.maxh && content.maxh <= content.offsetHeight){return}
    else if(!content.maxh)
    {
      content.style.display = 'block';     
      content.style.height = 'auto';
      content.maxh = content.offsetHeight;
      content.style.height = '0px';
     
    }
    content.status="expand";
    content.timer = setInterval(function(){SideddSlide(content,1)},MovingTIMER);
  }
  
  else
  {
    content.status="collapse";
    header.timer = setTimeout(function(){SideddCollapse(content)},50);
  }
  
}

// collapse the menu //
function SideddCollapse(content)
{
  content.timer = setInterval(function(){SideddSlide(content,-1)},MovingTIMER);
}

// cancel the collapse if a user rolls over the dropdown //
function SidecancelHide(control)
{
  var header = document.getElementById(control + '-ddheader');
  var content = document.getElementById(control + '-ddcontent');
  clearTimeout(header.timer);
  clearInterval(content.timer);  
  if(content.offsetHeight < content.maxh)
  {
    content.timer = setInterval(function(){SideddSlide(content,1)},MovingTIMER); 
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function SideddSlide(content,digit)
{
  var currh = content.offsetHeight;
  var dist;
  if(digit == 1)
  {
    dist = (Math.round((content.maxh - currh) / MovingSPEED));
  }
  else
  {
    dist = (Math.round(currh / MovingSPEED));
  }
  if(dist <= 1 && digit == 1){
    dist = 1;
  }
  content.style.height = currh + (dist * digit) + 'px';
  if((currh < 5 && digit != 1) || (currh > (content.maxh - 2) && digit == 1))
  {
      if(digit==-1)
      {
          content.style.height=0;
          
          //SideClosePane(content.control.substr(0,content.control.indexOf('-',0)));
      }
    clearInterval(content.timer);
  }
}

function SideSelectPane(content)
{
}
    
function SideClosePane(content)
{
}