﻿function SeasonEpisodeList(id)
{
	this.container = $('#' + id);
	this.episodeDetails = $('ul a', this.container);
	this.instantiateBasketPanels();
}

SeasonEpisodeList.prototype.renderSeason = function(Parameters)
{
	var EpisodePage = Url.format("handlers/SeasonEpisodeList.ashx");
	
	$('#ajaxLoader').show();
	
	$.ajax({
		type: "GET",
		url: EpisodePage,
		data:Parameters,
		dataType: "html",
		evalScripts: true,
		success: this.gotCallback.bind(this)
	})
}

SeasonEpisodeList.prototype.gotCallback = function(msg)
{
	$("#" + this.container.attr("id")).html(msg);
	this.instantiateBasketPanels();
	initLabels();
	if (typeof(supersleight) != 'undefined' && supersleight != null)
	{
		supersleight.init();
	}
	
	$('#ajaxLoader').hide();
}

SeasonEpisodeList.prototype.instantiateBasketPanels = function()
{
	$('.addToBasketContainer', this.container).each(function() 
	{ 
		new AddToBasketPanel(this.id, $('.InputBasketStyle', this).val());
	});
}
//TODO: have to write an object for an episode container !!!
function showSelectedEpisode(episodeIndex, BasketContainerClassName)
{
	showEpisode(episodeIndex);
	var episodenode = $('.episodesOn');
	var basketnode = $(BasketContainerClassName, episodenode)
	var sdnode = $('.radioBtns', basketnode)[0];
	if (sdnode) $('#' + sdnode.id).attr("checked","checked");
}
