/*
function changeView(type, section) {
	 

	if (type == "list") 
	{
		$("#typelink").html("<a onclick='changeView(\"calendar\", \""+section+"\")' href='#'>Calendar View</a>");
	}
	
	if (type == "calendar") 
	{
		$("#typelink").html("<a onclick='changeView(\"list\", \""+section+"\")' href='#'>List View</a>");
	}

	$.ajax({
	   		type: "POST", 
	   		url: "/index.php?c=control&m=eventtype&type="+type+"&section="+section+"&cache=" + Number(new Date()),
	   		success: function(dataBack) {    			   		
				if (dataBack != '')	{				
					$("#view").html(dataBack);
					if (type=="calendar") initCalendar(section);			
				} else {
					$("#view").html("Failed to load");
				}
	   		}
		});
}
*/

function initCalendar(section, calctgy) {  

	var eventurl = "/index.php?c=control&m=events&section="+section+"&ctgy="+calctgy;

	$('#calendar').fullCalendar({
				
		titleFormat: {
			week: '&#77;ee&#116;ing&#115; an&#100; Even&#116;&#115; For M/d - {M/d}'
		},
	
		header: {
				left: '',
				center: 'prev, title, next',
				right: ''
		},
		
		events: eventurl,  
	 
		editable: false,
		
		defaultView: 'basicWeek',	
		//defaultView: 'agendaDay',
			
		timeFormat: { // for event elements
			'': 'h:mm tt - {h:mm tt}' // default
		},		

		eventMouseover: function(calevent, e) {
			var event = $(this).find('a').find('span.fc-event-title').find("div").text();
			leftVal = $(this).css('left');
			topVal = $(this).css('top');
			if (event != "")
			{
			$('#popupDate .location').html(event);
			$('#popupDate').css({left:leftVal,top:topVal}).show();
			}
		},
		
		eventMouseout: function() {
			$('#popupDate').hide();
		},
					
		loading: function(bool) {
			if (bool) $('#loading').show();
			else $('#loading').hide();
		}

	
	});  
}

$(document).ready(function() { 
	initCalendar('0', calSect);

	$('dl.dropdown').hover(function() {
  	 	$(this).find('dt').addClass('dthover');
  	}, function() {
   		$(this).find('dt').removeClass('dthover');
  	});
  	
	$(".dropdown").click(function() {
		$(".dropdown dd").toggle();
	});
	
   $(document).bind('click', function(e) {
        var $clicked = $(e.target);
        if (! $clicked.parents().hasClass("dropdown"))
            $(".dropdown dd").hide();
    });
	
	
});


function showListView() {
	
	$('#date_extract2').val( $('.fc-header-title').html() );
	 
	$('#type_extract2').val( $('dt').html() );	
	
	$('#forlistedview').submit();
}

function showPrintView() {
	
	$('#date_extract').val( $('.fc-header-title').html() );
	 
	$('#type_extract').val( $('dt').html() );	
	
	$('#forlistview').submit();
}

