
		
	/**
	 * mayaFish.modules.comments
	 * 
	 * @author krish
	 */

	if (!mayaFish.modules.comments)
	{
		mayaFish.modules.comments = 
		{
            text:
            {
                errorRequireLogin: 'Please log in!',
                errorAlreadyRated: 'You have already voted for this entry!'
            },
			rate: function( commentId, value )
            {
                mayaFish.$id('commentRatingMessage_'+commentId).innerHTML = mayaFish.translations('common','please_wait');
                mayaFish.$id('commentRatingMessage_'+commentId).style.display = "block";
                mayaFish.httpRequest({
                                        url: '/comments/rate',
                                        params: {commentId: commentId, value: value},
                                        method: 'post',
                                        parse:  'text',	
                                        onSuccess: function (response) 
                                        {
                                            var _data = response.split('||');
                                            mayaFish.$id('commentRating_'+commentId).innerHTML = _data[1];
                                            
                                            if( _data[0] != 0 )
                                            {
                                                mayaFish.modules.comments.showMessage(_data[0]);
                                            }
                                        }
                                    });
            },
            showMessage: function(errorCode) 
            {
                var message;
                switch( parseInt(errorCode) )
                {
                    case 1:message = mayaFish.modules.comments.text.errorRequireLogin;break;
                    case 2:message = mayaFish.modules.comments.text.errorAlreadyRated;break;    
                }
                
                if( message )
                {
                    mayaFish.ui.alert(message);
                }
            }
            
        }
    }


