String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.isValidEmailAddress=function()
{var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;return(this!=''&&filter.test(this));}
String.prototype.isEmpty=function()
{return(''+this=='');}
Accordion=function(name,id,imagePath)
{this.name=name;this.id=id;this._imagePath=imagePath;this.toggleElement=this._getElement('toggle');this.contentElement=this._getElement('content');this._displayToggle('more');}
Accordion.prototype.hideContent=function()
{this.contentElement.slideUp('normal');this._displayToggle('more');}
Accordion.prototype.showContent=function()
{this.contentElement.slideDown('normal');this._displayToggle('hide');}
Accordion.prototype.toggle=function()
{if(this.contentElement.is(':visible'))
this.hideContent();else
this.showContent();}
Accordion.prototype._getElement=function(type)
{return jQuery("#"+this.name.replace(" ","_")+'_accordion_'+type+'_'+this.id);}
Accordion.prototype._getImage=function(name)
{return'<img src="'+this._imagePath+'/button_'+name+'.gif">';}
Accordion.prototype._displayToggle=function(name)
{this.toggleElement.html(this._getImage(name)+this.name);}
var ScheduleSearchForm=function(path,name,useAjax,imagePath){this.path=path;this.name=name;this.useAjax=useAjax;ScheduleSearchForm.forms[name]=this;this.initAutocomplete();this.contentElement=jQuery('#advanced_search_'+this.name);this.toggleElement=jQuery('#advanced_search_toggle_'+this.name);this._imagePath=imagePath;this._makeToggle('more');}
ScheduleSearchForm.prototype.$=function(name)
{return jQuery('#'+name+'_'+this.name);}
ScheduleSearchForm.prototype.submit=function(searchObject)
{searchObject=(searchObject==null)?search:searchObject;if(this.useAjax)
{sortBy=ScheduleSearchForm.getRadioButtonValue('sortBy');startDate=this.$('startDate').val();endDate=this.$('endDate').val();searchObject.runtime.populate(this.$('searchString').val(),this.$('episodeBroadcastId').val(),startDate,endDate,jQuery(".sortBy_"+this.name+":checked").val(),1,searchObject.runtime.perPage);search.display();}else
form.submit();}
ScheduleSearchForm.prototype.initAutocomplete=function(){this.$("searchString").autocomplete(this.path+"/?controller=Show&action=jquery",{});}
ScheduleSearchForm.submit=function(field)
{name=field.id.split('_')[1];ScheduleSearchForm.forms[name].submit();}
ScheduleSearchForm.getRadioButtonValue=function(name)
{return jQuery('#'+name).val();}
ScheduleSearchForm.prototype.show=function(){this.contentElement.slideDown('normal');this._updateToggle('hide');}
ScheduleSearchForm.prototype.hide=function(){this.contentElement.slideUp('normal');this._updateToggle('more');}
ScheduleSearchForm.prototype.toggle=function(){if(this.contentElement.is(':visible'))
this.hide();else
this.show();}
ScheduleSearchForm.prototype._makeToggle=function(name){this.toggleElement.html('<img id="collapsible_toggle_image_'+this.name+'" src="'+this._getImage(name)+'"><span id="toggle_'+this.name+'">'+name+' search options<span>');}
ScheduleSearchForm.prototype._updateToggle=function(name){jQuery('#collapsible_toggle_image_'+this.name).src=(this._getImage(name));jQuery('#toggle_'+this.name).html(name+' search options');}
ScheduleSearchForm.prototype._getImage=function(name){return this._imagePath+'/button_'+name+'.gif';}
ScheduleSearchForm.forms=[];ScheduleSearchRuntime=function(defaultSearchString,defaultEpisodeBroadcastId,defaultStartDate,defaultEndDate,defaultSortBy,defaultPageNumber,defaultPerPage,defaultChannel)
{this._ajaxLoaded=false;this.requestCounter=0;this.populate(defaultSearchString,defaultEpisodeBroadcastId,defaultStartDate,defaultEndDate,defaultSortBy,defaultPageNumber,defaultPerPage,defaultChannel);}
ScheduleSearchRuntime.prototype.populate=function(defaultSearchString,defaultEpisodeBroadcastId,defaultStartDate,defaultEndDate,defaultSortBy,defaultPageNumber,defaultPerPage,defaultChannel)
{this.searchString=defaultSearchString;this.episodeBroadcastId=defaultEpisodeBroadcastId;this.startDate=defaultStartDate;this.endDate=defaultEndDate;this.sortBy=defaultSortBy;this.pageNumber=defaultPageNumber;this.perPage=defaultPerPage;this.channel=defaultChannel}
var ScheduleSearch=function(path,imagePath,defaultSearchString,defaultEpisodeBroadcastId,defaultStartDate,defaultEndDate,defaultChannel)
{this.path=path;this.imagePath=imagePath;this.runtime=new ScheduleSearchRuntime(defaultSearchString,defaultEpisodeBroadcastId,defaultStartDate,defaultEndDate,'relevance',1,15,defaultChannel);}
ScheduleSearch.prototype.display=function()
{broadcastId=(this.runtime.episodeBroadcastId==null)?'':this.runtime.episodeBroadcastId;params={'searchString':this.runtime.searchString,'broadcastId':broadcastId,'startDate':this.runtime.startDate,'endDate':this.runtime.endDate,'sortBy':this.runtime.sortBy,'channel':this.runtime.channel,'pageNumber':this.runtime.pageNumber,'perPage':this.runtime.perPage,'requestCounter':this.runtime.requestCounter};this.showProgressWidget();new jQuery('#results').load(this.path+'/?controller=scheduleSearchResultSet',params,function(){ScheduleSearch.hideProgressWidget()});jQuery('#bottom').show();this.runtime.requestCounter++;}
ScheduleSearch.prototype.displayPage=function(pageNumber)
{this.runtime.pageNumber=pageNumber;this.display();}
ScheduleSearch.prototype.doAfterRender=function()
{jQuery('#bottom').hide();if(''+this.runtime.searchString!=''||''+this.runtime.episodeBroadcastId!='')
this.display();}
ScheduleSearch.prototype.handleNoResults=function()
{jQuery('#bottom').hide();}
ScheduleSearch.displayPage=function(pageNumber)
{search.displayPage(pageNumber);}
ScheduleSearch.prototype.showProgressWidget=function()
{if(jQuery('#loading_box'))
{jQuery('#loading_box').html('Performing Search...<br /><img src="'+this.imagePath+'/animation_loading.gif">');jQuery('#loading_box').fadeIn('normal');}}
ScheduleSearch.displayProgressWidget=function()
{}
ScheduleSearch.hideProgressWidget=function()
{jQuery('#loading_box').hide();jQuery('#results').fadeIn('normal');search.runtime._ajaxLoaded=true;}
