﻿var LogoSPEED = 5;
var LogoTIMER = 30;

// On Click Mouse //
function LogoopenMenu(controlID,flag)
{
  var body = document.getElementById(controlID + '-tabcontent');
  
  clearInterval(body.timer);
  
  var title = document.getElementById(controlID + '-tabheader');
 
  if(flag == 1)
  {
    if(body.status=="expand")
    {
        LogoopenMenu(controlID,-1);
        return;
    }
    clearTimeout(title.timer);
    if(body.maxw && body.maxw <= body.offsetWidth){return}
    else if(!body.maxw)
    {
      body.style.display = 'block';     
      body.style.width = 'auto';
      body.maxw = body.offsetWidth;
      body.style.width = '0px';
     
    }
    body.status="expand";
    body.timer = setInterval(function(){LogoMenuSlide(body,1)},LogoTIMER);
  }
  
  else
  {
    body.status="collapse";
    title.timer = setTimeout(function(){LogoMenuCollapse(body)},50);
  }
  
}

// Close Menu //
function LogoMenuCollapse(body)
{
  body.timer = setInterval(function(){LogoMenuSlide(body,-1)},LogoTIMER);
}

// Close on Mouse Over //
function LogocancelHide(controlID)
{
   var title = document.getElementById(controlID + '-tabheader');
clearTimeout(title.timer);
 
  var body = document.getElementById(controlID + '-tabcontent');
   clearInterval(body.timer);  
  if(body.offsetWidth < body.maxw)
  {
    body.timer = setInterval(function(){LogoMenuSlide(body,1)},LogoTIMER); 
  }
}

// Contract/Expand menu incrementally also change opacity //
function LogoMenuSlide(body,flag)
{
  var currh = body.offsetWidth;
  var length;
  if(flag == 1)
  {
    length = (Math.round((body.maxw - currh) / LogoSPEED));
  }
  else
  {
    length = (Math.round(currh / LogoSPEED));
  }
  if(length <= 1 && flag == 1){
    length = 1;
  }
  body.style.width = currh + (length * flag) + 'px';
  if((currh < 9 && flag != 1) || (currh > (body.maxw - 2) && flag == 1))
  {
      if(flag==-1)
      {
          body.style.width=0;
      }
    clearInterval(body.timer);
  }
}
    