var tabs=Array('All','Video','Audio','Text','Scripture','Authors','Albums');var functionQueue={queue:[],blocked:false,add:function(fname,fargs){this.queue.push([fname,fargs]);},done:function(){hideLoader();this.blocked=false;},callNext:function(){if(this.blocked==false&&this.queue.length>0){this.blocked=true;showLoader();var next=this.queue.pop();if(next[1].length==0){next[0]();}else if(next[1].length==1){next[0](next[1][0]);}else if(next[1].length==2){next[0](next[1][0],next[1][1]);}else if(next[1].length==3){next[0](next[1][0],next[1][1],next[1][2]);}else if(next[1].length==4){next[0](next[1][0],next[1][1],next[1][2],next[1][3]);}}
setTimeout("functionQueue.callNext()",100);}};functionQueue.callNext();var tabDefinitions={tabs:{'All':{searchType:'media',container:'#tab1',template:'All<span id="count_all">({results} Results)</span>',otherParams:{av:'',nd:'',t:'jn2'},tabFunction:generateMediaTab,contentFunction:loadMediaTab,itemsPerPage:9,hidden:false},'Video':{searchType:'media',container:'#tab2',template:'Video<span id="count_video">({results})</span>',otherParams:{av:'video',nd:'',t:'jn2'},tabFunction:generateMediaTab,contentFunction:loadMediaTab,itemsPerPage:9,hidden:false},'Audio':{searchType:'media',container:'#tab3',template:'Audio<span id="count_audio">({results})</span>',otherParams:{av:'audio',nd:'',t:'jn2'},tabFunction:generateMediaTab,contentFunction:loadMediaTab,itemsPerPage:9,hidden:false},'Text':{searchType:'media',container:'#tab4',template:'Text<span id="count_text">({results})</span>',otherParams:{av:'text',nd:'',t:'jn2'},tabFunction:generateMediaTab,contentFunction:loadMediaTab,itemsPerPage:9,hidden:false},'Scripture':{searchType:'',container:'#tab5',template:'Scripture<span id="count_scripture">({results})</span>',otherParams:{},tabFunction:null,contentFunction:loadBibleTab,itemsPerPage:7,hidden:false},'Authors':{searchType:'author',container:'#tab6',template:'Authors<span id="count_authors">({results})</span>',otherParams:{t:'jsn',nd:''},tabFunction:null,contentFunction:loadMediaTab,itemsPerPage:9,hidden:false},'Albums':{searchType:'album',container:'#tab7',template:'Albums<span id="count_albums">({results})</span>',otherParams:{t:'jsn',nd:''},tabFunction:null,contentFunction:loadMediaTab,itemsPerPage:9,hidden:false},'AuthorDrilldown':{searchType:'album',contentHeaderType:'author',container:'#tab6',template:'By This Author',otherParams:{t:'jsn',nd:''},tabFunction:null,contentFunction:loadMediaTab,itemsPerPage:6,hidden:true,subsearch:""},'AlbumDrilldown':{searchType:'media',contentHeaderType:'album',container:'#tab7',template:'In This Album',otherParams:{av:'',nd:'',t:'jn2'},tabFunction:null,contentFunction:loadMediaTab,itemsPerPage:6,hidden:true,subsearch:""}},iterator:0,currentTab:null,selectedTab:'All',searchString:'',tabsLoaded:false};$(document).ready(function(){$('.sidebar #authors_az').prev().hide();$('#mute').css('opacity',1);$('#mute').click(function(){$('#volume_bar').toggleClass('mute_color');});$.historyInit(historyChangedCallback);if(window.location.hash=='')
newHashState({page:'search',searchString:$('#search_field').val(),tab:tabDefinitions.selectedTab});if(get_param('ls')){var hash=window.location.hash;if(hash.substr(0,1)=='#')hash=hash.substr(1);var hash=hash.split(';');var oth_ls_exists=false;for(var i=0;i<hash.length;i++){var keyval=hash[i].split(':');if(keyval[0]=='oth.ls'){oth_ls_exists=true;break;}}
if(!oth_ls_exists)
newHashState({page:'search',searchString:'','oth.ls':get_param('ls'),tab:'Authors'});}
$('#play_again').click(function(){$('#more_in_series').hide();mediaport.play();showControlBar();});if(get_param('cat')!=''){var cat=unescape(get_param('cat'));for(var i in tabDefinitions.tabs){tabDefinitions.tabs[i].otherParams['cat']=cat;}
$('.menu li a').removeClass('current');$('#menu_'+cat.replace(" ","_")).addClass('current');}
$('form').submit(function(){delete tabDefinitions.tabs['Authors'].otherParams.ls;tabDefinitions.tabsLoaded=false;newHashState({page:'search',searchString:$('#search_field').val(),tab:tabDefinitions.selectedTab});return false;});$('#tab_menu li').click(function(){$('#tab_menu li').removeClass('current');$(this).addClass('current');var tabID=$(this).attr('id').substring(3);updateHashState({p:1,tab:tabs[tabID-1]});});$('#next_pages li').click(function(){updateHashState({p:parseInt($(this).text(),10)});});$('#back').click(function(){updateHashState({p:parseInt($('#next_pages .page_current').text(),10)-1});});$('#next').click(function(){updateHashState({p:parseInt($('#next_pages .page_current').text(),10)+1});});$("#btn_details_view").click(function(){if($('#search_media').hasClass('details_view')){$('#search_media').removeClass('details_view');$('#media_container').removeClass('details_view_reset_margin');if($('#media_container a img').length==0)
updateHashState({d:(new Date()).getMilliseconds()});}else{$('#search_media').addClass('details_view');$('#media_container').addClass('details_view_reset_margin');}});});function iclFileLoaded(){$('#more_in_series').hide();showControlBar();}
function iclFileCompleted(){hideControlBar();$('#more_in_series').show();}
function updateTabs(searchString){tabDefinitions.tabsLoaded=true;tabDefinitions.searchString=searchString;var i=0;var hasRecursed=false;for(var j in tabDefinitions.tabs){if(i==tabDefinitions.iterator){tabDefinitions.currentTab=j;tabDefinitions.iterator=++i;if(tabDefinitions.tabs[j].tabFunction!=null&&tabDefinitions.tabs[j].hidden==false){functionQueue.add(tabDefinitions.tabs[j].tabFunction,[]);hasRecursed=true;break;}}
else
i++;}
if(!hasRecursed)tabDefinitions.iterator=0;}
function generateMediaTab(){var jsonURL="http://service.ichristianlife.com/"+tabDefinitions.tabs[tabDefinitions.currentTab].searchType+"/search/";var paramObj={'cnv_url':jsonURL};for(var i in tabDefinitions.tabs[tabDefinitions.currentTab].otherParams){paramObj[i]=tabDefinitions.tabs[tabDefinitions.currentTab].otherParams[i];}
paramObj['s']=tabDefinitions.searchString;ajax_proxy(paramObj,{dataType:"json",type:'POST',success:function(data){var h=tabDefinitions.tabs[tabDefinitions.currentTab].template.replace(/\{results\}/,data.item_count);$(tabDefinitions.tabs[tabDefinitions.currentTab].container).html(h);functionQueue.done();updateTabs(tabDefinitions.searchString);}});}
function loadMediaTab(){showLoader();var selectedPage=parseInt(tabDefinitions.tabs[tabDefinitions.selectedTab].otherParams.p,10);var itemsPerPage=tabDefinitions.tabs[tabDefinitions.selectedTab].itemsPerPage;var jsonURL="http://service.ichristianlife.com/"+tabDefinitions.tabs[tabDefinitions.selectedTab].searchType+"/search/?";var paramObj={'cnv_url':jsonURL};for(var i in tabDefinitions.tabs[tabDefinitions.selectedTab].otherParams){paramObj[i]=tabDefinitions.tabs[tabDefinitions.selectedTab].otherParams[i];}
paramObj['p']=(itemsPerPage*selectedPage)-itemsPerPage+1;paramObj['s']=(typeof(tabDefinitions.tabs[tabDefinitions.selectedTab].subsearch)=="string")?tabDefinitions.tabs[tabDefinitions.selectedTab].subsearch:tabDefinitions.searchString;ajax_proxy(paramObj,{dataType:"json",type:'POST',error:function(xhr,textstatus,errorthrown){functionQueue.done();},success:function(data){$('#media_container').empty();var totalCount=parseInt(data.item_count,10);updatePagination(selectedPage,itemsPerPage,totalCount);var html='';if(typeof(data.items)=="undefined"||data.items.length==0)
html+='<div id="no_results">There are no results found for your search</div>';else{var numItems=0;for(var i in data.items){var e=data.items[i];if((numItems==0)&&typeof(tabDefinitions.tabs[tabDefinitions.selectedTab].contentHeaderType)=="string"){if(tabDefinitions.tabs[tabDefinitions.selectedTab].contentHeaderType=='album'){var auth=e.author.replace(/ /gi,"_").toLowerCase();var alb1=e.collection.replace(/ /gi,"_").toLowerCase();var alb2=e.collection.replace(/ /gi,"-").toLowerCase();var type=(e.video=='true')?'video':(e.audio=='true')?'audio':'text';html+='<div id="author_full_description">';html+='<img src="http://www.ichristianlife.com/images/icl2/english/'+auth+'/'+alb1+'/thumbnail/'+alb2+'.jpg" />';html+='<div><h5>'+e.collection+'<div class="media_type_'+type+'"></div></h5><p></p></div></div>';ajax_proxy({'cnv_url':'http://service.ichristianlife.com/album/search/?','t':'jsn','s':e.collection,'nd':''},{dataType:"json",type:'POST',success:function(data){$("#author_full_description p").html(data.items[0].background);}});}
else if(tabDefinitions.tabs[tabDefinitions.selectedTab].contentHeaderType=='author'){var auth=e.author_ls.replace(/_/gi," ");html+='<div id="author_full_description">';html+='<img src="http://www.ichristianlife.com/images/icl2/authors/'+e.author_ls+'/thumbnail/'+e.author_ls+'.jpg" />';html+='<div id="bg_album_description">';html+='<h5>'+auth+'<div class="media_type_author"></div></h5>';html+='<p id="alb_aut_desc"></p>';html+='</div></div>';ajax_proxy({'cnv_url':'http://service.ichristianlife.com/author/search/?','t':'jsn','s':auth,'nd':''},{dataType:"json",type:'POST',success:function(data){$("#alb_aut_desc").html(data.items[0].background);}});}}
if(tabDefinitions.tabs[tabDefinitions.selectedTab].searchType=='album'){var alb=e.album_ls.replace(/_/g,'-');var auth=e.author_ls.replace(/_/g,' ');var hashloc='page:search;searchString:;tab:AlbumDrilldown;p:1;oth.alb:'+escape(e.album_ls);var type=(e.video=='true')?'video':(e.audio=='true')?'audio':'text';html+='<a class="tab_item" href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">';if($('.list_view').length==0)
html+='<img src="http://www.ichristianlife.com/images/icl2/english/'+e.author_ls+'/'+e.album_ls+'/thumbnail/'+alb+'.jpg" />';html+='<h5>'+e.album+'</h5>';html+='<p>'+e.description+'</p>';html+='<div class="media_type_'+type+'"></div>';html+='<h3>by <span style="text-transform:capitalize; font-weight:bold;">'+auth+'</span></h3></a>';}
else if(tabDefinitions.tabs[tabDefinitions.selectedTab].searchType=='author'){var auth=e.author_ls.replace(/_/g,' ');var hashloc='page:search;searchString:;tab:AuthorDrilldown;p:1;oth.aut:'+escape(e.author_ls);html+='<a class="tab_item" href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">';if($('.list_view').length==0)
html+='<img src="http://www.ichristianlife.com/images/icl2/authors/'+e.author_ls+'/thumbnail/'+e.author_ls+'.jpg" />';html+='<h5>'+auth+'</h5>';html+='<p>'+e.description+'</p>';html+='<div class="media_type_author"></div></a>';}
else{if(e.media_type=="text"){var auth=e.author.substr(0,15).replace(/ /gi,"_");var alb=e.collection.substr(0,15).replace(/ /gi,"_");var title=e.name.substr(0,20).replace(/ /gi,"_");html+=(e.collection=='Action')?'<a class="tab_item" href="http://www.ichristianlife.com/'+auth+'__'+alb+'__'+title+'">':'<a class="tab_item" href="http://www.ichristianlife.com/t__'+auth+'__'+alb+'__'+title+'">';}
else{var hashloc='page:player;media:'+escape(e.name);html+='<a class="tab_item" href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">';}
if(!$('#search_media').hasClass('details_view'))
html+='<img src="'+e.thumbnail+'" />';html+='<h5>'+e.name+'</h5>';html+='<p class="media_desc_p">'+e.description+'</p>';html+='<h3>by '+e.author+'</h3>';html+='<div class="media_type_'+e.media_type+'"></div>';html+='<div class="additional_info"><p class="short_description">';html+=(e.description.length>75)?e.description.substr(0,75)+'...</p>':e.description+'</p>';var h3=(e.collection.length>=20)?'<h3 class="double_line_smush">':'<h3>';html+=h3+'<span>Album:</span> '+e.collection+'</h3>';html+=h3+'<span>Track #:</span> '+parseInt(e.track,10)+'</h3>';html+=h3+'<span>Date:</span> '+e.media_date+'</h3>';html+='</div></a>';}
if(++numItems==itemsPerPage)break;}}
$('#media_container').html(html).fadeIn();functionQueue.done();hideLoader();}});}
function loadBibleTab(){showLoader();$('#media_container').hide().empty();var selectedPage=tabDefinitions.tabs[tabDefinitions.selectedTab].otherParams.p
var itemsPerPage=tabDefinitions.tabs[tabDefinitions.selectedTab].itemsPerPage;var paramObj={'cnv_url':"http://churchfinder.ichristianlife.com/bible/bible_search.php5",'keywd':($('#search_field').val())?$('#search_field').val():(get_param('cat'))?unescape(get_param('cat')):'jesus'};ajax_proxy(paramObj,{dataType:"json",type:'POST',success:function(data){var totalCount=data.length;updatePagination(selectedPage,itemsPerPage,totalCount);var sPages=[''];for(var j=0;data!=null&&j<totalCount;j++){if((j>0)&&(j%7)==0)
sPages.push('');var i=data[j];var scriptureFieldValueList=paramObj['keywd'].split(' ');var specialWordBiblePassage=i.passage;for(var k=0;k<scriptureFieldValueList.length;k++){var sRegExInput=new RegExp(scriptureFieldValueList[k],"gi");specialWordBiblePassage=specialWordBiblePassage.replace(sRegExInput,'<strong>$&</strong>');}
sPages[sPages.length-1]+='<dl><a href="http://www.ichristianlife.com/site/PageServer?pagename=gmo__action__bible&bk=';sPages[sPages.length-1]+=i.book+'&ch='+i.chapter+'"><dt>'+specialWordBiblePassage+'</dt>';sPages[sPages.length-1]+='<dd><b>'+i.book+" "+i.chapter+":"+i.line+"</b></dd></a></dl>";}
var html='';for(var i=0;i<sPages.length;i++){html+='<div id="scripturePage'+(i+1)+'" class="scripturePage" style="display:none">'+sPages[i]+'</div>';}
$('#media_container').html(html).show();$('#scripturePage'+selectedPage).show();functionQueue.done();hideLoader();}});}
function play_media(media_name){showLoader();destroyPlayer();var jsonURL="http://service.ichristianlife.com/media/search/";var paramObj={'cnv_url':jsonURL,'t':'jn2','s':media_name,'nd':'','r':'200'};ajax_proxy(paramObj,{dataType:"json",type:'POST',error:function(xhr,textstatus,errorthrown){functionQueue.done();hideLoader();},success:function(data){if(data==null||!data){console.log('No data in JSON response!  Wait 1 second and recall function...');setTimeout("play_media("+media_name+");",1000);}
else{var origURL=unescape(this.data.substr(this.data.indexOf('url')+4));var origParamsArr=origURL.substr(origURL.indexOf('?')+1).split('&');var origParams={};for(var i=0;i<origParamsArr.length;i++){var keyval=origParamsArr[i].split('=');if(keyval.length>1)
origParams[keyval[0]]=keyval[1].replace(/\+/g,' ');}
var e={};for(var i in data.items){if(data.items[i].name.toLowerCase()==origParams.s.toLowerCase()){e=data.items[i];break;}}
if(e.media_type=='audio'){var authorMedia=e.author.toLowerCase().replace(/ /gi,"_");var albumMedia=e.collection.toLowerCase().replace(/ /gi,"_");var albumMediaDashes=e.collection.toLowerCase().replace(/ /gi,"-");var icon=authorMedia+'/'+albumMedia+'/thumbnail/'+albumMediaDashes+'.jpg';$('#video_audio').addClass('audio_player');$('#audio_album').html('<img src="http://www.ichristianlife.com/images/icl2/english/'+icon+'" />').show();}
else if(e.media_type=='video'){$('#video_audio').removeClass('audio_player');$('#audio_album').hide().empty();}
else
console.log('AN ERROR OCCURRED... MEDIA TYPE IS TEXT, this should have been redirected elsewhere: '+e.file);$('#video_audio h1').text(e.name);$('#h1_icon').remove();$('#video_audio h1').before('<div id="h1_icon" class=\"media_type_'+e.media_type+'\"></div>');$('#media_description span, #media_date span, #media_track span').empty();$('#media_description span').text(e.description);$('#media_date span').text(e.media_date);$('#media_track span').text(parseInt(e.track,10));var hashloc='page:search;tab:AuthorDrilldown;p:1;oth.aut:'+escape(e.author);var h='by <a href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">'+e.author+'</a>';h+='<img id="divider" src="../images/icl3/icon_divider.gif" alt="" width="30" height="8" />';hashloc='page:search;tab:AlbumDrilldown;p:1;oth.alb:'+escape(e.collection);h+='Album: <a href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">'+e.collection+'</a>';$('#video_audio h2').html(h);loadMedia(e.file,e.name,e.media_type);relatedMedia(e.name,e.name+' '+e.description+' '+e.collection);moreInSeries(e.collection,parseInt(e.track,10));functionQueue.done();hideLoader();}}});}
function loadMedia(uri,name,type){var c=($('#video_audio').hasClass('audio_player'))?{file:uri,videoWidth:0,videoHeight:0}:{file:uri,videoWidth:640,videoHeight:360};mediaport_jQuery(document).ready(function(){mediaport.gamt_measure.config.account_id='UA-3614417-4';mediaport.config.playerPath='http://mediacdn.ichristianlife.com/player/mediaplayer-4-2/player.swf';mediaport.init({config:c});});}
function destroyPlayer(){mediaport_jQuery(document).ready(function(){mediaport.pause();deconcept.SWFObjectUtil.cleanupSWFs();mediaport.simple_ui_destroy_dynamic;$('#mediaport_simple_ui').empty();});}
function updatePagination(selectedPage,itemsPerPage,totalCount){var lastPage=Math.ceil(totalCount/itemsPerPage);$('#next_pages li').removeClass('page_current').show();if(lastPage<=7){$('#ellipses_first, #ellipses_last, #next_pages li').hide();$('#page_1').show();for(var i=2;i<=lastPage;i++){$('#page_'+i).text(i).show();}
$('#page_'+selectedPage).addClass('page_current');}
else if(selectedPage<=4){$('#ellipses_first').hide();for(var j=2;j<=6;j++){$('#page_'+j).text(j);}
$('#page_7').text(lastPage).show();$('#page_'+selectedPage).addClass('page_current');$('#ellipses_last').show();}
else if(selectedPage>(lastPage-4)){$('#ellipses_first').show();for(var j=2;j<=6;j++){$('#page_'+j).text(lastPage+j-7);}
$('#page_7').text(lastPage).show();$('#page_'+(selectedPage-lastPage+7)).addClass('page_current');$('#ellipses_last').hide();}
else{$('#ellipses_first, #ellipses_last').show();for(var j=2;j<=6;j++){$('#page_'+j).text(selectedPage+j-4);}
$('#page_7').text(lastPage).show();$('#page_4').addClass('page_current');}
(selectedPage>1)?$('#media_paging #back').show():$('#media_paging #back').hide();(selectedPage<lastPage)?$('#media_paging #next').show():$('#media_paging #next').hide();var first=(itemsPerPage*selectedPage)-itemsPerPage+1;var last=Math.min(itemsPerPage*selectedPage,totalCount);$('#next_pages #currentlyDisplayed').text(first+'-'+last+' of '+totalCount);}
function unsetSelectedPage(){for(var i in tabDefinitions.tabs){if(typeof(tabDefinitions.tabs[i].otherParams.p)!="undefined")
delete tabDefinitions.tabs[i].otherParams.p;}}
function ieLoadHash(hash){if($.browser.msie){$.historyLoad(hash);return false;}}
function newHashState(state){var hashstr='';if(typeof(state)=='string')hashstr=state;else{var tempArr=[];for(var i in state){tempArr.push(escape(i)+':'+escape(state[i]));}
hashstr=tempArr.join(';');}
window.location.hash=hashstr;ieLoadHash(hashstr);}
function updateHashState(state){var hash=window.location.hash;if(hash.substr(0,1)=='#')hash=hash.substr(1);hash=hash.split(';');var stateObj={};for(var i=0;i<hash.length;i++){var keyval=hash[i].split(':');if(keyval[0].substr(0,4)!='oth.')
stateObj[keyval[0]]=keyval[1];}
for(var i in state){stateObj[i]=state[i];}
newHashState(stateObj);}
function historyChangedCallback(hash){functionQueue.add(hash_handler,[hash]);}
function hash_handler(hash){var hash=hash.split(';');var stateObj={};for(var i=0;i<hash.length;i++){var keyval=hash[i].split(':');stateObj[keyval[0]]=unescape(keyval[1]);}
if(stateObj.page=='player'){if(typeof(stateObj.media)=="undefined"){newHashState({page:'search',searchString:$('#search_field').val(),tab:tabDefinitions.selectedTab});}else{$('#media').hide();$('#more_in_series').hide();$('#video_audio').show();play_media(stateObj.media);}}
else{$('#video_audio').hide();destroyPlayer();$('#media_container').hide();unsetSelectedPage();$('#media').show();if(typeof(stateObj.searchString)!="undefined"){$('#search_field').val(stateObj.searchString);tabDefinitions.searchString=stateObj.searchString;}
if(typeof(stateObj.tab)!="undefined")tabDefinitions.selectedTab=stateObj.tab;if(typeof(stateObj.subsearch)!="undefined")tabDefinitions.tabs[tabDefinitions.selectedTab].subsearch=stateObj.subsearch;if(!tabDefinitions.tabsLoaded)
updateTabs(tabDefinitions.searchString);for(var i in stateObj){if(i.substr(0,4)=='oth.')
tabDefinitions.tabs[tabDefinitions.selectedTab].otherParams[i.substr(4)]=stateObj[i];}
for(var j=0;j<tabs.length;j++){if(tabs[j]==tabDefinitions.selectedTab){$('#tab_menu li').removeClass('current');$('#tab'+(j+1)).addClass('current');break;}}
tabDefinitions.tabs[tabDefinitions.selectedTab].otherParams.p=(typeof(stateObj.p)=="undefined")?1:stateObj.p;if(tabDefinitions.tabs[tabDefinitions.selectedTab].contentFunction!=null)
tabDefinitions.tabs[tabDefinitions.selectedTab].contentFunction();}}
function relatedMedia(current,related){$('#featured_media div').hide().empty();var r=related.replace(/[.!?:;&'"]/g,'').toLowerCase().split(' ');var wordList=new Array();var commonWords={'the':'the','of':'of','and':'and','a':'a','to':'to','in':'in','is':'is','you':'you','that':'that','it':'it','he':'he','was':'was','for':'for','on':'on','are':'are','as':'as','with':'with','his':'his','they':'they','i':'i','at':'at','be':'be','this':'this','have':'have','from':'from','or':'or','one':'one','had':'had','by':'by','word':'word','but':'but','not':'not','what':'what','all':'all','were':'were','we':'we','when':'when','your':'your','can':'can','said':'said','there':'there','use':'use','an':'an','each':'each','which':'which','she':'she','do':'do','how':'how','their':'their','if':'if','will':'will','up':'up','other':'other','about':'about','out':'out','many':'many','then':'then','them':'them','these':'these','so':'so','some':'some','her':'her','would':'would','make':'make','like':'like','him':'him','into':'into','time':'time','has':'has','look':'look','two':'two','more':'more','write':'write','go':'go','see':'see','number':'number','no':'no','way':'way','could':'could','people':'people','my':'my','than':'than','first':'first','water':'water','been':'been','call':'call','who':'who','oil':'oil','its':'its','now':'now','find':'find','long':'long','down':'down','day':'day','did':'did','get':'get','come':'come','made':'made','may':'may','part':'part'};for(var i=0;i<r.length;i++){if(commonWords[r[i]]==null){wordList.push(r[i]);}}
var randomIndex=Math.floor(Math.random()*wordList.length);var s=wordList[randomIndex];var totalMedia=0;var jsonURL='http://service.ichristianlife.com/media/search/';ajax_proxy({'cnv_url':jsonURL,'t':'jn2','nd':'','r':'4','s':s},{dataType:"json",type:'POST',success:function(data){var html='';for(var i=0;(i<data.items.length&&totalMedia<3);i++){var e=data.items[i];if(e.name!=current){totalMedia++;if(e.media_type=="text"){var auth=e.author.substr(0,15).replace(/ /gi,"_");var alb=e.collection.substr(0,15).replace(/ /gi,"_");var title=e.name.substr(0,20).replace(/ /gi,"_");html+=(e.collection=='Action')?'<a class="tab_item" href="http://www.ichristianlife.com/'+auth+'__'+alb+'__'+title+'">':'<a class="tab_item" href="http://www.ichristianlife.com/t__'+auth+'__'+alb+'__'+title+'">';}
else{var hashloc='page:player;media:'+escape(e.name);html+='<a class="tab_item" href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">';}
html+='<img src="'+e.thumbnail+'" alt="'+e.name+'" />';html+='<h5>'+e.name+'</h5>';html+='<p>'+e.description+'</p>';html+='<div class="media_type_'+e.media_type+'"></div>';html+='<h3>by '+e.author+'</h3>';html+='</a>';}}
$('#featured_media div').html(html).fadeIn();}});}
function moreInSeries(album,currentTrack){var jsonURL='http://service.ichristianlife.com/media/search/';ajax_proxy({'cnv_url':jsonURL,'t':'jn2','r':'200','alb':album,'nd':''},{dataType:"json",type:'POST',success:function(d){var data=[];for(i in d.items){data.push(d.items[i]);}
data.sort(sortByTrack);var j=0;for(var k=0;k<data.length;k++){if(parseInt(data[k].track,10)==currentTrack){j=k+1;break;}}
if(j>0){var html='';for(var itemsShown=0;itemsShown<Math.min(3,data.length);itemsShown++){var e=data[(j+itemsShown)%data.length];var hashloc='page:player;media:'+escape(e.name);html+='<a class="tab_item" href="#'+hashloc+'" onclick="newHashState(\''+hashloc+'\');">';html+='<img src="'+e.thumbnail+'" alt="'+e.name+'" />';html+='<h5>'+e.name+'</h5>';html+='<p>'+e.collection+'</p>';html+='<p>Track: '+parseInt(e.track,10)+'</p></a>';}
$('#more_in_series #more_in_series_results').html(html);}}});}
function sortByTrack(a,b){var i=parseInt(a.track,10);var j=parseInt(b.track,10);return(j<i)?1:(i<j)?-1:0;}
function showLoader(){$('#loader, #loader_media').show();}
function hideLoader(){$('#loader, #loader_media').hide();}
function showControlBar(){$('#mediaport_simple_ui_controls_bar').show();}
function hideControlBar(){$('#mediaport_simple_ui_controls_bar').hide();}
