/* 
	position (hidden) banner ads at designated placeholders (given class div.ad) in the main body after page load
	to avoid having to use inline javascript to write the ads directly in the page.
	
	based on code from http://www.trovacasa.net, in turn based on
	http://www.google.com/support/forum/p/Google+Ad+Manager/thread?tid=7bcfaa482259cc28&hl=en
*/
function fixbanner(bannerId) {
	var id = bannerId.replace(/_ad/, '');                
	var pos = $('#' + id).offset();
	if (pos) {
			$('#' + bannerId).css({
					'left': pos.left + 'px',
					'top': pos.top + 4 + 'px'
			});
	}
};

$('div.ad').each(function() {
	var id = $(this).attr('id') + '_ad';
	fixbanner(id);
});

// restore positions on resize
$(window).resize(function() {
	$('div.ad').each(function() {
		var id = $(this).attr('id') + '_ad';
		fixbanner(id);
	});
});