contract LICOToken is StandardToken {
    string public name;
    uint8 public decimals; 
    string public symbol;
    string public version = "1.0";
    uint totalEthInWei;

    constructor() public{
        decimals = 18;     // Amount of decimals for display purposes
        totalSupply = 315000000 * 10 ** uint256(decimals);    // Give the creator all initial tokens
        balances[msg.sender] = totalSupply;     // Update total supply
        name = "LifeCrossCoin";    // Set the name for display purposes
        symbol = "LICO";    // Set the symbol for display purposes
    }

    /* Approves and then calls the receiving contract */
    function approveAndCall(address _spender, uint256 _value, bytes _extraData) 
    public
    returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        if(!_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { revert(); }
        return true;
    }

    // can accept ether
    function() payable public{
        revert();
    }

    function transferToCrowdsale(address _to, uint _value) 
    onlyPayloadSize(2 * 32) 
    onlyOwner
    public
    returns (bool success)
    {
        require(_to != address(0));
        if (balances[msg.sender] >= _value && _value > 0) {
            balances[msg.sender] = safeSub(balances[msg.sender], _value);
            balances[_to] = safeAdd(balances[_to], _value);
            emit Transfer(msg.sender, _to, _value);
            return true;
        } else { return false; }

    }
    
    function withdrawTokenFromCrowdsale(address _crowdsale) onlyOwner public returns (bool success){
        require(_crowdsale != address(0));
        if (balances[_crowdsale] >  0) {
            uint _value = balances[_crowdsale];
            balances[_crowdsale] = 0;
            balances[owner] = safeAdd(balances[owner], _value);
            emit Transfer(_crowdsale, owner, _value);
            return true;
        } else { return false; }
    }
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) 
public
returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    emit Approval(msg.sender, _spender, _value);
    if(!_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { revert(); }
    return true;
}

/* Approves and then calls the receiving contract */