function SetupCalendar()
{
    //Remove the non-javascript controls
    jQuery('#cal-nav').addClass('withjs');
    jQuery('.next-month a').click(function()
    {
       MoveCalendar(1);
       return false;    
    }); 
    jQuery('.prev-month a').click(function()
    {
       MoveCalendar(-1);
       return false;    
    });     
    jQuery('#calendar #month').change(function()
    {
       CalendarGo();
    }); 
    jQuery('#calendar #year').change(function()
    {
       CalendarGo();
    }); 
}

function MoveCalendar(dir)
{
    currentmonth=parseInt(jQuery('#calendar #month').val());
    currentyear=parseInt(jQuery('#calendar #year').val());
    newmonth=currentmonth+dir;
    newyear=currentyear;
    if (newmonth==13)
    {
        newmonth=1;
        newyear++;
    }
    if (newmonth==0)
    {
        newmonth=12;
        newyear--;
    }        
    jQuery("#calendar #month option[value='"+currentmonth+"']").removeAttr('selected');
    jQuery("#calendar #year option[value='"+currentyear+"']").removeAttr('selected');
    jQuery("#calendar #month option[value='"+newmonth+"']").attr('selected','selected');
    jQuery("#calendar #year option[value='"+newyear+"']").attr('selected','selected');

    CalendarGo();
}  

function CalendarGo(month,year)
{
    jQuery("#calendar-holder").fadeTo('fast',0,function()
	{
		month=parseInt(jQuery('#calendar #month').val());
		year=parseInt(jQuery('#calendar #year').val());
		jQuery("#calendar-holder").load("/uctrl-project/calendar.php?month="+month+"&year="+year+"&ajax=1",'',function()
		{
			 jQuery("#calendar-holder").fadeTo('medium',1);
		});
	});
}
