contract ERC20Token is owned, SafeMath{

    // Token Definitions
    bool public tokenState;
    string public name = "DropDeck";
    string public symbol = "DDD";
    uint256 public decimals = 8;
    uint256 public totalSupply = 380000000000000000;
    address public ico;
    bool public blockState = true;

    mapping(address => uint256) balances;
    mapping(address => bool) public userBanned;
    mapping (address => mapping (address => uint256)) allowed;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

    // @notice Initialize the Token Contract
    // @param _name Name of Token
    // @param _code Short Code of the Token
    // @param _decimals Amount of Decimals for the Token
    // @param _netSupply TotalSupply of Tokens
    function init()
        external
    returns ( bool ){
        require(tokenState == false);
        owned;
        tokenState = true;
        balances[this] = totalSupply;
        allowed[this][owner] = totalSupply;
        return true;
    }

    // @notice Transfers the token
    // @param _to Address of reciver
    // @param _value Value to be transfered
    function transfer(address _to, uint256 _value)
        public
    returns ( bool ) {
        require(tokenState == true);
        require(_to != address(0));
        require(_value <= balances[msg.sender]);
        require(blockState == false);
        require(userBanned[msg.sender] == false);
        balances[msg.sender] = sub(balances[msg.sender],_value);
        balances[_to] = add(balances[_to],_value);
        Transfer(msg.sender, _to, _value);
        return true;
    }
    // @notice Transfers the token on behalf of
    // @param _from Address of sender
    // @param _to Address of reciver
    // @param _value Value to be transfered
    function transferFrom(address _from, address _to, uint256 _value)
        public
    {
        require(_to != address(0));
        require(_value <= balances[_from]);
        require(_value <= allowed[_from][msg.sender]);

        balances[_from] = sub(balances[_from],_value);
        balances[_to] = add(balances[_to],_value);
        allowed[_from][msg.sender] = sub(allowed[_from][msg.sender],_value);
        Transfer(_from, _to, _value);

    }

    // @notice Transfers the token from owner during the ICO
    // @param _to Address of reciver
    // @param _value Value to be transfered
    function transferICO(address _to, uint256 _value)
        public
    returns ( bool ) {
        require(tokenState == true);
        require(_to != address(0));
        require(_value <= balances[this]);
        require(ico == msg.sender);
        balances[this] = sub(balances[this],_value);
        balances[_to] = add(balances[_to],_value);
        Transfer(this, _to, _value);
        return true;
    }

    // @notice Checks balance of Address
    // @param _to Address of token holder
    function balanceOf(address _owner)
        external
        constant
    returns (uint256) {
        require(tokenState == true);
        return balances[_owner];
    }

    // @notice Approves allowance for token holder
    // @param _spender Address of token holder
    // @param _value Amount of Token Transfer to approve
    function approve(address _spender, uint256 _value)
        external
    returns (bool success) {
        require(tokenState == true);
        require(_spender != address(0));
        require(msg.sender == owner);
        allowed[msg.sender][_spender] = mul(_value, 100000000);
        Approval(msg.sender, _spender, _value);
        return true;
    }

    // @notice Fetched Allowance for owner
    // @param _spender Address of token holder
    // @param _owner Amount of token owner
    function allowance(address _owner, address _spender)
        external
        constant
    returns (uint256 remaining) {
        require(tokenState == true);
        return allowed[_owner][_spender];
    }

    // @notice Allows enabling of blocking of transfer for all users
    function blockTokens()
        external
    returns (bool) {
        require(tokenState == true);
        require(msg.sender == owner);
        blockState = true;
        return true;
    }

    // @notice Allows enabling of unblocking of transfer for all users
    function unblockTokens()
        external
    returns (bool) {
        require(tokenState == true);
        require(msg.sender == owner);
        blockState = false;
        return true;
    }

    // @notice Bans an Address
    function banAddress(address _addr)
        external
    returns (bool) {
        require(tokenState == true);
        require(msg.sender == owner);
        userBanned[_addr] = true;
        return true;
    }

    // @notice Un-Bans an Address
    function unbanAddress(address _addr)
        external
    returns (bool) {
        require(tokenState == true);
        require(msg.sender == owner);
        userBanned[_addr] = false;
        return true;
    }

    function setICO(address _ico)
        external
    returns (bool) {
        require(tokenState == true);
        require(msg.sender == owner);
        ico = _ico;
        return true;
    }

    // @notice Transfers the ownership of owner
    // @param newOwner Address of the new owner
    function transferOwnership( address newOwner )
        external
    {
        require(msg.sender == owner);
        require(newOwner != address(0));

        allowed[this][owner] =  0;
        owner = newOwner;
        allowed[this][owner] =  balances[this];
        OwnerEvents(msg.sender,2);
    }


}
function init()
    external
returns ( bool ){
    require(tokenState == false);
    owned;
    tokenState = true;
    balances[this] = totalSupply;
    allowed[this][owner] = totalSupply;
    return true;
}

// @notice Initialize the Token Contract
// @param _name Name of Token
// @param _code Short Code of the Token
// @param _decimals Amount of Decimals for the Token
// @param _netSupply TotalSupply of Tokens