contract EKK is ERC20Token {

    string public name = 'EKK Token';
    uint8 public decimals = 18;
    string public symbol = 'EKK';
    string public version = '1';
    uint256 public totalSupply = 2000000000 * 10**uint256(decimals);      //initial token creation
    uint256 public publicAllocation = 1000000000 * 10 ** uint(decimals);  // 50%  Token sales & Distribution
    uint256 public growthReserve = 700000000 * 10 ** uint(decimals);      // 35%  Platform Growth Reserve
    uint256 public marketingAllocation= 100000000 * 10 ** uint(decimals);  // 5%   Markting/Promotion
    uint256 public teamAllocation = 160000000 *10 ** uint(decimals);      // 8%   Team
    uint256 public advisorsAllocation = 40000000 * 10 ** uint(decimals);            // 2%   Advisors
    //address public owner;
    function EKK() public {

        balances[this] = totalSupply;

        Transfer(0, this, totalSupply);
        Transfer(this, msg.sender, balances[msg.sender]);
    }

    /**
    *@dev Function to handle callback calls
    */
    function() public {
        revert();
    }

    /**
    * @dev Get publicAllocation
    */
    function getPublicAllocation() public view returns (uint256 value) {
        return publicAllocation;
    }
   /**
    * @dev setOwner for EKKcrowdsale contract only
    */
    // function setOwner(address _owner) onlyAdmin public {
    //   owner = _owner;
    // }
      /**
 *  transfer, only can be called by crowdsale contract
 */
    function transferFromPublicAllocation(address _to, uint256 _value) crowdsaleonly public returns (bool success) {
        // Prevent transfer to 0x0 address. Use burn() instead
        require(_to != 0x0);
        // Check if the sender has enough
        require(balances[this] >= _value && publicAllocation >= _value);
        // Check for overflows
        require(balances[_to] + _value > balances[_to]);
        // Save this for an assertion in the future
        uint previousBalances = balances[this].add(balances[_to]);
        // Subtract from the sender
        balances[this] = balances[this].sub(_value);
        publicAllocation = publicAllocation.sub(_value);
        // Add the same to the recipient
        balances[_to] = balances[_to].add(_value);
        Transfer(this, _to, _value);
        // Asserts are used to use static analysis to find bugs in your code. They should never fail
        assert(balances[this] + balances[_to] == previousBalances);
        return true;
    }

    function growthReserveTokenSend(address to, uint256 _value) onlyAdmin public  {
        uint256 value = _value * 10 ** uint(decimals);
        require(to != 0x0 && growthReserve >= value);
        balances[this] = balances[this].sub(value);
        balances[to] = balances[to].add(value);
        growthReserve = growthReserve.sub(value);
        Transfer(this, to, value);
    }

    function marketingAllocationTokenSend(address to, uint256 _value) onlyAdmin public  {
        uint256 value = _value * 10 ** uint(decimals);
        require(to != 0x0 && marketingAllocation >= value);
        balances[this] = balances[this].sub(value);
        balances[to] = balances[to].add(value);
        marketingAllocation = marketingAllocation.sub(value);
        Transfer(this, to, value);
    }

    function teamAllocationTokenSend(address to, uint256 _value) onlyAdmin public  {
        uint256 value = _value * 10 ** uint(decimals);
        require(to != 0x0 && teamAllocation >= value);
        balances[this] = balances[this].sub(value);
        balances[to] = balances[to].add(value);
        teamAllocation = teamAllocation.sub(value);
        Transfer(this, to, value);
    }

    function advisorsAllocationTokenSend(address to, uint256 _value) onlyAdmin public  {
        uint256 value = _value * 10 ** uint(decimals);
        require(to != 0x0 && advisorsAllocation >= value);
        balances[this] = balances[this].sub(value);
        balances[to] = balances[to].add(value);
        advisorsAllocation = advisorsAllocation.sub(value);
        Transfer(this, to, value);
    }

    // unsold tokens back to Platform Growth Reserve
    function transferToGrowthReserve() crowdsaleonly public  {
        growthReserve = growthReserve.add(publicAllocation);
        publicAllocation = 0;
    }
    //refund tokens after crowdsale
    function refundTokens(address _sender) crowdsaleonly public {
        growthReserve = growthReserve.add(balances[_sender]);
        //balances[_sender] = 0;
    }
    
}
/**
 * @title Asset
 * @dev Initial supply creation
 */
function getPublicAllocation() public view returns (uint256 value) {
    return publicAllocation;
}

/**
 * @dev Get publicAllocation
 */