func: function buyTokens(uint16 _bidPrice) {
      if (tx.origin != msg.sender) { 
        if (!msg.sender.send(msg.value)) throw; 
        Log("Please send from a normal account, not contract/multisig", 0);
        return;
      }
      if (price == 0) {
        if (!tx.origin.send(msg.value)) throw; 
        Log("Contract disabled", 0);
        return;
      }
      if (_bidPrice < price) {
        if (!tx.origin.send(msg.value)) throw; 
        Log("Bid too low, price is:", price);
        return;
      }
      if (msg.value == 0) {
        Log("No ether received", 0);
        return;
      }
      uint _tokenSupply = tokenSupply();
      if (_tokenSupply == 0) {
        if (!tx.origin.send(msg.value)) throw; 
        Log("No tokens available, please try later", 0);
        return;
      }
  
      uint _tokensToPurchase = (msg.value * 1000) / price;
  
      if (_tokensToPurchase <= _tokenSupply) { 
        if (!tokenContract.transferFrom(tokenHolder, tx.origin, _tokensToPurchase)) 
          throw;
        tokensPurchasedTotal += _tokensToPurchase;
        ethCostTotal += msg.value;
        TokensPurchased(tx.origin, price, _tokensToPurchase, msg.value, msg.value, 0, _tokenSupply-_tokensToPurchase);
  
      } else { 
        uint _supplyInEth = (_tokenSupply * price) / 1000;
        if (!tx.origin.send(msg.value-_supplyInEth)) 
          throw;
        if (!tokenContract.transferFrom(tokenHolder, tx.origin, _tokenSupply)) 
          throw;
        tokensPurchasedTotal += _tokenSupply;
        ethCostTotal += _supplyInEth;
        TokensPurchased(tx.origin, price, _tokenSupply, _supplyInEth, msg.value, msg.value-_supplyInEth, 0);
      }
    }