var Emotions = {
    init: function()
    {
        if($('#priorities').length)
        {
            $('#priorities a').each(function() 
            {        
                $(this).css({'cursor':'pointer'});       
                $(this).bind('click',  function(e){Emotions.vote($(this).attr('id'), $(this).parent().parent().attr('rel')); e.preventDefault();});
            });   
        }
    },
    
    vote: function(strEmotion, nArticleID) 
    {  
        if(nArticleID != '')
        {
            //alert(strRootPath+'articles/emotions/'+strEmotion+'/'+nArticleID+'.html');
            if(nArticleID.match(/^[0-9]+/))
            {
                $.ajax({
                    cache: false,
                    url: strRootPath+'articles/emotions/'+strEmotion+'/'+nArticleID+'.html',
                    success: function(data) {
                        if(data != '')
                        {
                            //alert(data);
                            $('#priorities').replaceWith(data);
                        }
                    }
                });
            }
            else if(nArticleID == 'no')
            {
                CFacebook.login();
            }
        }
    } 
};
