function initFacebookLinkObserver(e) {
    
	if (!document.getElementsByTagName){ return; }

	var anchors = document.getElementsByTagName('a');

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		
		var relAttribute = String(anchor.getAttribute('rel'));		
		var url = String(anchor.getAttribute('href'));
		var title = String(anchor.getAttribute('title'));
		
		// use the string.match() method to catch 'facebook' references in the rel attribute
		if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('facebook'))){
					
			anchor.onclick = function () {
				var url = String(this.getAttribute('href'));
				var title = String(this.getAttribute('title'));

				var dotmarkpos = url.indexOf('?u=');
				if(dotmarkpos > 0) {
					url = url.substring(dotmarkpos + 3);
					window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'sharer','toolbar=0,status=0,width=626,height=436');
					}
				return false;
				}
			/*Event.observe(anchor, 'click', function (e) {
				
				Event.stop(e);		
				
				var dotmarkpos = url.indexOf('?u=');
				if(dotmarkpos > 0) {
					url = url.substring(dotmarkpos + 3);
					window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'sharer','toolbar=0,status=0,width=626,height=436');
				}
				return false;
			}, true);*/
		}
	}
}

Event.observe(window, 'load', initFacebookLinkObserver);

