// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function toggleExpandedCalendarDetails(node)
{
    // Get my parent calendarItem
    var calendarItem = node.parentNode.parentNode;

    // Get the expandedInfo for this calendarItem
    var children = calendarItem.getElementsByTagName('div');
    for (var i = 0; i < children.length; i++) {
        if (children[i].className == "expandedInfo") { expandedInfo = children[i]; }
    }

    // Toggle display
    if (expandedInfo.style.display != 'block') { expandedInfo.style.display = 'block'; }
    else { expandedInfo.style.display = 'none'; }
}

function bookmarkPub(url, title) {
  if (window.sidebar) { // firefox
    var modifier = (navigator.userAgent.toLowerCase().indexOf('mac') != -1) ? 'Cmd' : 'Ctrl';
    alert('Please press ' + modifier + ' + D to bookmark this publication.');
    // This command will add the bookmark, but when it is used the page appears in the sidebar
    //window.sidebar.addPanel(title, url, "");
  }
  else if (window.opera && window.print) { // opera
    var elem = document.createElement('a');
    elem.setAttribute('href', url);
    elem.setAttribute('title', title);
    elem.setAttribute('rel', 'sidebar');
    elem.click();
  }
  else if (window.external) { // IE
    window.external.AddFavorite(url, title);
  }
  else {
    alert("Sorry! Your browser won't allow us to bookmark #{@current_publication.name}, so you will need to do it manually."); 
  }
}
