// based on http://javascript.about.com/library/blufav.htm

function add_to_favourites() {
    var link = document.createElement('a');
    var text = document.createTextNode('[Add to favourites]');
    link.className='logout-link';
    link.setAttribute('href', '#');
    link.appendChild(text);
    var s = document.getElementById('add_to_favourites');
    if (window.sidebar) {
        s.appendChild(link);
        s.onclick = function() {
            window.sidebar.addPanel(document.title,self.location,'')
        };
    } else if (window.external) {
        s.appendChild(link);
        s.onclick = function() {
            window.external.AddFavorite(self.location,document.title)
        };
    } else if (window.opera) {
        s.appendChild(link);
        s.onclick = function() {
             var e = document.createElement('a');
             e.setAttribute('href',self.location);
             e.setAttribute('title',document.title);
             e.setAttribute('rel','sidebar');
             e.click();
        }
    }
}

var pageLoaded = 0;

window.onload = function() { pageLoaded = 1; };

function loaded(i,f) {
    if (document.getElementById && document.getElementById(i) != null) f();
    else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}

loaded('add_to_favourites', add_to_favourites);


