/*
Synopsis:
  Any anchor element that has its 'rel' attribute set to 'bookmark' will be modified. The modified links will incur a new bookmark function specific to the current user agent. A link with a 'href' attribute of '' or '#' will result in a bookmark function for the current page. The links 'href' attribute can also be used to bookmark a document other than the current page by setting ‘href’ to its URL.  The links title attribute can be used to prepend a string to the bookmark title (which by default is the page title or URL). If the current browser isn't supported the link is hidden using DHTML.
*/
window.onload = setBookmarkLinks;
function setBookmarkLinks()
{
  var bURL, bTitle;
  var links = document.getElementsByTagName('a');
  for (i=0; i<links.length; i++) { // Cycle through all links on page
    if (links[i].rel=='bookmark') { // Operate on the link if it has a 'rel' of 'bookmark'
      if (links[i].href == '' || links[i].href == window.location || links[i].href == '#' || links[i].href == window.location+'#') { // If destination anchor isn't set
				bURL = window.location;  // Set bookmark URL to current page URL
        bTitle = document.domain +' :: '+ document.title; // Set bookmark title to current page title
      } else bURL = bTitle = links[i].href; // Set bookmark URL and title to destination anchor
      if (links[i].title != '') bTitle = links[i].title+': '+bTitle; // Prepend link title to bookmark title if set
      // Branch for various browsers
      if (window.sidebar) { // Mozilla Firefox Bookmark
        links[i].href = "javascript:window.sidebar.addPanel('"+bTitle+"', '"+bURL+"','')";
      } else if( navigator.appName=="Netscape" ) { // Google Chrome
				links[i].href = "javascript:alert(\'Please click OK, then press <Ctrl-D> to bookmark this page.\');return false;";
			} else if( window.external ) { // IE Favorite
        links[i].href = "javascript:window.external.AddFavorite('"+bURL+"', '"+bTitle+"')";
      } else if(window.opera && window.print) { // Opera Hotlist
        links[i].rel = 'sidebar';
        links[i].title = bTitle;
      } else links[i].style.display = 'none';  // Hide link if unsupported browser
    }
  }
}