$(document).ready(function() {
	var is_home = 0;
	if (selected=='home') {
		is_home = 1;
	}
	$('#Calendario_de_Eventos_CMB1').live('change', function() {
		mesano = $(this).val();
		mesano = mesano.split('-');
		getCalendario(mesano[1],mesano[0],is_home);
	});
	$('#vertodos').click(function() {
		mesano = $('#Calendario_de_Eventos_CMB1').val();
		mesano = mesano.split('-');
		getEventos(mesano[1],mesano[0]);
	});
	$('.tdCalendar').live('click', function() {
		if ($(this).attr('onclick')) {
			$('.tdCalendar_sel').removeClass('tdCalendar_sel').addClass('tdCalendar');
			$(this).addClass('tdCalendar_sel');
		}
	});
});

function getCalendario(tmp_ano, tmp_mes, is_home) {
	$.ajax({
		type: "GET",
		url: "../../inc/routines/routines.php",
		data: {
			action : 'getCalendario',
			ano : tmp_ano,
			mes : tmp_mes,
			home : is_home
		},
		success: function(retorno) {
			if (retorno) {
				$("#calendario").html(retorno);
			}
		}
	});
}

function getEventos(tmp_ano, tmp_mes, tmp_dia) {
	$.ajax({
		type: "GET",
		url: "../../inc/routines/routines.php",
		data: {
			action : 'getEventos',
			ano : tmp_ano,
			mes : tmp_mes,
			dia : tmp_dia
		},
		success: function(retorno) {
			if (retorno) {
				$("#listaEventos").html(retorno);
			}
		}
	});
}

function getProximosEventos() {
	$.ajax({
		type: "GET",
		url: "../../inc/routines/routines.php",
		data: {
			action : 'getProximosEventos'
		},
		success: function(retorno) {
			if (retorno) {
				$("#proximoseventos").html(retorno);
				$(function(){ 
					settings = {
						tl: { radius: 3 },
						tr: { radius: 3 },
						bl: { radius: 3 },
						br: { radius: 3 },
						autoPad: true,
						validTags: ["div"]
						}
					  $('.boxEventos').corner(settings);
				});
			}
		}
	});
}

