contract Hubcoin is StandardToken, Pausable {

  string public constant name = 'Hubcoin';                       // Set the token name for display
  string public constant symbol = 'HUB';                                       // Set the token symbol for display
  uint8 public constant decimals = 6;                                          // Set the number of decimals for display
  uint256 public constant INITIAL_SUPPLY = 326804 * 10**uint256(decimals); // 326804 HUB specified in Grains
  uint256 public constant total_freeze_term = 86400*365;   //Freeze duration
  uint256 public constant launch_date = 1501545600;
  uint256 public constant owner_freeze_start = 1506782212;
  uint256 public constant owner_freeze_term = 3600*24;

  mapping (address => uint256) public frozenAccount;

  event FrozenFunds(address target, uint256 frozen);
  event Burn(address burner, uint256 burned);

  /**
   * @dev Hubcoin Constructor
   * Runs only on initial contract creation.
   */
  function Hubcoin() {
    totalSupply = INITIAL_SUPPLY;                               // Set the total supply
    balances[msg.sender] = INITIAL_SUPPLY;                      // Creator address is assigned all
  }

  /**
   * @dev Transfer token for a specified address when not paused
   * @param _to The address to transfer to.
   * @param _value The amount to be transferred.
   */
  function transfer(address _to, uint256 _value) whenNotPaused returns (bool) {
    freezeCheck(msg.sender, _value);

    return super.transfer(_to, _value);
  }

  /**
   * @dev Transfer tokens from one address to another when not paused
   * @param _from address The address which you want to send tokens from
   * @param _to address The address which you want to transfer to
   * @param _value uint256 the amount of tokens to be transferred
   */
  function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool) {
    freezeCheck(msg.sender, _value);

    return super.transferFrom(_from, _to, _value);
  }

  /**
   * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused.
   * @param _spender The address which will spend the funds.
   * @param _value The amount of tokens to be spent.
   */
  function approve(address _spender, uint256 _value) whenNotPaused returns (bool) {
    return super.approve(_spender, _value);
  }


  function freezeAccount(address target, uint256 freeze)  onlyOwner  {
        require(block.timestamp < (owner_freeze_start + owner_freeze_term));
        frozenAccount[target] = freeze;
        FrozenFunds(target, freeze);
  }

  function freezeCheck(address _from, uint256 _value)  returns (bool) {


    uint forbiddenPremine =  launch_date - block.timestamp + total_freeze_term;
    if (forbiddenPremine < 0) forbiddenPremine = 0;

    require(balances[_from] >= _value.add( frozenAccount[_from] * forbiddenPremine / total_freeze_term) ); // Check if the sender has enough
    return true;
  }

   function burn(uint256 _value) onlyOwner public {
    require(_value > 0);

    address burner = msg.sender;
    balances[burner] = balances[burner].sub(_value);
    totalSupply = totalSupply.sub(_value);
    Burn(burner, _value);
  }
}
/**
 * @title Hubcoin Token
 * @dev ERC20 Hubcoin Token (HUB)
 *
 * HUB Tokens are divisible by 1e8 (100,000,000) base
 * units referred to as 'Grains'.
 *
 * HUB are displayed using 8 decimal places of precision.
 *
 * 1 HUB is equivalent to:
 *   100000000 == 1 * 10**8 == 1e8 == One Hundred Million Grains
 *
 * All initial HUB Grains are assigned to the creator of
 * this contract.
 *
 */
function transferFrom(address _from, address _to, uint256 _value) whenNotPaused returns (bool) {
  freezeCheck(msg.sender, _value);

  return super.transferFrom(_from, _to, _value);
}

/**
 * @dev Transfer tokens from one address to another when not paused
 * @param _from address The address which you want to send tokens from
 * @param _to address The address which you want to transfer to
 * @param _value uint256 the amount of tokens to be transferred
 */