var kqf={cObj:[],timer:'',timerList:{},inTimer:0,filename:'feed.js',url:'',get:function(parent_id,index){if(!this.url)kqf.baseURL();if(!this.timerList[parent_id]){this.timerList[parent_id]={};this.timerList[parent_id]['index']=index;}this.timerList[parent_id]['div']=document.getElementById(parent_id);if(!this.timerList[parent_id]['div'])return false;var handleSuccess=function(o){if(o.responseText){eval('var response = '+o.responseText);if(response['feeds'].length){if((isDefined(response['time_left'])||isDefined(response['time_since'])||isDefined(response['ticker_type']))&&!kqf.timer)kqf.timer=setInterval(kqf.updateTimers,1000);if(isDefined(response['time_left'])){kqf.timerList[parent_id]['time_left']=response['time_left'];kqf.timerList[parent_id]['time_left_div']=document.getElementById('timeleft-'+parent_id);}if(isDefined(response['time_since'])){kqf.timerList[parent_id]['time_since']=response['time_since'];kqf.timerList[parent_id]['time_since_div']=document.getElementById('timesince-'+parent_id);}if(isDefined(response['ticker_type'])){itemsList=response['feeds'][0]['item'];kqf.timerList[parent_id]['feeds']=response['feeds'];kqf.timerList[parent_id]['ticker_index']=1;kqf.timerList[parent_id]['ticker_type']=response['ticker_type'];kqf.timerList[parent_id]['ticker_pause']=0;khanh.event.add(kqf.timerList[parent_id]['div'],'mouseover',function(){kqf.timerList[parent_id]['ticker_pause']=1;});khanh.event.add(kqf.timerList[parent_id]['div'],'mouseout',function(){kqf.timerList[parent_id]['ticker_pause']=0;});kqf.timerList[parent_id]['ticker_delay']=kqf.timerList[parent_id]['ticker_count']=response['ticker_delay'];}else{var itemsList='';for(var i=0;i<response['feeds'].length;i++){if(response['feeds'][i]['freshness']){if(!kqf.timerList[parent_id]['freshness'])kqf.timerList[parent_id]['freshness']=[];var pubdate=new Date(Date.parse(new Date())-response['feeds'][i]['freshness']*1000);kqf.timerList[parent_id]['freshness'].push(pubdate);}itemsList+=response['feeds'][i]['item'];}}kqf.timerList[parent_id]['div'].innerHTML=itemsList;}}};var handleFailure=function(o){if(o.responseText!==undefined)kqf.timerList[parent_id]['div'].innerHTML='<li>Transaction id: '+o.tId+'</li>'+'<li>HTTP status: '+o.status+'</li>'+'<li>Status code message: '+o.statusText+'</li>';};var callback={success:handleSuccess,failure:handleFailure};var sUrl=this.url+'feed-loader.php?'+unescape(feeds[index]['url'])+'&kqf_parent_id='+parent_id+'&kqf_index='+index;if(feeds[index]['poll']){YAHOO.util.Connect.initHeader('If-Modified-Since','Sat, 1 Jan 2000 00:00:00 GMT');YAHOO.util.Connect.initHeader('Cache-Control','no-store, no-cache, must-revalidate');YAHOO.util.Connect.initHeader('Expires','Mon, 26 Jul 1997 05:00:00 GMT');YAHOO.util.Connect.initHeader('Pragma','no-cache');}this.cObj[index]=YAHOO.util.Connect.asyncRequest('GET',sUrl,callback);var abortRef=document.getElementById('abort-'+parent_id);if(abortRef)abortRef.innerHTML='<a href="#" onclick="kqf.abort(\'' + parent_id + '\', '+index+'); return false;">'+unescape(feeds[index]['abort_message'])+'</a>';},ticker:{normal:{tocker:function(parent_id){kqf.timerList[parent_id]['ticker_count']--;if(kqf.timerList[parent_id]['ticker_count']==0){kqf.timerList[parent_id]['ticker_count']=kqf.timerList[parent_id]['ticker_delay'];kqf.timerList[parent_id]['div'].innerHTML=kqf.timerList[parent_id]['feeds'][kqf.timerList[parent_id]['ticker_index']]['item'];kqf.ticker.incIndex(parent_id);}}},fade:{opacityDefault:0.2,opacityStep:0.2,opacity:0.2,tocker:function(parent_id){kqf.timerList[parent_id]['ticker_count']--;if(kqf.timerList[parent_id]['ticker_count']==0){kqf.timerList[parent_id]['ticker_count']=kqf.timerList[parent_id]['ticker_delay'];kqf.ticker.fade.transition(parent_id,'reset');kqf.timerList[parent_id]['div'].innerHTML=kqf.timerList[parent_id]['feeds'][kqf.timerList[parent_id]['ticker_index']]['item'];kqf.timerList[parent_id]['fadeTimer']=setInterval(function(){kqf.ticker.fade.transition(parent_id,'up')},100);kqf.ticker.incIndex(parent_id);}},transition:function(parent_id,fadetype){var tickerDiv=kqf.timerList[parent_id]['div'];if(fadetype=='reset')kqf.timerList[parent_id]['opacity']=kqf.ticker.fade.opacityDefault;if(kqf.timerList[parent_id]['opacity']==0&&tickerDiv.style.visibility!='hidden')tickerDiv.style.visibility='hidden';else if(tickerDiv.style.visibility!='visible')tickerDiv.style.visibility='visible';if(window.ActiveXObject)tickerDiv.style.filter='alpha(opacity='+kqf.timerList[parent_id]['opacity']*100+')';tickerDiv.style.opacity=kqf.timerList[parent_id]['opacity'];if(fadetype=='up'){kqf.timerList[parent_id]['opacity']+=kqf.ticker.fade.opacityStep;if(kqf.timerList[parent_id]['opacity']>=1)clearInterval(kqf.timerList[parent_id]['fadeTimer']);}}},decIndex:function(parent_id){kqf.timerList[parent_id]['ticker_index']--;if(kqf.timerList[parent_id]['ticker_index']<0)kqf.timerList[parent_id]['ticker_index']=kqf.timerList[parent_id]['feeds'].length-1;},incIndex:function(parent_id){kqf.timerList[parent_id]['ticker_index']++;if(kqf.timerList[parent_id]['ticker_index']>=kqf.timerList[parent_id]['feeds'].length)kqf.timerList[parent_id]['ticker_index']=0;},prev:function(parent_id){kqf.ticker.decIndex(parent_id);kqf.ticker.decIndex(parent_id);kqf.timerList[parent_id]['ticker_count']=1;kqf.ticker.fade.tocker(parent_id);},next:function(parent_id){kqf.timerList[parent_id]['ticker_count']=1;kqf.ticker.fade.tocker(parent_id);}},updateTimers:function(){if(kqf.inTimer)return;kqf.inTimer=1;for(var parent_id in kqf.timerList){if(isDefined(kqf.timerList[parent_id]['time_left'])){kqf.timerList[parent_id]['time_left']--;if(kqf.timerList[parent_id]['time_left_div'])kqf.timerList[parent_id]['time_left_div'].innerHTML=kqf.timerList[parent_id]['time_left'];if(kqf.timerList[parent_id]['time_left']==0)kqf.get(parent_id,kqf.timerList[parent_id]['index']);}if(isDefined(kqf.timerList[parent_id]['time_since'])){kqf.timerList[parent_id]['time_since']++;if(kqf.timerList[parent_id]['time_since_div'])kqf.timerList[parent_id]['time_since_div'].innerHTML=kqf.timerList[parent_id]['time_since'];}if(isDefined(kqf.timerList[parent_id]['freshness'])){for(var i=0;i<kqf.timerList[parent_id]['freshness'].length;i++){var timesince=kqf.timerList[parent_id]['freshness'][i].timeSince();var freshness=document.getElementById('freshness-'+parent_id+'-'+i);if(freshness&&freshness.innerHTML!=timesince&&!isNaN(timesince)&&timesince>0)freshness.innerHTML=timesince;}}if(isDefined(kqf.timerList[parent_id]['ticker_count'])&&!kqf.timerList[parent_id]['ticker_pause'])kqf.ticker[kqf.timerList[parent_id]['ticker_type']].tocker(parent_id);}kqf.inTimer=0;},abort:function(parent_id,index){var status=YAHOO.util.Connect.abort(this.cObj[index]);document.getElementById(parent_id).innerHTML='<li>Transaction '+(status?'':'could not be ')+'aborted!</li>';return status;},baseURL:function(){var scripts=document.getElementsByTagName('script');for(var i=scripts.length-1;i>=0;i--){if(new RegExp(this.filename.replace(/\./g,'\.')).test(scripts[i].src)){var core=/includes\/core\.php\?dir=/;if(core.test(scripts[i].src)){this.url=scripts[i].src.replace(/&?(file|type)=.+(&|$)/g,'').replace(core,'')+'/';break;}else{this.url=scripts[i].src.replace(/[^\/]+$/,'');break;}}}}};Date.prototype.timeSince=function(newer_date){var chunks=[[60*60*24*365,'year'],[60*60*24*30,'month'],[60*60*24*7,'week'],[60*60*24,'day'],[60*60,'hour'],[60,'minute']];newer_date=(newer_date==null)?new Date():newer_date;var since=(newer_date-this)/1000;for(var i=0;i<chunks.length;i++){seconds=chunks[i][0];name=chunks[i][1];if((count=parseInt(since/seconds))!=0)break;}var output=(count==1)?'1 '+name:count+' '+name+'s';if(i+1<chunks.length){var seconds2=chunks[i+1][0];var name2=chunks[i+1][1];if((count2=parseInt((since-(seconds*count))/seconds2))!=0){output+=(count2==1)?', 1 '+name2:', '+count2+' '+name2+'s';}}return output;};