// socialtags.js

// 'ajouter un bookmark' ne marche que sous IE
// les tuyaux trouves pour FF ou Opera sont creves
;var socialtags_addfavorite = function(u,t){
	if(document.all)window.external.AddFavorite(u,t);
};
(function($) { $(function(){
var selector = $('#contenu');
if (!selector.length) return;
var socialtags = [
{ a: 'facebook', n: 'Facebook', i: 'plugins/auto/socialtags/images/facebook.png', u: 'http://www.facebook.com/sharer.php?u=%u&t=%t' },
{ a: 'twitter', n: 'Twitter', i: 'plugins/auto/socialtags/images/twitter.png', u: 'http://twitter.com/home?status=%u' }
];
var title = $('title').text() ||'';
// [@attr] style selectors removed in jQuery 1.3 (voir http://docs.jquery.com/Selectors)
// si besoin, rendre compatible avec anciennes versions de jQuery (SPIP 192x)
var jqss = (jQuery.fn.jquery <= '1.2.6') ? '@' : '';
var description = ($('meta['+jqss+'name=description]').attr('content') || '').substr(0,250);
var cano = $('link['+jqss+'rel=canonical]')[0];
var url = cano ? cano.href : document.location.href;
var ul = $('<ul><\/ul>');
var esc = function(x){return encodeURIComponent(x).replace(/\s/g,' ');};

$.each(socialtags, function(){ if (this.u) {
	if (this.a == 'bookmark' && !document.all) return;

	$('<a rel="nofollow"><img class="socialtags-hovers" src="'+ this.i +'"\/><\/a>')
	.attr('href',
		this.u
		.replace(/%u/g, esc(url))
		.replace(/%t/g, esc(title))
		.replace(/%d/g, esc(description))
	)
	.attr('title', this.n)
	.wrap('<li><\/li>')
	.parent().appendTo(ul);
}});

selector.after(ul.wrap('<div class="socialtags"><\/div>').parent());

}); })(jQuery);
