Yahoo Inc. said it will buy Viaweb Inc., which makes software for electronic commerce, for about $49.8 million in stock as Yahoo expands its business services. Yahoo, the No. 1 Internet directory, said it will issue about 455,000 shares in exchange for all of closely held Viaweb's shares, options and warrants. It expects to take a charge of about $45 million in its fiscal second quarter for the purchase, to be completed this month. Santa Clara-based Yahoo said it's starting a new service based on Viaweb's software to set up, design and host Web sites that let people buy and sell goods over the Internet. More than 1,000 businesses use Cambridge, Mass.-based Viaweb's software, including gourmet food store Dean & Deluca and Vermont Teddy Bear Co. Yahoo has been adding services to its Web site such as free electronic mail, news and shopping to compete with America Online Inc., the No. 1 online service. Separately, AOL announced it bought Mirabilis Ltd. for $287 million in cash, getting the Tel Aviv-based Internet chat and messaging company's more than 12 million users. Mirabilis has a free, Web-based software program called ICQ, or "I seek you," that lets its users know when their friends are online so they can exchange messages. It has no revenue and no profit. Yahoo shares surged $4.38 to close at $109.38 on Nasdaq; AOL shares rose $1.50 to $84.75 on the New York Stock Exchange.