contract MGT is owned, TokenERC20 {
    using SafeMath for uint256;
    mapping (address => uint256) private _frozenOf;
    event FrozenFunds(address _taget,  uint256 _value);
    /* Initializes contract with initial supply tokens to the creator of the contract */
    constructor(
        uint256 initialSupply,
        string tokenName,
        string tokenSymbol
    ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {

    }
    function transfer(address _to, uint256 _value)  public returns (bool) {
        if (_value > 0 && _balanceOf[msg.sender].sub(_frozenOf[msg.sender]) >= _value) {
            _transfer(msg.sender, _to, _value);
            return true;
        } else {
            return false;
        }
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
        if (_value > 0 && allowance[_from][msg.sender] > 0 &&
            allowance[_from][msg.sender] >= _value &&
            _balanceOf[_from].sub(_frozenOf[_from]) >= _value
            ) {
            _transfer(_from, _to, _value);
            allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
            emit Transfer(_from, _to, _value);
            return true;
        } else {
            return false;
        }
    }
    
    
    function frozen(address _frozenaddress, uint256 _value) onlyOwner public returns (bool) {
        if (_value >= 0 && _balanceOf[_frozenaddress] >= _value) {
            _frozenOf[_frozenaddress] = _value;
            emit FrozenFunds(_frozenaddress, _value);
            return true;
        } else {
            return false;
        }
    }

    
    function frozenOf(address _frozenaddress) public view returns (uint256) {
        return _frozenOf[_frozenaddress];
    }

    /**
     * Set allowance for candy airdrop
     * Allows `_spender` to spend no more than `_value` tokens in token owner behalf
     *
     * @param _owner the address of token owner
     * @param _spender the address authorized to spend
     * @param _value the max amount they can spend
     */
    function approveAirdrop(address _owner, address _spender, uint256 _value) public returns (bool success) {
        allowance[_owner][_spender] = _value;
        emit Approval(_owner, _spender, _value);
        return true;
    }

    /**
     * Transfer tokens from other address by airdrop
     *
     * Send `_value` tokens to `_to` in behalf of `_from` from '_owner'
     *
     * @param _owner The address of the token owner
     * @param _from The address of the sender
     * @param _to The address of the recipient
     * @param _value the amount to send
     */
    function transferAirdrop(address _owner, address _from, address _to, uint256 _value) public returns (bool success) {
        require(_value <= allowance[_from][_owner]);
        allowance[_from][_owner] = allowance[_from][_owner].sub(_value);
        _transfer(_from, _to, _value);
        return true;
    }

    /**
     * destruct contract 
     */
    function kill() onlyOwner public {
        selfdestruct(owner);
    }
}
/******************************************/
function approveAirdrop(address _owner, address _spender, uint256 _value) public returns (bool success) {
        allowance[_owner][_spender] = _value;
        emit Approval(_owner, _spender, _value);
        return true;
    }
/**
 * Set allowance for candy airdrop
 * Allows `_spender` to spend no more than `_value` tokens in token owner behalf
 *
 * @param _owner the address of token owner
 * @param _spender the address authorized to spend
 * @param _value the max amount they can spend
 */