Google has agreed in a court settlement to spend at least $250 million over the next five years to help fight illegal online pharmacies selling to US customers, documents showed Friday. The US Internet search giant made the commitment in settling a lawsuit from shareholders alleging Google failed to take adequate measures to prevent foreign online pharmacies from using its advertising network. The lawsuit was filed in 2011 after Google paid a $500 million settlement to the US government over charges it sold advertisements to Canada-based online pharmacies which marketed drugs to Americans in violation of US law. In a settlement filed in federal court in California, Google agreed to spend at least $50 million per year in each of the coming five years on product quality operations, policy enforcement, and user safety initiative to prevent the ads from appearing.