/*############################################################## 
	@Autor:			Aderbal Nunes
	@e-mail:		aderbalnunes@gmail.com
	@data:			07/12/2007
	@content:		Funções do calendário (SÓ ALTERE SE SOUBER O QUE ESTÁ FAZENDO)
###############################################################*/



/**
 * Quando documento é carregado, mostre o calendário com datas atuais
 */
$(document).ready(function(){
	
	$("#calendario").html("Carregando...");
	
	var html = $.ajax({
 		url: "calendario/php/c.php",
  		async: false				  
	}).responseText;
	
	$("#calendario").html(html);
		
});

/**
 * Altera o ano a ser mostrado (-ano)
 */
function prev(){
	var ano = $("#ano").text();
	ano--;
	$("#ano").html(ano);
}

/**
 * Altera o ano a ser mostrado (+ano)
 */
function next(){
	var ano = $("#ano").text();
	ano++;
	$("#ano").html(ano);
}


/**
 * Muda o calendário com ano e mês escolhido
 */
function mudaMes(){
	 var ano = $("#ano").text();
	 var mes = $("#listMes").val();
	 
	 $("#calendario").html("Carregando...");

	 $.ajax({
		type 	: "POST",
		url  	: "calendario/php/c.php",
		data 	: "mes="+mes+"&ano="+ano,
		success : function(res){
			$("#calendario").html(res);
		}
	 });
}

/**
 * Abre o pop-up com o conteúdo da agenda 
 */
function show(obj){
	var ano = $("#ano").text();
	var mes = $("#listMes").val();
	
    var x = parseInt((screen.width-435)/2); 
    var y = parseInt((screen.height-250)/2); 	
	
	var param = "dia="+obj.id+"&mes="+mes+"&ano="+ano;
	
	window.open('calendario/php/show.php?'+param+'','popup','width=435,height=250,scrollbars=yes,top='+y+',left='+x+'');
}