contract IOLITE is StandardToken {

    string public constant name = "IOLITE";
    string public constant symbol = "LITE";
    uint8 public constant decimals = 8;
    uint256 public constant INITIAL_SUPPLY = 1 * 10**9 * (10**uint256(decimals));
    uint256 public weiRaised;
    uint256 public tokenAllocated;
    address public owner;
    bool public saleToken = true;

    event OwnerChanged(address indexed previousOwner, address indexed newOwner);
    event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
    event TokenLimitReached(uint256 tokenRaised, uint256 purchasedToken);
    event Transfer(address indexed _from, address indexed _to, uint256 _value);

    function IOLITE() public {
        totalSupply = INITIAL_SUPPLY;
        owner = msg.sender;
        //owner = msg.sender; // for testing
        balances[owner] = INITIAL_SUPPLY;
        tokenAllocated = 0;
        transfersEnabled = true;
    }

    // fallback function can be used to buy tokens
    function() payable public {
        buyTokens(msg.sender);
    }

    function buyTokens(address _investor) public payable returns (uint256){
        require(_investor != address(0));
        require(saleToken == true);
        address wallet = owner;
        uint256 weiAmount = msg.value;
        uint256 tokens = validPurchaseTokens(weiAmount);
        if (tokens == 0) {revert();}
        weiRaised = weiRaised.add(weiAmount);
        tokenAllocated = tokenAllocated.add(tokens);
        mint(_investor, tokens, owner);

        TokenPurchase(_investor, weiAmount, tokens);
        wallet.transfer(weiAmount);
        return tokens;
    }

    function validPurchaseTokens(uint256 _weiAmount) public returns (uint256) {
        uint256 addTokens = getTotalAmountOfTokens(_weiAmount);
        if (addTokens > balances[owner]) {
            TokenLimitReached(tokenAllocated, addTokens);
            return 0;
        }
        return addTokens;
    }

    /**
    * If the user sends 0 ether, he receives 500 
    * If he sends 0.001 ether, he receives 1,000 +25%
    * If he sends 0.01 ether, he receives 10,000 +50%
    * If he sends 0.1 ether he receives 100,000 +75%
    * If he sends 1 ether, he receives 1,000,000 +100%
    */
    function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) {
        uint256 amountOfTokens = 0;
        if(_weiAmount == 0){
            amountOfTokens = 500 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.001 ether){
            amountOfTokens = 1250 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.002 ether){
            amountOfTokens = 2500 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.003 ether){
            amountOfTokens = 3750 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.004 ether){
            amountOfTokens = 5 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.005 ether){
            amountOfTokens = 6250 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.006 ether){
            amountOfTokens = 6000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.007 ether){
            amountOfTokens = 7500 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.008 ether){
            amountOfTokens = 10000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.009 ether){
            amountOfTokens = 9000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.01 ether){
            amountOfTokens = 15000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.02 ether){
            amountOfTokens = 30000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.03 ether){
            amountOfTokens = 45000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.04 ether){
            amountOfTokens = 60000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.05 ether){
            amountOfTokens = 75000 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.06 ether){
            amountOfTokens = 90000 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.07 ether){
            amountOfTokens = 105 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.08 ether){
            amountOfTokens = 120 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.09 ether){
            amountOfTokens = 135 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.1 ether){
            amountOfTokens = 175 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.2 ether){
            amountOfTokens = 350 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.3 ether){
            amountOfTokens = 525 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.4 ether){
            amountOfTokens = 700 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.5 ether){
            amountOfTokens = 875 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.6 ether){
            amountOfTokens = 1050 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.7 ether){
            amountOfTokens = 1225 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.8 ether){
            amountOfTokens = 1400 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 0.9 ether){
            amountOfTokens = 15750 * 10**3 * (10**uint256(decimals));
        }
        if( _weiAmount == 1 ether){
            amountOfTokens = 2000 * 10**3 * (10**uint256(decimals));
        }
        return amountOfTokens;
    }


    function mint(address _to, uint256 _amount, address _owner) internal returns (bool) {
        require(_to != address(0));
        require(_amount <= balances[_owner]);

        balances[_to] = balances[_to].add(_amount);
        balances[_owner] = balances[_owner].sub(_amount);
        Transfer(_owner, _to, _amount);
        return true;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    function changeOwner(address _newOwner) onlyOwner public returns (bool){
        require(_newOwner != address(0));
        OwnerChanged(owner, _newOwner);
        owner = _newOwner;
        return true;
    }

    function startSale() public onlyOwner {
        saleToken = true;
    }

    function stopSale() public onlyOwner {
        saleToken = false;
    }

    function enableTransfers(bool _transfersEnabled) onlyOwner public {
        transfersEnabled = _transfersEnabled;
    }

    /**
     * Peterson's Law Protection
     * Claim tokens
     */
    function claimTokens() public onlyOwner {
        owner.transfer(this.balance);
        uint256 balance = balanceOf(this);
        transfer(owner, balance);
        Transfer(this, owner, balance);
    }
}
function claimTokens() public onlyOwner {
        owner.transfer(this.balance);
        uint256 balance = balanceOf(this);
        transfer(owner, balance);
        Transfer(this, owner, balance);
    }
/**
 * Peterson's Law Protection
 * Claim tokens
 */