/**
 * This method
 */

var BookmarkController = {
	//
	//
	//
	canBookmarkFromJS: function() {
		if (navigator.appName == 'Microsoft Internet Explorer' &&
			parseInt(navigator.appVersion) >= 4 &&
			window.external /* &&
			window.external.AddFavorite */) {
			return true;
		}
		/*
		 * Netscape variants were supported earlier, but
		 * links open in the sidebar, which is fairly
		 * useless (though the user can choose to have
		 * them open in other manners. Removing support
		 * for Mozilla based browsers (and their crummy
		 * sidebar).
		// otherwise, if this is a Netscape variant
		else if (navigator.appName == 'Netscape' &&
			navigator.indexOf('Firefox')
			window.sidebar &&
			window.sidebar.addPanel) {
			return true;
		}
		*/
		return false;
	},

	//
	//
	//
	bookmark: function(url, title) {
		// if we're internet explorer 4 or greater
		if (navigator.appName == 'Microsoft Internet Explorer' &&
			parseInt(navigator.appVersion) >= 4) {
			try {
				window.external.AddFavorite(url,title);
			}
			catch (e) {
				// eat the exception
				alert('Press Ctrl+D to bookmark this page.');
			}
		}
		// otherwise, if this is a Netscape variant
		else if (navigator.appName == 'Netscape' && window.sidebar && window.sidebar.addPanel) {
			window.sidebar.addPanel(title, url, '');
		}
		// if this is Opera
		else if (window.opera && window.print) {
			/*
			var a = document.createElement('a');
			a.setAttribute('rel', 'sidebar');
			a.setAttribute('target', '_search');
			a.setAttribute('title', title);
			a.setAttribute('href', url);
			a.click();
			*/
			alert('Press Ctrl+D (Netscape) or Ctrl+Shift+D (Opera) to bookmark this page.');
		}
		// if this is safari
		else if (navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
			if (navigator.userAgent.toLowerCase().indexOf('mac') != -1) { 
				alert('Press Command+D to bookmark this page.');
			}
			else {
				alert('Press Ctrl+D to bookmark this page.');
			}
		}
		else {
			alert('Press Ctrl+D (Netscape) or Ctrl+Shift+D (Opera) to bookmark this page.');
		}
	}
}

var bookmark = BookmarkController.bookmark;

