function updateEmeralds(type, amount)
{
    var emeraldDiv = $('#sidebar_emerald_total');
    var oldAmount = parseInt($(emeraldDiv).html());
    
    if(type == 'add' && amount > 0)
    {
        $(emeraldDiv).html(oldAmount + amount);
    }
    else if(amount > 0)
    {
        $(emeraldDiv).html(oldAmount - amount);
    }
}

function previewRewardLink()
{
    var token = $('#reward-link-token').val();
    var next = $('#reward-link-redirect').val();
    var link = 'http://emeraldactivities.com/claim_reward.php?reward=' + token;
    
    if(next != '')
    {
        link += '&next=' + escape(escape(next));
    }
    
    $('#reward-link-preview').html(link);
}

