function checkComment(f){
	if(!f.nome.value)
		return alert("Preencha corretamente o campo nome"), f.nome.focus(), false;
	if(!/[\w-]+@([\w-]+\.)+[\w-]+/.test(f.email.value))
		return alert("O campo e-mail deve conter um email válido"), f.email.focus(), false;
	if(!f.texto.value)
		return alert("Preencha corretamente o campo mensagem"), f.texto.focus(), false;
	if(!f.captcha.value)
		return alert("Preencha o código de verificação"), f.captcha.focus(), false;
	return true;
}

function comment(link){
	var o = findNext(link.parentNode.parentNode, "div").style;
	o.display = ["", "none"][+(o.display != "none")];
	return false;
}

function enquete(resultado){
	var d = ["", "none"];
	ge("enquete-resultado").style.display = d[+!resultado];
	ge("enquete-responder").style.display = d[+resultado];
	return false;
}

function Calendar(year, month){
	var meses = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
	calendar = ge("calendar"),
	monthText = ge("calendar-month"),
	date = new Date(year, month - 1, 1),
	loader = new Loader("skin/img/loader.gif", calendar),
	loadCalendar = function(month, year){
		if(!arguments.length)
			month = date.getMonth() + 1, year = date.getFullYear();
		date = new Date(year, month - 1, 1);

		monthText.innerHTML = meses[month - 1] + " de " + year;
		loader.display(true);
		(new HTTPRequest).get("js/xhr/blog-calendario.aspx", {month: month, year: year}, {"end": function(o){
			if(o.status != 200)
				return loader.display(false), alert("Erro ao carregar o calendário");
			var c = calendar, days = new Function("return " + o.responseText)();
			var lastDay = /4|6|9|11/.test(month) ? 30 : month == 2 ? ((year = !(year % 4) && (year % 1e2) || !(year % 4e2)) ? 29 : 28) : 31,
			weekDay = date.getDay();
			for(var o = c.tBodies[0].getElementsByTagName("td"), i = weekDay; i--;){
				o[i].innerHTML = "&nbsp;";
				o[i].className = "mes";
			}
			for(var i = weekDay - 1, day = 0, l = o.length; ++i < l;){
				o[i].className = "";
				if(lastDay > day){
					o[i].innerHTML = ++day;
					if(days[0] == day){
						days.shift();
						o[i].className = "atual";
						o[i].innerHTML = "<a href=\"\/blog\/?data=" + year + "-" + month + "-" + day + "\">" + o[i].innerHTML + "</a>";
					}
				}
				else{
					o[i].className = "mes";
					o[i].innerHTML = "";
				}
			}
			loader.display(false);
		}});
	};
	addEvent(ge("calendar-previous"), "click", function(){
		date.setMonth(date.getMonth() - 1);
		loadCalendar();
		return false;
	});
	addEvent(ge("calendar-next"), "click", function(){
		date.setMonth(date.getMonth() + 1);
		loadCalendar();
		return false;
	});
	loadCalendar();
}