contract T8CToken is StandardToken {

	//FIELDS
	string public name = "T8Coin";
    string public symbol = "T8C";
    uint public decimals = 3;

	//INITIALIZATION
	address public minter; //address that able to mint new tokens
	uint public icoEndTime; 

	uint illiquidBalance_amount;
	mapping (uint => address) illiquidBalance_index;
	mapping (address => uint) public illiquidBalance; //Balance of 'Frozen funds'


	// called by crowdsale contract
	modifier only_minter {
		if (msg.sender != minter) throw;
		_;
	}

	// Can only be called if the `crowdfunder` is allowed to mint tokens. Any
	// time before `endMintingTime`.
	modifier when_mintable {
		if (now > icoEndTime) throw; // todo need bounty create token?
		_;
	}

	// Initialization contract assigns address of crowdfund contract and end time.
	function T8CToken (address _minter, uint _icoEndTime) {
		minter = _minter;
		icoEndTime = _icoEndTime;
	}

	// Create new tokens when called by the crowdfund contract.
	// Only callable before the end time.
	function createToken(address _recipient, uint _value)
		when_mintable
		only_minter
		returns (bool o_success)
	{
		balances[_recipient] += _value;
		totalSupply += _value;
		return true;
	}

		// Create an illiquidBalance which cannot be traded until admin make it liquid.
	// Can only be called by crowdfund contract before the end time.
	function createIlliquidToken(address _recipient, uint _value)
		when_mintable
		only_minter
		returns (bool o_success)
	{
		illiquidBalance_index[illiquidBalance_amount] = _recipient;
		illiquidBalance[_recipient] += _value;
		illiquidBalance_amount++;

		totalSupply += _value;
		return true;
	}

	// Make sender's illiquid balance liquid when called after lockout period.
	function makeLiquid()
		only_minter
	{
		for (uint i=0; i<illiquidBalance_amount; i++)
		{
			address investor = illiquidBalance_index[i];
			balances[investor] += illiquidBalance[investor];
			illiquidBalance[investor] = 0;
		}
	}

	// Transfer amount of tokens from sender account to recipient.
	// Only callable after the crowd fund end date.
	function transfer(address _recipient, uint _amount)
		returns (bool o_success)
	{
		return super.transfer(_recipient, _amount);
	}

	// Transfer amount of tokens from a specified address to a recipient.
	// Only callable after the crowd fund end date.
	function transferFrom(address _from, address _recipient, uint _amount)
		returns (bool o_success)
	{
		return super.transferFrom(_from, _recipient, _amount);
	}
}
function T8CToken (address _minter, uint _icoEndTime) {
	minter = _minter;
	icoEndTime = _icoEndTime;
}

// Initialization contract assigns address of crowdfund contract and end time.