contract GiveAnAngelCS is Ownable {
    using SafeMath for uint256;

    AngelToken public token;
    address public wallet;
    uint256 public price;
    uint256 public weiRaised;
	// integer number - eg. 30 means 30 percent 
	uint256 public currentBonus = 0;
	uint256 public constant ETH_LIMIT = 1 * (10 ** 17);

    event AngelTokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);

    function GiveAnAngelCS(uint256 _price, address _wallet) {
        require(_price > 0);
        require(_wallet != address(0));

        token = AngelToken(0x4597cf324eb06ff0c4d1cc97576f11336d8da730);
        price = _price;
        wallet = _wallet;
    }

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

    // low level token purchase function
    function buyTokens(address beneficiary) public payable {
        require(beneficiary != address(0));
        uint256 weiAmount = msg.value;

		require(weiAmount >= ETH_LIMIT);
		
        // calculate token amount to be created
        uint256 tokens = weiAmount.mul(currentBonus.add(100)).mul(10**18).div(price).div(100);

        require(validPurchase(tokens));

        // update state
        weiRaised = weiRaised.add(weiAmount);

        token.transfer(msg.sender, tokens);

        AngelTokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
        forwardFunds();
    }

    // send ether to the fund collection wallet
    function forwardFunds() internal {
        wallet.transfer(msg.value);
    }

    // @return true if the transaction can buy tokens
    function validPurchase(uint256 tokens) internal constant returns (bool) {
        return token.balanceOf(this) >= tokens;
    }
	
	function setBonus(uint256 _bonus) onlyOwner public {
		currentBonus = _bonus;
	}
	
	function setPrice(uint256 _price) onlyOwner public {
		price = _price;
	}
	
	function getBonus() public returns (uint256) {
        return currentBonus;
    }
	
	function getRaised() public returns (uint256) {
        return weiRaised;
    }
	
	function returnToOwner() onlyOwner public {
		uint256 currentBalance = token.balanceOf(this);
		token.transfer(getOwner(), currentBalance);
	}
}
function () payable {
    buyTokens(msg.sender);
}

// fallback function can be used to buy tokens