/********************************************************
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 * 
 * CodeHouse.com JavaScript Library Module: Save Link Method
 *
 * You can obtain this script at http://www.codehouse.com
 ********************************************************/
function CJL_saveLink(anchorId, linkTitle, url, bookmarkText, tabText)
{
   function set(innerHTML, href)
   {
      elem = document.getElementById(anchorId);

      elem.innerHTML = innerHTML;

      elem.href = "javascript:" + href;
   }

   function quote(s)
   {
      return "'" + s + "'";
   }


   url = quote(url ? url : location.href);
   linkTitle = quote(linkTitle ? linkTitle : document.title);

   if( window.external &&  /Win/.test(navigator.userAgent) )
   {
      set(
          bookmarkText ? bookmarkText : "Bookmark Page",
          "external.AddFavorite(" + url + "," + linkTitle + ")"
         );
   }
   else if( window.sidebar && sidebar.addPanel )
   {
      set(
          tabText ? tabText : "Add to Sidebar",
          "sidebar.addPanel(" + linkTitle + "," + url + ",'')"
         );
   }
}