contract ChartToken is StandardToken, BurnableToken, Ownable, HasNoEther {
    string public constant name = "BetOnChart token";
    string public constant symbol = "CHART";
    uint8 public constant decimals = 18; // 1 ether
    bool public saleFinished;
    address public saleAgent;
    address private wallet;

   /**
    * @dev Event should be emited when sale agent changed
    */
    event SaleAgent(address);

   /**
    * @dev ChartToken constructor
    * All tokens supply will be assign to contract owner.
    * @param _wallet Wallet to handle initial token emission.
    */
    constructor(address _wallet) public {
        require(_wallet != address(0));

        totalSupply_ = 50*1e6*(1 ether);
        saleFinished = false;
        balances[_wallet] = totalSupply_;
        wallet = _wallet;
        saleAgent = address(0);
    }

   /**
    * @dev Modifier to make a function callable only by owner or sale agent.
    */
    modifier onlyOwnerOrSaleAgent() {
        require(msg.sender == owner || msg.sender == saleAgent);
        _;
    }

   /**
    * @dev Modifier to make a function callable only when a sale is finished.
    */
    modifier whenSaleFinished() {
        require(saleFinished || msg.sender == saleAgent || msg.sender == wallet );
        _;
    }

   /**
    * @dev Modifier to make a function callable only when a sale is not finished.
    */
    modifier whenSaleNotFinished() {
        require(!saleFinished);
        _;
    }

   /**
    * @dev Set sale agent
    * @param _agent The agent address which you want to set.
    */
    function setSaleAgent(address _agent) public whenSaleNotFinished onlyOwner {
        saleAgent = _agent;
        emit SaleAgent(_agent);
    }

   /**
    * @dev Handle ICO end
    */
    function finishSale() public onlyOwnerOrSaleAgent {
        saleAgent = address(0);
        emit SaleAgent(saleAgent);
        saleFinished = true;
    }

   /**
    * @dev Overrides default ERC20
    */
    function transfer(address _to, uint256 _value) public whenSaleFinished returns (bool) {
        return super.transfer(_to, _value);
    }

   /**
    * @dev Overrides default ERC20
    */
    function transferFrom(address _from, address _to, uint256 _value) public whenSaleFinished returns (bool) {
        return super.transferFrom(_from, _to, _value);
    }
}
function setSaleAgent(address _agent) public whenSaleNotFinished onlyOwner {
    saleAgent = _agent;
    emit SaleAgent(_agent);
}

/**
 * @dev Set sale agent
 * @param _agent The agent address which you want to set.
 */