var at_resize_image = function(){
	if($(this).width()>640) {
		$(this).width(640);
		var elarge = $('<a class="imgres" href="">&Eacute;largir/r&eacute;duire l\'image</a>');
		elarge.click(function(){
			var div = $(this).parent(".band_imgres");
			var img = div.data("image");
			div.css({position:"relative"});
			if(img.width()>640) {
				img.css({position:"relative",width:640,left:"auto"},1000);
				div.height("auto");
			}
			else {
				img.css({position:"absolute",width:"auto"});
				var w_im = img.width();
				var left = "-"+Math.min(170,Math.floor(160-(800-w_im)/2))+"px";
				img.css({left:left});
				// Math.floor(320-80-img.width()/2)} (soucis: scrolle pas vers la gauche)
				div.height(img.height()+$(this).height());
			}
			return false;
		});
		var bandeau = $('<div class="band_imgres"></div>').append(elarge).append(' - '
			+'<a class="imgres" href="'+$(this).attr("src")
			+'" target="_blank">Voir dans une nouvelle fen&ecirc;tre</a>'
			+'<br/>')
			.data("image",$(this))
			.css({background:"darkblue",margin:"0"});
		if( $(this).parents("a").length>0 ) {
			$(this).parents("a").before(bandeau);
			bandeau.append($(this).parents("a"));
		} else {
			$(this).before(bandeau);
			bandeau.append($(this));
		}
	}
};
$(function() {
	/* cacher les pubs google */
	$('#add-google').remove();
	$('#google_ads_frame,#google_ads_frame1').remove();
	/* redimensionner les images */
	$('.postbody img, .quote img').each(at_resize_image);
	$('.postbody img, .quote img, .spoiler img').load(at_resize_image);
	/* ajouter à ".spoiler img" ? mais ça ne marche pas, il faut attendre qu'il "déspoile" */
	/* style du bidule */
	/*
		.imgres { background:#F2F6FF; color:#415680; border:1px solid #F2F6FF; }
		.imgres:hover { background:#415680; color:#F2F6FF; }
	*/
});
