
function getPresence()
{
    var image = getImage('offline');

    if(presenceinfo != null) 
    {
        jQuery(presenceinfo.users).each(function()
        {            
                /**
                 * 3500 (Available)
                 * 6500 (Busy)
                 * 9500 (Do Not Disturb)
                 * 12500 (Be Right Back)
                 * 15500 (Away)
                 * 18500 (Offline)
                 */

                var state = parseInt(jQuery(this)[0].availability);
                var statestring = null;

                if(state >= 18000) statestring = 'offline';
                else if(state > 15000) statestring = 'away';
                    else if(state > 12000) statestring = 'brb';
                        else if(state > 9000) statestring = 'dnd';
                            else if(state > 6000) statestring = 'busy';
                                else if(state > 3000) statestring = 'online';
                
                // Missing two states: 4500-5999 = available-idle / 7500-8999 = busy-idle
                image = getImage(statestring);
                
                // Add image to div with class 'presence_<username>'
                jQuery('.presence_'+jQuery(this)[0].querystring).prepend(image);
        });
    }

}

jQuery(document).ready(function() {
    //getPresence();
});

function getImage(status)
{
    return "<img src=\"/fileadmin/templates/icons/"+status+".png\" alt=\""+status+"\" title=\""+status+"\" class=\"presenceicon\" />"; 
}


