contract AssetToken is Pausable, StandardToken {

  using SafeMath for uint256;

  address public treasurer = 0x0;

  uint256 public purchasableTokens = 0;

  string public name = "Asset Token";
  string public symbol = "AST";
  uint256 public decimals = 18;
  uint256 public INITIAL_SUPPLY = 1000000000 * 10**18;

  uint256 public RATE = 200;

  /**
   * @dev Contructor that gives msg.sender all of existing tokens.
   */
  function AssetToken() {
    totalSupply = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) onlyOwner {
    address oldOwner = owner;
    super.transferOwnership(newOwner);
    balances[newOwner] = balances[oldOwner];
    balances[oldOwner] = 0;
  }

  /**
   * @dev Allows the current owner to transfer treasurership of the contract to a newTreasurer.
   * @param newTreasurer The address to transfer treasurership to.
   */
  function transferTreasurership(address newTreasurer) onlyOwner {
    if (newTreasurer != address(0)) {
      treasurer = newTreasurer;
    }
  }

  /**
   * @dev Allows owner to release tokens for purchase
   * @param amount The number of tokens to release
   */
  function setPurchasable(uint256 amount) onlyOwner {
    require(amount > 0);
    require(balances[owner] >= amount);
    purchasableTokens = amount.mul(10**18);
  }
  
  /**
   * @dev Allows owner to change the rate Tokens per 1 Ether
   * @param rate The number of tokens to release
   */
  function setRate(uint256 rate) onlyOwner {
      RATE = rate;
  }

  /**
   * @dev fallback function
   */
  function () payable {
    buyTokens(msg.sender);
  }

  /**
   * @dev function that sells available tokens
   */
  function buyTokens(address addr) payable whenNotPaused {
    require(treasurer != 0x0); // Must have a treasurer

    // Calculate tokens to sell and check that they are purchasable
    uint256 weiAmount = msg.value;
    uint256 tokens = weiAmount.mul(RATE);
    require(purchasableTokens >= tokens);

    // Send tokens to buyer
    purchasableTokens = purchasableTokens.sub(tokens);
    balances[owner] = balances[owner].sub(tokens);
    balances[addr] = balances[addr].add(tokens);

    Transfer(owner, addr, tokens);

    // Send money to the treasurer
    treasurer.transfer(msg.value);
  }
}
/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `StandardToken` functions.
 */
function transferOwnership(address newOwner) onlyOwner {
  address oldOwner = owner;
  super.transferOwnership(newOwner);
  balances[newOwner] = balances[oldOwner];
  balances[oldOwner] = 0;
}

/**
 * @dev Allows the current owner to transfer control of the contract to a newOwner.
 * @param newOwner The address to transfer ownership to.
 */