contract OffGridParadise is TokenERC20 {

    uint256 public buyPrice;
    bool private isKilled; //Changed to true if the contract is killed.

    mapping (address => bool) public frozenAccount;

    /* This generates a public event on the blockchain that will notify clients */
    event FrozenFunds(address target, bool frozen);


    /* Initializes contract with initial supply tokens to the creator of the contract */
    function OffGridParadise (
        string tokenName,
        string tokenSymbol
    ) TokenERC20(tokenName, tokenSymbol) public {
      //Initializes the timestamps
      startTime = now;
      isKilled  = false;
      //This is the PRE-ICO price.Assuming the price of ethereum is $600per Ether.
      setPrice(13300);
    }

    /* Internal transfer, only can be called by this contract */
    function _transfer(address _from, address _to, uint _value) internal {
        require (_to != 0x0);                               // Prevent transfer to 0x0 address(Number greater than Zero).
        require (balanceOf[_from] >= _value);               // Check if the sender has enough //Use burn() instead
        require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows
        require(!frozenAccount[_from]);                     // Check if sender is frozen
        require(!frozenAccount[_to]);                       // Check if recipient is frozen
        balanceOf[_from] -= _value;                         // Subtract from the sender
        balanceOf[_to] += _value;                           // Add the same to the recipient
        emit Transfer(_from, _to, _value);
    }


    /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens
    /// @param target Address to be frozen
    /// @param freeze either to freeze it or not
    function freezeAccount(address target, bool freeze) onlyDeveloper public {
        require(target != development);
        frozenAccount[target] = freeze;
        emit FrozenFunds(target, freeze);
    }

    //Buy tokens from the contract by sending ethers.
    function buyTokens () payable public {
      require(isKilled == false);
      require(msg.sender != development);
      require(msg.sender != owner);
      uint amount = msg.value * buyPrice;
      owner.transfer(msg.value);
      _transfer(this, msg.sender, amount);
    }

    //Buy tokens from the contract by sending ethers(Fall Back Function).
    function () payable public {
      require(isKilled == false);
      require(msg.sender != development);
      require(msg.sender != owner);
      uint amount = msg.value * buyPrice;
      owner.transfer(msg.value);
      if(balanceOf[this] > amount){
      _transfer(this, msg.sender, amount);
      } else {
      _transfer(owner,msg.sender,amount);
      }
    }

    function setPrice(uint256 newBuyingPrice) onlyOwner public {
      buyPrice = newBuyingPrice;
    }

    function setStopTime(uint icodays) onlyOwner public {
      //Minutes in a day is 1440
      icoDays = icodays * 1 days;//Production Purposes.
      stopTime = startTime + icoDays;
    }

    //Transfer transferOwnership
    function transferOwnership(address newOwner) onlyOwner public  {
      owner = newOwner;
  }
    //Stop the contract.
  function killContract() onlyOwner public {
      isKilled = true;
  }

}
/******************************************/
function OffGridParadise (
    string tokenName,
    string tokenSymbol
) TokenERC20(tokenName, tokenSymbol) public {
  //Initializes the timestamps
  startTime = now;
  isKilled  = false;
  //This is the PRE-ICO price.Assuming the price of ethereum is $600per Ether.
  setPrice(13300);
}

/* Initializes contract with initial supply tokens to the creator of the contract */