﻿jQuery.favicons = function(el, conf) {
	var config = {
		width: '11',
		height: '11',
		defaultIco: '/Images/external.png'
	};
	config = jQuery.extend(config, conf);

	el.filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).each(function() {
		var link = jQuery(this);
		var faviconURL = 'http://www.google.com/s2/favicons?domain=' + link.attr('href').replace(/^http:\/\/([^\/]+).*$/, '$1');
		var faviconIMG = jQuery('<img width="' + config.width + '" height="' + config.height + '" src="' + serverPath + config.defaultIco + '" alt="external link" />');
		link.after(faviconIMG).after(' ');

		var extImg = new Image();
		extImg.onload = function() {
			faviconIMG.attr('src', faviconURL);
		};
		extImg.src = faviconURL;
	});
};
