$(document).ready(function() {

//	$('#cycle').cycle({
//		fx: 'fade'
//	});

//	$('figure.gallery-item a').attr('rel','gallery');
//	$('figure.gallery-item a[rel="gallery"]').fancybox();

	$('#nav_col ul li:last-child').css({paddingBottom: '0', marginBottom: '0', borderBottom: '0'});
	$('article:last-child, .article:last-child').css({marginBottom: '0', border: '0'});
	$('.staff-list li.staff:last-child').css({borderBottom: '0'});
	$('.staff-list li.staff div .description p:last-child').css({marginBottom: '0'});
	$('#nav-main ul ul li:last-child').css({borderBottom: '0'});

	$('#main img.size-medium, #main img.size-large, #main img.size-full').not('img.square').one('load',function () {
		var img = $(this);
		var img_width = parseInt(img.css('width'));
		var img_height = parseInt(img.css('height'));

		// build wrapper
		var wrapper = $('<div class="rounded_wrapper"></div>');
		wrapper.css('width', img_width + 'px');
		wrapper.css('height', img_height + 'px');

		// move CSS properties from img to wrapper
		wrapper.css('float', img.css('float')); img.css('float', 'none');
		wrapper.css('clear', img.css('clear')); img.css('clear', 'none');
		wrapper.css('margin-right', img.css('margin-right')); img.css('margin-right', '0');
		wrapper.css('margin-left', img.css('margin-left')); img.css('margin-left', '0');
		wrapper.css('margin-bottom', img.css('margin-bottom')); img.css('margin-bottom', '0');
		wrapper.css('margin-top', img.css('margin-top')); img.css('margin-top', '0')
		wrapper.css('display', 'block'); img.css('display', 'block');

		// wrap image
		img.wrap(wrapper);

		// add rounded corners
		img.after('<div class="tl"></div>');
		img.after('<div class="tr"></div>');
		img.after('<div class="bl"></div>');
		img.after('<div class="br"></div>');
	}).each(function(){
		if(this.complete) $(this).trigger("load");
	});

});

