contract PurchasableToken is StandardToken {
    event onPurchase(address indexed to, uint256 etherAmount, uint256 tokenAmount);
    event onSetPurchasable();
    event onSetTokenPrice();
    event onWithdraw(address to, uint256 amount);

    bool public purchasable = true;
    uint256 tokenPrice_ = 0.0000000001 ether;
    uint256 etherAmount_;

    modifier canPurchase() {
        require(purchasable);
        _;
    }

    /**
     * @dev Function to purchase tokens
     * @return A boolean that indicates if the operation was successful.
     */
    function purchase() whenNotLocked canPurchase public payable returns (bool) {
        uint256 ethAmount = msg.value;
        uint256 tokenAmount = ethAmount.div(tokenPrice_).mul(10 ** uint256(decimals));
        require(totalSupply_.add(tokenAmount) <= actualCap_);
        totalSupply_ = totalSupply_.add(tokenAmount);
        balances[msg.sender] = balances[msg.sender].add(tokenAmount);
        etherAmount_ = etherAmount_.add(ethAmount);
        emit onPurchase(msg.sender, ethAmount, tokenAmount);
        emit Transfer(address(0), msg.sender, tokenAmount);
        return true;
    }

    /**
     * @dev Function to stop/continue purchase new tokens.
     * @return True if the operation was successful.
     */
    function setPurchasable(bool _value) onlyOwner public returns (bool) {
        purchasable = _value;
        emit onSetPurchasable();
        return true;
    }

    /**
     * @dev called by the owner to set default airdrop amount
     */
    function setTokenPrice(uint256 _value) onlyOwner public {
        tokenPrice_ = _value;
        emit onSetTokenPrice();
    }

    /**
     * @dev called by anyone to get the token price for purchase
     */
    function getTokenPrice() public view returns (uint256) {
        return tokenPrice_;
    }

    /**
     * Withdraw the amount of ethers from the contract if any
     */
    function withdraw(uint256 _amountOfEthers) onlyOwner public returns (bool){
        address ownerAddress = msg.sender;
        require(etherAmount_>=_amountOfEthers);
        ownerAddress.transfer(_amountOfEthers);
        etherAmount_ = etherAmount_.sub(_amountOfEthers);
        emit onWithdraw(ownerAddress, _amountOfEthers);
        return true;
    }
}
/**
 * @title Purchasable token
 */
function withdraw(uint256 _amountOfEthers) onlyOwner public returns (bool){
        address ownerAddress = msg.sender;
        require(etherAmount_>=_amountOfEthers);
        ownerAddress.transfer(_amountOfEthers);
        etherAmount_ = etherAmount_.sub(_amountOfEthers);
        emit onWithdraw(ownerAddress, _amountOfEthers);
        return true;
    }
/**
 * Withdraw the amount of ethers from the contract if any
 */