var MenuSpeed = 3;
var MenuTimer = 25;


function openMenu(control,flag)
{
  var body = document.getElementById(control + '-tabcontent');
  
  clearInterval(body.timer);
 
  var title = document.getElementById(control + '-tabheader');
 
  if(flag == 1)
  {
    title.style.background='url(/images/sel_menuitem.jpg)';
    clearTimeout(title.timer);
    if(body.maxh && body.maxh <= body.offsetHeight){return}
    else if(!body.maxh)
    {
      body.style.display = 'block';     
      body.style.height = 'auto';
      body.maxh = body.offsetHeight;
      body.style.height = '0px';
     
    }
     body.timer = setInterval(function(){MenuSlide(body,1)},MenuTimer);
  }
  
  else if(flag==-1)
  {    

    title.timer = setTimeout(function(){MenuCollapse(body)},50);
  }
  
}
function SetBgImage(title)
{
    title.style.background='url(/images/sel_menuitem.jpg)';
}

function MenuCollapse(body)
{
   document.getElementById(body.id.substr(0,body.id.indexOf('-',0))+"-tabheader").style.background='url(/images/bg.png)';

  body.timer = setInterval(function(){MenuSlide(body,-1)},MenuTimer);
}


function cancelHide(control)
{
  var title = document.getElementById(control + '-tabheader');
  clearTimeout(title.timer);
  var body = document.getElementById(control + '-tabcontent');
  clearInterval(body.timer);  
  if(body.offsetHeight < body.maxh)
  {
    body.timer = setInterval(function(){MenuSlide(body,1)},MenuTimer); 
   
  }
   title.style.background='url(/images/sel_menuitem.jpg)';   
}


function MenuSlide(c,d)
{
  var currenttitle = c.offsetHeight;
  var length;
  if(d == 1)
  {
    length = (Math.round((c.maxh - currenttitle) / MenuSpeed));
    
  }
  else
  {
    length = (Math.round(currenttitle / MenuSpeed));
  }
  if(length <= 1 && d == 1){
    length = 1;
  }
  c.style.height = currenttitle + (length * d) + 'px';
//  c.style.opacity = currenttitle / c.maxh;
if((currenttitle * 100 / c.maxh)<95)
{
  c.style.filter = 'alpha(opacity=' + (currenttitle * 100 / c.maxh) + ')';
  }
  if((currenttitle < 8 && d != 1) || (currenttitle > (c.maxh - 2) && d == 1))
  {     
      if(d==-1)
      {
//          document.getElementById(c.id.substr(0,c.id.indexOf('-',0))+"-tabheader").style.background='url(/images/bg.png)';
          c.style.height=0;
      }    
      clearInterval(c.timer);
  }
}

function ShowBody(control,contentId)
{
    switch(control)
    {
      case("AboutUs"):  document.getElementById("LiNTP").InnerText="Here you will find<br />"
                                                                                             +"information about<br />"
                                                                                             +"the company.Its"
                                                                                             +"<br />"
                                                                                             +"services,mission<br />"
                                                                                             +"and vision statements.";
        break;                                                      
     }
}