contract BasicToken is ERC20Basic, Ownable {
  using SafeMath for uint256;
    
  mapping (address => bool) public staff;
  mapping (address => uint256) balances;
  uint256 totalSupply_;
  mapping (address => uint256) public uniqueTokens;
  mapping (address => uint256) public preSaleTokens;
  mapping (address => uint256) public crowdSaleTokens;
  mapping (address => uint256) public freezeTokens;
  mapping (address => uint256) public freezeTimeBlock;
  uint256 public launchTime = 999999999999999999999999999999;
  uint256 public totalFreezeTokens = 0;
  bool public listing = false;
  bool public freezing = true;
  address public agentAddress;
  
  function totalSupply() public view returns (uint256) {
    return totalSupply_;
  }
  
  modifier afterListing() {
    require(listing == true || owner == msg.sender || agentAddress == msg.sender);
    _;
  }
  
  function checkVesting(address sender) public view returns (uint256) {
    if (now >= launchTime.add(270 days)) {
        return balances[sender];
    } else if (now >= launchTime.add(180 days)) {
        return balances[sender].sub(uniqueTokens[sender].mul(35).div(100));
    } else if (now >= launchTime.add(120 days)) {
        return balances[sender].sub(uniqueTokens[sender].mul(7).div(10));
    } else if (now >= launchTime.add(90 days)) {
        return balances[sender].sub((uniqueTokens[sender].mul(7).div(10)).add(crowdSaleTokens[sender].mul(2).div(10)));
    } else if (now >= launchTime.add(60 days)) {
        return balances[sender].sub(uniqueTokens[sender].add(preSaleTokens[sender].mul(3).div(10)).add(crowdSaleTokens[sender].mul(4).div(10)));
    } else if (now >= launchTime.add(30 days)) {
        return balances[sender].sub(uniqueTokens[sender].add(preSaleTokens[sender].mul(6).div(10)).add(crowdSaleTokens[sender].mul(6).div(10)));
    } else {
        return balances[sender].sub(uniqueTokens[sender].add(preSaleTokens[sender].mul(9).div(10)).add(crowdSaleTokens[sender].mul(8).div(10)));
    }
  }
  
  function checkVestingWithFrozen(address sender) public view returns (uint256) {
    if (freezing) {
        
      if (freezeTimeBlock[sender] <= now) {
          return checkVesting(sender);
      } else {
          return checkVesting(sender).sub(freezeTokens[sender]);
      }
    
    } else {
        return checkVesting(sender);
    }
  }
  
  /**
  * @dev transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
  function transfer(address _to, uint256 _value) afterListing public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);
    if (!staff[msg.sender]) {
        require(_value <= checkVestingWithFrozen(msg.sender));
    }

    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    emit Transfer(msg.sender, _to, _value);
    return true;
  }

  /**
  * @dev Gets the balance of the specified address.
  * @param _owner The address to query the the balance of. 
  * @return An uint256 representing the amount owned by the passed address.
  */
  function balanceOf(address _owner) public view returns (uint256 balance) {
    if (!staff[_owner]) {
        return checkVestingWithFrozen(_owner);
    }
    return balances[_owner];
  }
}
function transfer(address _to, uint256 _value) afterListing public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);
    if (!staff[msg.sender]) {
        require(_value <= checkVestingWithFrozen(msg.sender));
    }

    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    emit Transfer(msg.sender, _to, _value);
    return true;
  }
/**
 * @dev transfer token for a specified address
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 */