showFriendLink = 1; // can be reset on a loaded html page

/*Ajax Event Functions*/
function startAjaxWorking()
{
	new Effect.Move($('ajaxWorking'),{duration:0.0, x: xPos, y: yPos, mode: 'absolute'});
	//new Effect.Opacity($('container'),{duration:0.5, from:1.0, to:0.7});
}
function stopAjaxWorking()
{
	new Effect.Move($('ajaxWorking'),{duration:0.0, x: 0, y: -1000, mode: 'absolute'});
	//new Effect.Opacity($('container'),{duration:0.5, from:0.7, to:1.0});
}
/**************
set the x and y coordinates
**************/
function setXY(e)
{
	yPos = Event.pointerY(e);
	xPos = Event.pointerX(e);
}
function ajaxEventDay(eventDay, eventMonth, eventYear,catid)
{
	//startAjaxWorking();
	// drop out the events
	new Effect.Parallel([
			new Effect.Move('ajaxResults', { sync: true, x: 0, y: 100, mode: 'relative' }),
			new Effect.Opacity('ajaxResults', { sync: true, from: 1, to: 0 })
		], {
		duration: 0.1});
	new Ajax.Request('/ajax/event_day.sd?calday=' + eventDay + '&calmonth=' + eventMonth + '&calyear=' + eventYear + '&catid=' + catid + '&friend=' + showFriendLink,
	{
		method:'get',
		onSuccess: function(transport)
		{
			var response = transport.responseText || "no response text";
			$('ajaxResults').update(response);
			// show the events
			new Effect.Parallel([
					new Effect.Move('ajaxResults', { sync: true, x: 0, y: -100, mode: 'relative' }),
					new Effect.Opacity('ajaxResults', { sync: true, from: 0, to: 1 })
				], {
				queue: 'end', duration: 1.0});
			//stopAjaxWorking();
		},
		onFailure: function(){stopAjaxWorking();}
	});
}
function ajaxEventWeek(eventWeek, eventMonth, eventYear,catid)
{
	startAjaxWorking();
	// drop out the events
	new Effect.Parallel([
			new Effect.Move('ajaxResults', { sync: true, x: 0, y: 100, mode: 'relative' }),
			new Effect.Opacity('ajaxResults', { sync: true, from: 1, to: 0 })
		], {
		duration: 0.1});
	new Ajax.Request('/ajax/event_week.sd?calweek=' + eventWeek + '&calmonth=' + eventMonth + '&calyear=' + eventYear + '&catid=' + catid + '&friend=' + showFriendLink,
	{
		method:'get',
		onSuccess: function(transport)
		{
			var response = transport.responseText || "no response text";
			$('ajaxResults').update(response);
			// show the events
			new Effect.Parallel([
					new Effect.Move('ajaxResults', { sync: true, x: 0, y: -100, mode: 'relative' }),
					new Effect.Opacity('ajaxResults', { sync: true, from: 0, to: 1 })
				], {
				duration: 1.0});
			stopAjaxWorking();
		},
		onFailure: function(){stopAjaxWorking();}
	});
}
function ajaxEventMonth(urlValue)
{
	//Effect.Fade('ajaxResults');
	new Ajax.Request(urlValue,
	{
		method:'get',
		onSuccess: function(transport)
		{
			var response = transport.responseText || "no response text";
			$('ajaxResults').update(response);
			Effect.SlideDown('ajaxResults');
		},
		onFailure: function(){stopAjaxWorking();}
	});
}

function showWeeklyDiv(thisDay)
{
	element = thisDay + 'Weekly';
	elementHover = thisDay + 'WeeklyHover';

	// change the opacity for all the elements
	var itemArray = $$('.eventWeeklyHover');
	for (i=0; i <= (itemArray.length-1); i++)
	{
		itemArray[i].setOpacity(0);
	}

	//$(element).style.display = "none";
	new Effect.Appear(elementHover,{duration: 0.0});

}

function hideWeeklyDiv(thisDay)
{
	// change the opacity for all the elements
	var itemArray = $$('.eventWeeklyHover');
	for (i=0; i <= (itemArray.length-1); i++)
	{
		itemArray[i].setOpacity(0);
	}
}

