$(document).ready(function() {
	// programacao
	var programacao = $('.programacaoconteudo');
	if(programacao.length > 0){
		var content = $('#content');
		programacao.css({'margin-top':'-' + (content.height()+22) + 'px'});
	}
	var programas = $('#programas');
	if(programas.length > 0){
		if($('.content_col_2_programacao').height() > $('#content').height()){
			$('#content').height($('.content_col_2').height());
		}else{
			$('.content_col_2').height($('#content').height());
		}
		$('.content_col_1_2').height($('.content_col_2').height() - 30);
	}
	// blog_radiocaos
	var blog_radiocaos = $('#blog_radiocaos');
	if (blog_radiocaos.length > 0) {
		if($('.content_col_2').height() > $('.content_col_1').height()){
			$('.content_col_1').height($('.content_col_2').height());
		}else{
			$('.content_col_2').height($('.content_col_1').height());
		}
	}
	// home
	var home_content_col_1 = $('.home_content_col_1');
	var home_content_col_2 = $('.home_content_col_2');
	if (home_content_col_1.length > 0 && home_content_col_2.length > 0) {
		if(home_content_col_1.height() > home_content_col_2.height()){
			home_content_col_2.height(home_content_col_1.height());
		}else{
			home_content_col_1.height(home_content_col_2.height());
		}
	}
	// images
	if($('#programacaoconteudo').length > 0){
		$('#programacaoconteudo img').each(function(){
			var image = $(this);
			var maxWidth = 780;
			if(image.width() > maxWidth){
				ratio = maxWidth / image.width();
				image.width(maxWidth);
				image.height(image.height() * ratio);
			}
		});
	}else{
		$('#content img').each(function(){
			var image = $(this);
			var maxWidth = 730;
			if(image.width() > maxWidth){
				ratio = maxWidth / image.width();
				image.width(maxWidth);
				image.height(image.height() * ratio);
			}
			$(this).load(function(){
				var programacao = $('.programacaoconteudo');
				if(programacao.length > 0){
					var content = $('#content');
					programacao.css({'margin-top':'-' + (content.height()+22) + 'px'});
				}
				var programas = $('#programas');
				if(programas.length > 0){
					if($('.content_col_2_programacao').height() > $('#content').height()){
						$('#content').height($('.content_col_2').height());
					}else{
						$('.content_col_2').height($('#content').height());
					}
					$('.content_col_1_2').height($('.content_col_2').height() - 30);
				}
			});
		});
	}
});

