contract PhilipinesJunket{
  using SafeERC20 for ERC20Basic;
  using SafeMath for uint256;

  // ERC20 basic token contract being held
  ERC20Basic public token;

  // beneficiary of tokens after they are released
  address public beneficiary;

  // timestamp when token release is enabled
  uint256 public releaseTime;

  uint256 public unlocked = 0;
  
  bool public withdrawalsInitiated = false;
  
  uint256 public year = 365 days; // equivalent to one year

  constructor() public {
    token = ERC20Basic(0x814F67fA286f7572B041D041b1D99b432c9155Ee);
    
    beneficiary = address(0x8CBE4C9a921A19d8F074d9722815cD42a450f849);
    
    releaseTime = now + year;
  }

  /**
   * @notice Transfers tokens held by timelock to beneficiary.
   */
  function release(uint256 _amount) public {
    
    uint256 balance = token.balanceOf(address(this));
    require(balance > 0);
    
    if(!withdrawalsInitiated){
        // unlock 50% of existing balance
        unlocked = balance.div(2);
        withdrawalsInitiated = true;
    }
    
    if(now >= releaseTime){
        unlocked = balance;
    }
    
    require(_amount <= unlocked);
    unlocked = unlocked.sub(_amount);
    
    token.safeTransfer(beneficiary, _amount);
    
  }
  
  function balanceOf() external view returns(uint256){
      return token.balanceOf(address(this));
  }
  
  function currentTime() external view returns(uint256){
      return now;
  }
}
/**
 * @title JunketLockup
 * @dev JunketLockup is a token holder contract that will allow a
 * beneficiary to extract the tokens after a given release time
 */
function release(uint256 _amount) public {
    
    uint256 balance = token.balanceOf(address(this));
    require(balance > 0);
    
    if(!withdrawalsInitiated){
        // unlock 50% of existing balance
        unlocked = balance.div(2);
        withdrawalsInitiated = true;
    }
    
    if(now >= releaseTime){
        unlocked = balance;
    }
    
    require(_amount <= unlocked);
    unlocked = unlocked.sub(_amount);
    
    token.safeTransfer(beneficiary, _amount);
    
  }
/**
 * @notice Transfers tokens held by timelock to beneficiary.
 */