/* 
*  Script by: Dynamic Site Solutions -- http://www.dynamicsitesolutions.com/
*  Last Updated: 2007-02-06

*  IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Konqueror 3, IE5/Mac, iCab 3

Lo mejoré para poder hacerlo para varios idiomas, ya que originalmente está en inglés. El obj. linkTextAlertFav es mío. Estos son los alerts que eran originales:
var linkTextAlertFav = {
	linkText:'Favoritos',
	isKonq:'You need to press CTRL + B to bookmark our site.',
	isNsOriCABa:'You need to press ',
	isNsOriCABb:' + D to bookmark our site.',
	isIE5MacOrSafari:'You need to press Command/Cmd + D to bookmark our site.',
	isManually:'In order to bookmark this site you need to do so manually '+' through your browser.'
};
*/

var linkTextAlertFav = {
	linkText:'Favoritos',
	isKonq:'Debe presionar CTRL + B para agregar este site a sus favoritos.',
	isNsOriCABa:'Debe presionar ',
	isNsOriCABb:' + D para agregar este site a sus favoritos.',
	isIE5MacOrSafari:'Debe presionar Command/Cmd + D para agregar este site a sus favoritos.',
	isManually:'Para agregar este site a sus favoritos debe hacer algo manualmente en su navegador.'
};

var addBookmarkObj = {linkText:linkTextAlertFav.linkText, addTextLink:function (parId) {
	var a = addBookmarkObj.makeLink(parId);
	if (!a) {
		return;
	}
	a.appendChild(document.createTextNode(addBookmarkObj.linkText));
}, addImageLink:function (parId, imgPath) {
	if (!imgPath || isEmpty(imgPath)) {
		return;
	}
	var a = addBookmarkObj.makeLink(parId);
	if (!a) {
		return;
	}
	var img = document.createElement('img');
	img.alt = addBookmarkObj.linkText;
	img.title = '';
	img.src = imgPath;
	a.appendChild(img);
}, makeLink:function (parId) {
	if (!document.getElementById || !document.createTextNode) {
		return null;
	}
	parId = ((typeof (parId) == 'string') && !isEmpty(parId)) ? parId : 'addBookmarkContainer';
	var cont = document.getElementById(parId);
	if (!cont) {
		return null;
	}
	var a = document.createElement('a');
	a.href = location.href;
	if (window.opera) {
		a.rel = 'sidebar';
		// this makes it work in Opera 7+
	} else {
		// this doesn't work in Opera 7+ if the link has an onclick handler,
		// so we only add it if the browser isn't Opera.
		a.onclick = function() {
			addBookmarkObj.exec(this.href, this.title);
			return false;
		};
	}
	a.title = document.title;
	return cont.appendChild(a);
}, exec:function (url, title) {
	var isKonq = (isLikelyKonqueror3 && isLikelyKonqueror3());
	var isMac = (navigator.userAgent.toLowerCase().indexOf('mac') != -1);
	var buttonStr = isMac ? 'Command/Cmd' : 'CTRL';
	if (window.external && (!document.createTextNode || (typeof (window.external.AddFavorite) == 'unknown'))) {
		// IE4/Win generates an error when you
		// execute "typeof(window.external.AddFavorite)"
		// In IE7 the page must be from a web server, not directly from a local 
		// file system, otherwise, you will get a permission denied error.
		window.external.AddFavorite(url, title);
		// IE/Win
	} else if (isKonq) {
		alert(linkTextAlertFav.isKonq);
	} else if (window.opera) {
		void (0);
		// do nothing here (Opera 7+)
	} else if (window.home) {
		// Netscape, iCab
		alert(linkTextAlertFav.isNsOriCABa+buttonStr+linkTextAlertFav.isNsOriCABb);
	} else if (!window.print || isMac) {
		// IE5/Mac and Safari 1.0
		alert(linkTextAlertFav.isIE5MacOrSafari);
	} else {
		alert(linkTextAlertFav.isManually);
	}
}};
function isEmpty(s) {
	return ((s=='')||/^\s*$/.test(s));
}
function isLikelyKonqueror3() {
	if (!document.getElementById) {
		return false;
	}
	if (document.defaultCharset || window.opera || !window.print) {
		return false;
	}
	if (window.home) {
		return false;
	}
	// Konqueror doesn't support this but Firefox, 
	// which has silent support for document.all when in Quirks Mode does
	if (document.all) {
		return true;
	}
	// Konqueror versions before 3.4 
	var likely = 1;
	// testing for silent document.all support; try-catch used to keep it from
	// generating errors in other browsers.
	// try-catch causes errors in IE4 and NS4.x so we use the eval() to hide it.
	// try {
	//   var str=document.all[0].tagName;
	// } catch(err) { likely=0; }
	eval("try{var str=document.all[0].tagName;}catch(err){likely=0;}");
	return likely;
}
function dss_addEvent(el, etype, fn) {
	if (el.addEventListener && (!window.opera || opera.version) && (etype != 'load')) {
		el.addEventListener(etype, fn, false);
	} else if (el.attachEvent) {
		el.attachEvent('on'+etype, fn);
	} else {
		if (typeof (fn) != "function") {
			return;
		}
		if (typeof (window.earlyNS4) == 'undefined') {
			// to prevent this function from crashing Netscape versions before 4.02
			window.earlyNS4 = ((navigator.appName.toLowerCase() == 'netscape') && (parseFloat(navigator.appVersion)<4.02) && document.layers);
		}
		if ((typeof (el['on'+etype]) == "function") && !window.earlyNS4) {
			var tempFunc = el['on'+etype];
			el['on'+etype] = function (e) {
				var a = tempFunc(e), b = fn(e);
				a = (typeof (a) == 'undefined') ? true : a;
				b = (typeof (b) == 'undefined') ? true : b;
				return (a && b);
			};
		} else {
			el['on'+etype] = fn;
		}
	}
}
dss_addEvent(window, 'load', addBookmarkObj.addTextLink);

// below is an example of how to make an image link with this
// the first parameter is the ID. If you pass an empty string it defaults to
// 'addBookmarkContainer'.
/*
dss_addEvent(window,'load',function(){
  addBookmarkObj.addImageLink('','/images/add-bookmark.jpg');
});
*/
