// JavaScript Document

var ajaxInProgress = 0;

function CloseDetailView()
{
		$('CalendarDetail').style.display = 'none';
		$('CalendarDetailBlend').style.display = 'none';
}

function UserDetailView(date, id)
{
		if (window.navigator.userAgent.indexOf("MSIE ") > -1 &&
		document.compatMode && !window.XMLHttpRequest)
		{
			return;
		}
					
	  if(ajaxInProgress == 1) return;
		ajaxInProgress = 1;
    new Ajax.Updater('CalendarDetail', 'index.php?id=' + id, {
			method: 'post',
			parameters:
			{
					"tx_dkcalendar_pi1[userAction]": "DetailView",
					"tx_dkcalendar_pi1[userDate]": date
			},
			onComplete: function()
			{
					ajaxInProgress = 0;
			  	new Effect.Opacity($('Calendar'), {duration: 0.0, to: 1.0 });
			  	new Effect.Opacity($('CalendarTopFrame'), {duration: 0.0, to: 1.0 });
	 				new Effect.Opacity($('CalendarDetailBlend'), {duration: 0.5, from: 0.00, to: 0.55 });
					$('CalendarDetail').style.display = 'block';
					$('CalendarDetailBlend').style.display = 'block';
			}
   });
	 new Effect.Opacity($('Calendar'), {duration: 0.0, to: 0.7 });
	 new Effect.Opacity($('CalendarTopFrame'), {duration: 0.0, to: 0.4 });
	 new Effect.Opacity($('CalendarDetailBlend'), {duration: 0.0, to: 0.00 });
}

function UserMonthLeft(id)
{
	  if(ajaxInProgress == 1) return;
		ajaxInProgress = 1;
		var currentMonth = parseInt($('CalendarCurrentMonth').innerHTML);
		var currentYear = parseInt($('CalendarCurrentYear').innerHTML);
		if(currentMonth == 1)
		{
				currentMonth = 12;
				currentYear -= 1;
		} else {
				currentMonth -= 1;
		}
    new Ajax.Updater('Calendar', 'index.php?id=' + id, {
			method: 'post',
			parameters:
			{
					"tx_dkcalendar_pi1[userAction]": "ChangedDate",
					"tx_dkcalendar_pi1[userMonth]": currentMonth,
					"tx_dkcalendar_pi1[userYear]": currentYear
			},
			onComplete: function()
			{
					if (window.navigator.userAgent.indexOf("MSIE ") > -1 &&
					document.compatMode && !window.XMLHttpRequest)
					{
						$('weg1').style.display = "block";
						$('weg2').style.display = "block";
					}
					ajaxInProgress = 0;
			  	new Effect.Opacity($('Calendar'), {duration: 0.0, to: 1.0 });
			  	new Effect.Opacity($('CalendarTopFrame'), {duration: 0.0, to: 1.0 });
			}
   });
	 new Effect.Opacity($('Calendar'), {duration: 0.0, to: 0.7 });
	 new Effect.Opacity($('CalendarTopFrame'), {duration: 0.0, to: 0.4 });
}

function UserMonthRight(id)
{
	  if(ajaxInProgress == 1) return;
		ajaxInProgress = 1;
		var currentMonth = parseInt($('CalendarCurrentMonth').innerHTML);
		var currentYear = parseInt($('CalendarCurrentYear').innerHTML);
		if(currentMonth == 12)
		{
				currentMonth = 1;
				currentYear += 1;
		} else {
				currentMonth += 1;
		}
    new Ajax.Updater('Calendar', 'index.php?id=' + id, {
			method: 'post',
			parameters:
			{
					"tx_dkcalendar_pi1[userAction]": "ChangedDate",
					"tx_dkcalendar_pi1[userMonth]": currentMonth,
					"tx_dkcalendar_pi1[userYear]": currentYear
			},
			onComplete: function()
			{
					if (window.navigator.userAgent.indexOf("MSIE ") > -1 &&
					document.compatMode && !window.XMLHttpRequest)
					{
						$('weg1').style.display = "block";
						$('weg2').style.display = "block";
					}
					ajaxInProgress = 0;
			  	new Effect.Opacity($('Calendar'), {duration: 0.0, to: 1.0 });
			  	new Effect.Opacity($('CalendarTopFrame'), {duration: 0.0, to: 1.0 });
			}
   });
	 new Effect.Opacity($('Calendar'), {duration: 0.0, to: 0.7 });
	 new Effect.Opacity($('CalendarTopFrame'), {duration: 0.0, to: 0.4 });
}
