var _selectedLinkID = null;
var _openHeight = null;
var _closedHeight = null;

$jQuery(document).ready(function()
  {
    _closedHeight = $jQuery("#TopMenuBar").height();
    $jQuery("#TopMenuBar").height(_closedHeight);
    _openHeight = $jQuery("#TopMenuBar li:first").height() + $jQuery("#TopMenuBar").height() + 10;
  }
)

///Open the drop down menu
function toggleMenu(linkID, path) {
  if (_selectedLinkID != null)
    $jQuery("#" + _selectedLinkID).removeClass("TopMenuSelected");

  if ($jQuery("#TopMenu").hasClass("TopMenuClosed")) {
    $jQuery("#TopMenu").addClass("TopMenuOpen");
    $jQuery("#TopMenu").removeClass("TopMenuClosed");
    //$jQuery(".TopMenuSubContainer *").hide();
    $jQuery("#TopMenuBar").animate({height: _openHeight + "px"}, "fast", "linear", openCallBack);
    _selectedLinkID = linkID;

    //Register the menu click with Google Analytics
    trackClick("/topmenu/open" + path);
  }
  else {
    if (linkID == _selectedLinkID) {
      $jQuery("#TopMenuBar").animate({ height: _closedHeight + "px" }, "fast", "linear", animateCallBack);
      _selectedLinkID = null;
      trackClick("/topmenu/close" + path);
    }
    else {
      _selectedLinkID = linkID;
      //Register the menu click with Google Analytics
      trackClick("/topmenu/change" + path);
    }
  }

  if (_selectedLinkID != null)
    $jQuery("#" + _selectedLinkID).addClass("TopMenuSelected");
}

function animateCallBack() {
  $jQuery("#TopMenu").addClass("TopMenuClosed");
  $jQuery("#TopMenu").removeClass("TopMenuOpen");
}

function openCallBack() {
  //$jQuery(".TopMenuSubContainer *").fadeIn("fast");
}

//===============================
/* For preview start */
//===============================
var httpRequest = null;
 
function menuPreview(ID)
{

}

function goToSupport() {
  window.open("http://support.pentia.dk");
}
