$(document).ready(function () {




var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		$('#calendar').fullCalendar({
			editable: false,
			aspectRatio: 1,
			events: $.fullCalendar.gcalFeed(
            "http://www.google.com/calendar/feeds/marnixcollege%40gmail.com/public/basic",
			{
				currentTimezone : 'Europe/Amsterdam'	
			}
        ),
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,basicWeek,basicDay'
			},
			
			eventRender: function(event, element, view)
    {
		
       $('#content').css('height', $('.fc-content').height());
       $('#content').css('height', $('.fc-content').height());
       $('#blokjes').css('display', 'none');
    }
			
		});














	
	
    // MENU

$("nav .main:not(#cur)").hoverIntent(
  function () {
  
    $(this).children('ul').fadeIn(200);
	// Fade Current weg
	$('#cur').children('ul').fadeOut(200);
	
  }, 
  function () {
	
	$(this).children('ul').fadeOut(200);	
	
  }
);	


$("#cur").hover(
  function () {
	   $(this).children('ul').fadeIn(200);
  });

$("nav").hoverIntent(
function () { 

 }, 
  function () {
// Fade Current in	
	$('#cur').children('ul').fadeIn(300);
});


	
	
	
    if ($('#cur').length) { // implies *not* zero
        $('#cur').find('ul').show();
        $('#blokjes').css('width', '233px');
        $('#content').css('width', '630px');
    }
	
	
	
	if($('#content').height() < $('#blokjes').height() )
	{
	$('#center').css('height', $('#blokjes').height() + 'px');
	}
	else
	{
	
	};
	
	
	if ($('#calendar').length) { // implies *not* zero
     $('#content').css('width', '870px');
	 
  } else {
  ;
  }
	
	
	
	
	
    // Zijbalk
    $(window).scroll(function () {
        if ($('#cur').length) { // implies *not* zero
            $('#blokjes').css('position', 'absolute');
            $('#blokjes').css('right', '21px');
            $schermGrote = $(window).height();
            $balkGrote = $('#blokjes').height();
            if ($balkGrote > $schermGrote) {} else {
                if ($(window).scrollTop() > 428) {
               
					$("#blokjes").stop().animate({ 
  top: $(window).scrollTop() + 15
   
  }, 700, function() {
	  
	  if ($(window).scrollTop() < 400) {
	  
	   $("#blokjes").stop().animate({ 
  top: '450px'
   
  }, 700)
	  }
  });
					
					
					
                } else {
                    $("#blokjes").css('top', '450px');
                }
            }
        };
    });
});
