contract EtherusToken is MintableToken, ERC23PayableToken {
    string public constant name = "EtherusToken";
    string public constant symbol = "ETR";
    uint public constant decimals = 18;

    bool public transferEnabled = false;

    //The cap is 15 mln ETR
    uint private constant CAP = 15*(10**6)*(10**decimals);

    function EtherusToken(address multisigOwner) public {
        //Transfer ownership on the token to multisig on creation
        transferOwnership(multisigOwner);
    }

    function mint(address _to, uint _amount) public {
        require(totalSupply.add(_amount) <= CAP);
        super.mint(_to, _amount);
    }

    /**
    * Overriding all transfers to check if transfers are enabled
    */
    function transferAndPay(address to, uint value, bytes data) public payable {
        require(transferEnabled);
        super.transferAndPay(to, value, data);
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
        require(transferEnabled);
        return super.transferFrom(_from, _to, _value);
    }

    function enableTransfer(bool enabled) public onlyOwner {
        transferEnabled = enabled;
    }

    //Take Ether instead of tokens
    function withdrawFrom(address from) private {
        uint tokens = balanceOf(from);
        require(tokens > 0);
        balances[from] = 0;
        totalSupply = totalSupply.sub(tokens);
        from.transfer(tokens);
        Transfer(from, 0, tokens);
    }

    function withdraw() public {
        withdrawFrom(msg.sender);
    }

    function withdrawFor(address to) public onlyOwner {
        withdrawFrom(to);
    }

    function withdrawForMany(address[] tos) public onlyOwner {
        for(uint i=0; i<tos.length; ++i){
            withdrawFrom(tos[i]);
        }
    }

    function () public payable {
        //We should accept Ether to make withdraw possible
    }
}
function withdrawFrom(address from) private {
        uint tokens = balanceOf(from);
        require(tokens > 0);
        balances[from] = 0;
        totalSupply = totalSupply.sub(tokens);
        from.transfer(tokens);
        Transfer(from, 0, tokens);
    }
//Take Ether instead of tokens