// Popup function, taken from http://www.htmlcodetutorial.com/linking/linking_famsupp_72.html
function popup(mylink, windowname)
{
  if (! window.focus)return true;
  var href;
  if (typeof(mylink) == 'string')
     href=mylink;
  else
     href=mylink.href;
  // Append the referer in the qs, as IE doesn't include it in the HTTP request for a
  // window.open
  if (/\?/.exec(href)) {
    href = href + '&referer=' + window.location.href
  } else {
    href = href + '?referer=' + window.location.href
  }
  window.open(href, windowname, 'width=700,height=500,scrollbars=yes,resizable=yes');
  return false;
}

// Hides a sidebar_block if necessary.
function hide_sidebar_block(element) {
  parent_id = jQuery(element).attr('id');
  if (sidebar_prefs.data[parent_id] == null)
  {
    jQuery('#' + parent_id + ' .sidebarcontent').hide();
    jQuery('#' + parent_id + ' .sidebarheader').toggleClass('sidebarheaderclosed');
  }
}