



function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function size_pictures() {
	$('.text img').each(function(index) {
	  if ($(this).width() > 490) {
			var width = $(this).width();
			var height = $(this).height();
			var ratio = roundNumber(width/height,2);
			width = 490;
			height = roundNumber(width/ratio,0)
			$(this).css('width', width+'px');
			$(this).css('height', height+'px');
	  }
	});
	$('.text .wp-caption').each(function(index) {
		if ($(this).width() > 510) {
			$(this).css('width', '510px');
		}
	});
	$('.text embed').each(function(index) {
		var url = $(this).attr("src");
		var is_youtube = url.search("youtube.com");
		if ($(this).width() > 524 && is_youtube != -1 ) {
			var width = $(this).width();
			var height = $(this).height();
			var ratio = roundNumber(width/height,2);
			width = 524;
			height = roundNumber(width/ratio,0)
			$(this).css('width', width+'px');
			$(this).css('height', height+'px');
		}
	});
		$('.text object').each(function(index) {
		var url = $(this).attr("src");
		if ($(this).width() > 524 ) {
			var width = $(this).width();
			var height = $(this).height();
			var ratio = roundNumber(width/height,2);
			width = 524;
			height = roundNumber(width/ratio,0)
			$(this).css('width', width+'px');
			$(this).css('height', height+'px');
		}
	});
}
