var move=0;
var inProgress=0;
var currentTime=';'

function changeMonth(direction)
{
	if (direction=='next')
		move++;
	if (direction=='prev')
		move--;
	if (move>2){
		move=2;
		$("#bubble").css({ display:'none' });
		$("#bubble2").css({ display:'block' });
		}
	else{
		$("#bubble").css({ display:'block' });
		$("#bubble2").css({ display:'none' });
	}
	if (move<0)
		move=0;

	var url    = 'cal.php';
	var rand   = Math.random(9999);
	var pars   = 'move=' +move;
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: showResponse} );


}
function bindCalEvent()
{
	   $("#cal tr td").not('.arrowL,.arrowR').children('a').click(function(){
				$("#date").html($("#month").html()+" "+$(this).text()+", 2010");
				currentTime = $(this).attr('title');
				if (currentTime.indexOf('*') != -1){
					currentTime='<span class="splitTimes">'+currentTime+'</span>';
				}
				if ($(this).parent().hasClass("old")){
					$("#performanceLeadIn").html('This date<br/>has passed');
					$("#seating").html('');
					$("#dayTime").html('');
				}
				else{
					$("#dayTime").html(currentTime.replace("*", "<br/>"));
					$("#performanceLeadIn").html('Performance at:');
					$("#seating").html('Seating still available');
				}
				$("#bubble").css({ display:'block' });
				$("#bubble2").css({ display:'none' });
				return false;
	})


}
function showResponse (originalRequest) 
{
	$("#cTable").html(originalRequest.responseText);
		bindCalEvent();
}


function changeOut(show)
{
	if (inProgress==0)
	{
		inProgress=1;
		if (show=='discountSection')
		{
			Effect.Fade($('waysSection'));
			Effect.Appear($('discountSection'),{ afterFinish: function() { inProgress=0;}
            });
		}
		
		else
		{
			Effect.Appear($('waysSection'));
		
			Effect.Fade($('discountSection'),{ afterFinish: function() { inProgress=0;}
            });
		}
	}
}
function openAnswer(link)
{
	$("#"+link).css({ display:'block' });
	$("#link"+link).html('<a href="javascript:closeAnswer('+link+')">Show less</a>')
}
function closeAnswer(link)
{
	$("#"+link).css({ display:'none' });
	$("#link"+link).html('<a href="javascript:openAnswer('+link+')">Show more</a>')
}
