var webinarsCount = document.getElementById("totalWebinars").innerHTML;
var currentWebinar = 1;

function changeWebinar(direction)
{
	switch (direction){
		case 'previous':
			currentWebinar++;
		break;
		case 'next':
			currentWebinar--;
		break;
	}
	// sanity check
	if (currentWebinar < 1)
	{
		currentWebinar = 1;
	}
	if (currentWebinar >= webinarsCount)
	{
		currentWebinar = webinarsCount - 1;
	}
	displayCurrentWebinar();
}

/* Displays the selected webinar
	* It displays the data from the webinars array at the currentWebinar index
*/
function displayCurrentWebinar()
{
	//hide previous webinar
	var previousWebinar = currentWebinar - 1;

	//show current webinar
	document.getElementById("webinarBox").innerHTML = document.getElementById("webinar_" + currentWebinar).innerHTML;

	//change class of placehorder
	placeHolder = document.getElementById("webinarPlaceholder");
	if (placeHolder.className == 'topWebinarBox')
	{
		placeHolder.className = 'topWebinarBoxNoBg';
	}
	//this is for shorter content
	{
		placeHolder.className = 'topWebinarBoxNoBg webinarPlaceholderShort';
	}

	// disable or enable navigation buttons
	if (currentWebinar <= 1)
	{
		dojo.addClass('webinarButtonNext', 'nextDisabled');
	}
	else
	{
		dojo.removeClass('webinarButtonNext', 'nextDisabled');
	}

	if (currentWebinar >= webinarsCount - 1)
	{
		dojo.addClass('webinarButtonPrevious', 'previousDisabled');
	}
	else
	{
		dojo.removeClass('webinarButtonPrevious', 'previousDisabled');
	}
}

function loadWebinar ()
{
	//show current webinar
	document.getElementById("webinarBox").innerHTML = document.getElementById("webinar_1").innerHTML;
}

dojo.addOnLoad(function(){
	loadWebinar();
});
