// This has been autogenerated by \lib\JSMin\jsmin.exe, do not modify manually

﻿function episodeSelector(){var SeriesList=null;var EpisodeList=null;var jsonUrl=null;var me=this;this.init=function(seriesListId,episodeListId,url){if(!document.getElementById||!document.createTextNode){return;}
jsonUrl=url;SeriesList=$(seriesListId);SeriesList.change(me.onChange);EpisodeList=$(episodeListId);EpisodeList[0].style.display='';var form=$(EpisodeList[0].form);form.submit(me.onSubmit);};this.onSubmit=function(event)
{if(SeriesList.val()!=null&&SeriesList.val()!='')
{if(EpisodeList.val()!=null&&EpisodeList.val()!='')
{window.location.pathname=applicationRoot+'tv-show/series-'+SeriesList.val()+'/episode-'+EpisodeList.val();}
else
{window.location.pathname=applicationRoot+'tv-show/series-'+SeriesList.val();}}
return false;};this.onChange=function(event)
{if(SeriesList.val()!='')
{var url=jsonUrl+SeriesList.val();$.getJSON(url,me.getJsonResults);}
else
{EpisodeList[0].disabled=true;EpisodeList[0].selectedIndex=0;}};this.getJsonResults=function(json){if(json.episodes){me.displaySuggestions(json.episodes);}};this.displaySuggestions=function(jsonRet){EpisodeList[0].disabled=true;var option1=EpisodeList[0].options[0];EpisodeList.empty();EpisodeList[0].options.add(new Option(option1.text,option1.value));for(i=0;i<jsonRet.length;i++)
{for(var key in jsonRet[i])
{EpisodeList[0].options.add(new Option(jsonRet[i][key],key,false,false));}}
EpisodeList[0].disabled=false;};};