﻿var MJ_tmr;
var MJ_TargetHeight;
var MJ_Action=false;
var MJ_IsVisible=false;
var MJ_XRatio;

function MJ_ShowList()
{
  MJ_Action=true;
  MJ_TargetHeight=0;
  var recentList=document.getElementById(MJ_ID+"RecentVacanciesSection");
  if(recentList){
    var linkCount=recentList.getElementsByTagName("a").length;
    if(linkCount>5){
      linkCount=5;
    }
    MJ_TargetHeight=linkCount*18+25;
  }
  var shortList=document.getElementById(MJ_ID+"ShortlistVacanciesSection");
  if(shortList){
    var linkCount=shortList.getElementsByTagName("a").length;
    if(linkCount>5){
      linkCount=5;
    }
    MJ_TargetHeight=MJ_TargetHeight+linkCount*18+25;
  }
  MJ_XRatio=230*35/MJ_TargetHeight;
  var dropDown=document.getElementById("DropDown");
  dropDown.style.height="1px";
  dropDown.style.width="1px";
  dropDown.style.display="block";
  MJ_tmr=window.setInterval(MJ_Expand,50);
}

function MJ_Expand()
{
  window.clearInterval(MJ_tmr);
  MJ_tmr=null;
  
  var dropDown=document.getElementById("DropDown"); 
  var incrY=dropDown.offsetHeight+35;
  if(incrY>MJ_TargetHeight){
    incrY=MJ_TargetHeight;
  }
  var incrX=dropDown.offsetWidth+MJ_XRatio;
  if(incrX>230){
    incrX=230;
  }
  dropDown.style.width=incrX+"px";
  dropDown.style.height=incrY+"px";
  if(incrY<MJ_TargetHeight||incrX<230)
  {
    MJ_tmr=window.setInterval(MJ_Expand,50);
  }
  else
  {
    dropDown.style.height="auto";
    MJ_IsVisible=true;
    MJ_Action=false;
  }
}

function MJ_Hide()
{
  MJ_Action=true;
  document.getElementById("DropDown").style.display="none";
  MJ_IsVisible=false;
  MJ_Action=false;  
}