﻿/*

  (c) 2007 Interphace Ltd

*/


/*
  Function: addBookmark(title, url)
  
  Args: are optional, will use document title & url if not supplied
  
  Works in IE 4+, Firefox 1.0+, Opera (unknown versions)
  
*/
function addBookmark(title, url) {

  if (!title) {
    title = document.title
  }
    
  if (!url) {
    url = window.location;  
  }

  if (window.sidebar) {
    window.sidebar.addPanel(title, url, "");
  } else if (window.external) {
    window.external.AddFavorite(url, title);
  } else if (window.opera && window.print) {
    // Opera uses the rel="sidebar" attribute on anchors to 
    // add bookmarks programmatically
  
    var anchor = document.createElement('a');
    anchor.setAttribute('rel','sidebar');
    anchor.setAttribute('href',url);
    anchor.setAttribute('title',title);

    anchor.click();
  } else { // unsupported browser  
    alert("You must manually add this page to your favourites/bookmarks by pressing ctrl-D or ctrl-T");
  }
  
  window.event.returnValue = false;
  return false;  
}

/*
  Function: printPage
  
  Works in IE 4+, Firefox 1.0+, Opera (unknown versions)
  
*/
function printPage() {

  if (window.print) {
    window.print();  
  }
  
  window.event.returnValue = false;
  return false;
}
