(function($){var NEG_INF=Number.NEGATIVE_INFINITY;var POS_INF=Number.POSITIVE_INFINITY;$.fn.cuteTime=function(options){var right_now=new Date().getTime();var other_time;var curr_this;if((typeof options=='object')||(options==undefined)){$.extend($.fn.cuteTime.settings,options);$.fn.cuteTime.the_selected=this;this.each(function(){curr_this=$(this);other_time=get_time_value(curr_this);curr_this.text(get_cuteness(right_now-other_time));});$.fn.cuteTime.start_cuteness();return this;}};$.cuteTime=function(options){var right_now=new Date().getTime();var other_time;var curr_this;if(typeof options=='string'){other_time=date_value(options);if(!isNaN(other_time)){return get_cuteness(right_now-other_time);}else{return'INVALID DATE/TIME FORMAT';}}
return this;};$.fn.cuteTime.settings={refresh:-1,time_ranges:[{bound:NEG_INF,cuteness:'the future!',unit_size:0},{bound:0,cuteness:'just now',unit_size:0},{bound:20*1000,cuteness:'a few seconds ago',unit_size:0},{bound:60*1000,cuteness:'a minute ago',unit_size:0},{bound:60*1000*2,cuteness:' minutes ago',unit_size:60*1000},{bound:60*1000*60,cuteness:'an hour ago',unit_size:0},{bound:60*1000*60*2,cuteness:' hours ago',unit_size:60*1000*60},{bound:60*1000*60*24,cuteness:'yesterday',unit_size:0},{bound:60*1000*60*24*2,cuteness:' days ago',unit_size:60*1000*60*24},{bound:60*1000*60*24*30,cuteness:'last month',unit_size:0},{bound:60*1000*60*24*30*2,cuteness:' months ago',unit_size:60*1000*60*24*30},{bound:60*1000*60*24*30*12,cuteness:'last year',unit_size:0},{bound:60*1000*60*24*30*12*2,cuteness:' years ago',unit_size:60*1000*60*24*30*12},{bound:POS_INF,cuteness:'a blinkle ago',unit_size:0}]};$.fn.cuteTime.start_cuteness=function(){var refresh_rate=$.fn.cuteTime.settings.refresh;if($.fn.cuteTime.process_tracker==null){if(refresh_rate>0){$.fn.cuteTime.process_tracker=setInterval("$.fn.cuteTime.update_cuteness()",refresh_rate);}}else{}
return this;};$.fn.cuteTime.update_cuteness=function(){var right_now=new Date().getTime();var curr_this;var other_time;$.fn.cuteTime.the_selected.each(function(){curr_this=$(this);other_time=get_time_value(curr_this);curr_this.text(get_cuteness(right_now-other_time));});}
$.fn.cuteTime.stop_cuteness=function(){if($.fn.cuteTime.process_tracker!=null){clearInterval($.fn.cuteTime.process_tracker);$.fn.cuteTime.process_tracker=null;}else{}
return this;};function get_cuteness(time_difference){var time_ranges=$.fn.cuteTime.settings.time_ranges;var calculated_time;var cute_time='';jQuery.each(time_ranges,function(i,timespan){if(i<time_ranges.length-1){if((time_difference>=timespan['bound'])&&(time_difference<time_ranges[i+1]['bound'])){if(timespan['unit_size']>0){calculated_time=Math.floor(time_difference/timespan['unit_size']);}else{calculated_time='';}
cute_time=calculated_time+timespan['cuteness'];return false;}}else{return false;}});if(cute_time==''){cute_time='2 pookies ago';}
return cute_time;}
function date_value(the_date){var the_value=(new Date(the_date)).valueOf();if(isNaN(the_value)){the_value=new Date(the_date.replace(/-/g," "));}
return the_value;}
function get_time_value(obj){var time_value=Number.NaN;time_string=get_cutetime_attr(obj);if(time_string!=null){time_value=date_value(time_string);}
if(isNaN(time_value)){time_string=get_object_text(obj);if(time_string!=null){time_value=date_value(time_string);}}
if(isNaN(time_value)){time_string=new Date().toString();time_value=date_value(time_string);}
set_cutetime_attr(time_string,obj);return time_value;}
function get_cutetime_attr(obj){var return_value=obj.attr('cutetime');if(return_value!=undefined){return return_value;}else{return null;}}
function set_cutetime_attr(attr,obj){obj.attr('cutetime',attr);}
function get_object_text(obj){return obj.text();}})(jQuery);