/*
HTTP Host: static.ak.fbcdn.net
Generated: March 21st 2010 9:56:55 AM PDT
Machine: 10.16.139.101
Locale: nu_ll
Path: js/live_timer.js
*/

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/live_timer.js"]); }


var LiveTimer={restart:function(newServerTime){this.stop();this.serverTime=newServerTime;this.offset=0;this.delay=20000;this.timeout=setTimeout(function(){LiveTimer.timestamps=DOM.scry($('content'),'abbr.timestamp');LiveTimer.loop();},this.delay);},stop:function(){clearTimeout(this.timeout);},loop:function(){LiveTimer.offset+=LiveTimer.delay/1000;var bestnext=-1;LiveTimer.timestamps.each(function(timestamp){var time_created=+new Date(timestamp.getAttribute('title'))/1000;var newtime=LiveTimer.renderRelativeTime(LiveTimer.serverTime+
LiveTimer.offset,time_created);if(newtime.text){DOM.setText(timestamp,newtime.text);}
if(newtime.next!=-1&&(newtime.next<bestnext||bestnext==-1)){bestnext=newtime.next;}});if(bestnext!=-1){LiveTimer.delay=Math.max(20000,bestnext*1000);LiveTimer.timeout=setTimeout(function(){LiveTimer.loop();},LiveTimer.delay);}},renderRelativeTime:function(newtstamp,oldtstamp){var ret={text:"",next:-1};if(newtstamp-oldtstamp>(12*3600)||(new Date(newtstamp*1000).getDay()!=new Date(oldtstamp*1000).getDay())){return ret;}
var secs=newtstamp-oldtstamp,mins=Math.floor(secs/60),hrs=Math.floor(mins/60);if(mins<1){ret.next=60-secs%60;return ret;}
if(hrs<1){if(mins==1){ret.text=_tx("Hace un minuto aproximadamente");}else{ret.text=_tx("Hace {number} minutos",{number:mins});}
ret.next=60-secs%60;return ret;}
if(hrs!=11){ret.next=3600-secs%3600;}
if(hrs==1){ret.text=_tx("Hace aproximadamente una hora.");return ret;}
ret.text=_tx("Hace {number} horas",{number:hrs});return ret;}};

if (window.Bootloader) { Bootloader.done(["js\/live_timer.js"]); }