$(function(){
	$('.headeraction').bind({
		mouseenter : function()
		{
			$(this).clearQueue();
			$(this).fadeTo('fast',0.6);
		},
		mouseleave: function()
		{
			$(this).fadeTo('fast',1);
		},
		click : function()
		{
			var i = $(this).attr('rel');
			window.location = i;			
		}
	});	

	$('td.calendar_day').mouseenter(function() {
		// console.log('test');
		$('div.calendar_items', this).show();
	}).mouseleave(function() {
		$('div.calendar_items', this).hide();
	});
});

function displayMonth(mId){
	document.getElementById('month_'+mId).style.display = '';
	document.getElementById('currentMonth').value = mId;

}
function hideMonth(mId){
	document.getElementById('month_'+mId).style.display = 'none';
}

function jumpToMonth(mId){
	for(i = 1; i <= 12; i++){
		if(mId == i){
			displayMonth(i);
			document.getElementById('jumpmonth').value = i;
		}else{
			hideMonth(i);
		}
	}
}

function nextMonth(){
	var m,y,nextY;
	m = document.getElementById('currentMonth').value;
	y = document.getElementById('currentYear').value;
	nextY = parseInt(y) + 1;
	if(nextY > 2020){ nextY = 2020; }
	if(m < 12){ m++	}else{	window.location='?year='+ nextY +'&setmonth=1';}
	jumpToMonth(m);
}

function lastMonth(){
	var m,y;
	m = document.getElementById('currentMonth').value;
	y = document.getElementById('currentYear').value;
	lastY = parseInt(y) - 1;
	if(lastY < 2007){ lastY = 2007; }
	if(m > 1){ m--; }else{ window.location='?year='+lastY+'&setmonth=12'; }
	jumpToMonth(m);
}

function jumpyear(y){
	var m,y;

	m = document.getElementById('currentMonth').value;
	window.location='?year='+y+'&setmonth='+m;

}


