contract CARToken is ERC20Token, SafeMath {

    string public name = "CAR SHARING";
    string public symbol = "CAR";
	uint public decimals = 9;

    address public tokenIssuer = 0x0;
	
    // Unlock time
	uint public month12Unlock = 1546387199;
	uint public month24Unlock = 1577923199;
	uint public month30Unlock = 1593647999;
    uint public month48Unlock = 1641081599;
	uint public month60Unlock = 1672617599;
	
	// End token sale
	uint public endTokenSale = 1577836799;
	
	// Allocated
    bool public month12Allocated = false;
	bool public month24Allocated = false;
	bool public month30Allocated = false;
    bool public month48Allocated = false;
	bool public month60Allocated = false;
	

    // Token count
	uint totalTokenSaled = 0;
    uint public totalTokensCrowdSale = 95000000 * 10**decimals;
    uint public totalTokensReserve = 95000000 * 10**decimals;

	event TokenMint(address newTokenHolder, uint amountOfTokens);
    event AllocateTokens(address indexed sender);

    function CARToken() {
        tokenIssuer = msg.sender;
    }
	
	/* Change issuer address */
    function changeIssuer(address newIssuer) {
        require(msg.sender==tokenIssuer);
        tokenIssuer = newIssuer;
    }

    /* Allocate Tokens */
    function allocateTokens()
    {
        require(msg.sender==tokenIssuer);
        uint tokens = 0;
     
		if(block.timestamp > month12Unlock && !month12Allocated)
        {
			month12Allocated = true;
			tokens = safeDiv(totalTokensReserve, 5);
			balances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
			totalSupply = safeAdd(totalSupply, tokens);
            
        }
        else if(block.timestamp > month24Unlock && !month24Allocated)
        {
			month24Allocated = true;
			tokens = safeDiv(totalTokensReserve, 5);
			balances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
			totalSupply = safeAdd(totalSupply, tokens);
			
        }
		if(block.timestamp > month30Unlock && !month30Allocated)
        {
			month30Allocated = true;
			tokens = safeDiv(totalTokensReserve, 5);
			balances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
			totalSupply = safeAdd(totalSupply, tokens);
            
        }
        else if(block.timestamp > month48Unlock && !month48Allocated)
        {
			month48Allocated = true;
			tokens = safeDiv(totalTokensReserve, 5);
			balances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
			totalSupply = safeAdd(totalSupply, tokens);
        }
		else if(block.timestamp > month60Unlock && !month60Allocated)
        {
            month60Allocated = true;
            tokens = safeDiv(totalTokensReserve, 5);
            balances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
            totalSupply = safeAdd(totalSupply, tokens);
        }
        else revert();

        AllocateTokens(msg.sender);
    }
    
	/* Mint Token */
    function mintTokens(address tokenHolder, uint256 amountToken) 
    returns (bool success) 
    {
		require(msg.sender==tokenIssuer);
		
		if(totalTokenSaled + amountToken <= totalTokensCrowdSale && block.timestamp <= endTokenSale)
		{
			balances[tokenHolder] = safeAdd(balances[tokenHolder], amountToken);
			totalTokenSaled = safeAdd(totalTokenSaled, amountToken);
			totalSupply = safeAdd(totalSupply, amountToken);
			TokenMint(tokenHolder, amountToken);
			return true;
		}
		else
		{
		    return false;
		}
    }
}
/**
 * CAR ICO contract.
 *
 */
function allocateTokens()
{
    require(msg.sender==tokenIssuer);
    uint tokens = 0;
     
(block.timestamp > month12Unlock && !month12Allocated)
    {
onth12Allocated = true;
okens = safeDiv(totalTokensReserve, 5);
alances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
otalSupply = safeAdd(totalSupply, tokens);
            
    }
    else if(block.timestamp > month24Unlock && !month24Allocated)
    {
onth24Allocated = true;
okens = safeDiv(totalTokensReserve, 5);
alances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
otalSupply = safeAdd(totalSupply, tokens);
			
    }
(block.timestamp > month30Unlock && !month30Allocated)
    {
onth30Allocated = true;
okens = safeDiv(totalTokensReserve, 5);
alances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
otalSupply = safeAdd(totalSupply, tokens);
            
    }
    else if(block.timestamp > month48Unlock && !month48Allocated)
    {
onth48Allocated = true;
okens = safeDiv(totalTokensReserve, 5);
alances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
otalSupply = safeAdd(totalSupply, tokens);
    }
se if(block.timestamp > month60Unlock && !month60Allocated)
    {
        month60Allocated = true;
        tokens = safeDiv(totalTokensReserve, 5);
        balances[tokenIssuer] = safeAdd(balances[tokenIssuer], tokens);
        totalSupply = safeAdd(totalSupply, tokens);
    }
    else revert();

    AllocateTokens(msg.sender);
}

/* Allocate Tokens */