///////////////////////////////////////////////////////
//
// localendar.com - transitions.js
//
///////////////////////////////////////////////////////
function doTransEffect(effect,toHide,toShow,cycleTo, fromWhen,toWhen)
{
	if ("slide"==effect.toLowerCase())
	{
		if (toWhen.getTime()<fromWhen.getTime())
		{	
			$(toHide).hide("slide", { direction: "right" } ,1500);
			$(toShow).show("slide", { direction: "left" },1500);
		}
		else
		{
			$(toHide).hide("slide", { direction: "left" } ,1500);
			$(toShow).show("slide", { direction: "right" },1500);
		}
	}
	else if ("vdrop"==effect.toLowerCase())
	{
		if (toWhen.getTime()<fromWhen.getTime())
		{	
			$(toHide).hide("drop", { direction: "down" },1000);
			$(toShow).show("drop", { direction: "up" },1000);
		}
		else
		{
			$(toHide).hide("drop", { direction: "up" },1000);
			$(toShow).show("drop", { direction: "down" },1000);
		}
	}
	else if ("hdrop"==effect.toLowerCase())
	{
		if (toWhen.getTime()<fromWhen.getTime())
		{	
			$(toHide).hide("drop", { direction: "right" },1000);
			$(toShow).show("drop", { direction: "left" },1000);
		}
		else
		{
			$(toHide).hide("drop", { direction: "left" },1000);
			$(toShow).show("drop", { direction: "right" },1000);
		}
	}
	else if ("fold"==effect.toLowerCase()) // this effect may be removed
	{
		$(toHide).hide("fold", { size: 10 },3000);
		$(toShow).show("fold", { size: 10 },3000);
	}	
	else if ("shake"==effect.toLowerCase()) // might work once you figure out how to serialize effects
	{
		$(toHide).effect("shake", { times: 3 },300);
		//$(toShow).show();
		//$(toHide).hide();
	}
	else if ("roll"==effect.toLowerCase()) // this effect needs to fade on the hide
	{
		//$(toHide).hide("clip", { direction: "vertical" }, 2000);
		//$(toHide).fadeOut();
		$(toHide).hide("slide", { direction: "down" }, 2000);
		$(toShow).show("slide", { direction: "down" }, 2000);
	}	
	else if ("hclip"==effect.toLowerCase()) 
	{
		$(toHide).hide("clip", { direction: "horizontal" }, 1000);
		$(toShow).show("clip", { direction: "horiztonal" }, 1000);
	}	
	else if (effect.indexOf("cyc_",0)>=0) // Cycle-based effect
	{
		 $('#calendar_container').cycle(cycleTo); 
	}	

}

function lc_publishjump(p_menutype,p_date,p_calendarid,p_rsslink)
{
	if (("none"!=transEffect.toLowerCase()) && (p_menutype==lastMenutype)) 
	{
		var toShow = "", toHide="", url=""; cycle=0;
		if ($('#alt_calendar').is(':hidden')) 
		{
			toShow="#alt_calendar";
			toHide="#calendar";
			cycle = 0;
		}
		else 
		{
			toShow="#calendar";
			toHide="#alt_calendar";
			cycle = 1;
		}
		//alert("Boo!");
		url = "/elsie?JSP=PublishedCalendar&mode=PUBLISH_PUBLIC&ajax=true&search_type="+p_menutype+"&start_date="+p_date+"&calendar_id="+p_calendarid; //+"&rss_link="+p_rsslink;	
		var next = new Date(p_date);
		$(toShow).load(url,null,function(){
			doTransEffect(transEffect,toHide, toShow, cycle, now, next);
			now = next;
		});
	} 
	else 
		window.location.href="/elsie?JSP=PublishedCalendar&mode=PUBLISH_PUBLIC&search_type="+p_menutype+"&start_date="+p_date+"&calendar_id="+p_calendarid; //+"&rss_link="+p_rsslink;
}

function transEffectInit(effect)
{
	if ("cyc_bounceout"==effect.toLowerCase())
	{
		$('#calendar_container').cycle({ 
		    fx:      'scrollVert', 
		    speedIn:  2000, 
		    speedOut: 500, 
		    easeIn:  'bounceout', 
		    easeOut: 'backin', 
		    delay:   -2000,
		    timeout: 0, 
		    startingSlide: 1 
		});
	}
	else if ("cyc_bounceup"==effect.toLowerCase())
	{
		$('#calendar_container').cycle({ 
		    fx:      'curtainY', 
		    speedIn:  2000, 
		    speedOut: 500, 
		    easeIn:  'bounceout', 
		    easeOut: 'backin', 
		    delay:   -2000,
		    timeout: 0, 
		    startingSlide: 1 
		});
	}
	else if ("cyc_bouncein"==effect.toLowerCase())
	{
	
		$('#calendar_container').cycle({ 
     		    fx:     'zoom', 
		    delay:  -4000, 
		    timeout: 0, 
		    startingSlide: 1 
		});	
	}
	else if ("cyc_bounceright"==effect.toLowerCase())
	{
		$('#calendar_container').cycle({ 
		    fx:      'slideX', 
		    speedIn:  2000, 
		    speedOut: 500, 
		    easeIn:  'bounceout', 
		    easeOut: 'backin', 
		    delay:   -2000,
		    timeout: 0, 
		    startingSlide: 1 
		});
	}
	else if ("cyc_curtainx"==effect.toLowerCase()) 
	{
		$('#calendar_container').cycle({ 
		    fx:      'curtainX', 
		    speedIn:  2000, 
		    speedOut: 500, 
		    easeIn:  'bounceout', 
		    easeOut: 'backin', 
		    delay:   -2000,
		    timeout: 0, 
		    startingSlide: 1 
		});
	}
	else if ("cyc_fade"==effect.toLowerCase()) 
	{
		$('#calendar_container').cycle({ 
		    fx:      'fade', 
		    delay:   -2000,
		    timeout: 0, 
		    startingSlide: 1 
		});
	}
}
