For more than a decade, James W. Ray was trapped in a fog of drugs and mental illness. In and out of hospitals and emergency rooms, he sometimes landed in halfway houses or jail, one step from the streets.

He told anyone who would listen that he was a rich man. That his family once had a 110-room mansion with masterpieces by Rembrandt and Renoir, and ancestral portraits by John Singer Sargent. That his great-granddad owned a racetrack in Miami.

Nurses and caseworkers nodded politely while jotting down observations like "delusions of grandeur" and "inflated self-worth" in his records.

It was understandable, except that the tall, scruffy man in bib overalls was telling the truth.

The "W" stood for Widener - as in Philadelphia nobility and Gilded Age fortune; as in summer manses in Newport and winter villas in Palm Beach; as in Widener University in Chester, the Widener Building in Center City, the Widener Library at Harvard University, and the 600-piece Widener art collection at the National Gallery of Art.

That Widener.

When he died at 52 in 2005 in Seattle, single, childless, unnoticed, James Widener Ray left his entire fortune of almost $80 million to a nonprofit he started in the more lucid last years of his life.

Today, the Raynier Institute and Foundation splits most of its contributions between groups in Philadelphia and its hometown of Seattle - everything from programs for homeless teens to jazz festivals, animal rescue leagues, even a Buddhist monastery and UFO museum.

It recently made its largest local grant: $2 million to Project HOME, a nonprofit serving homeless people. Much of the money has been used to renovate a foreclosed apartment house in North Philadelphia into 53 rental units. Tenants, most of whom were once homeless, already have begun moving into the James Widener Ray Homes.

Looking ahead, the foundation is targeting homelessness as one of its core issues, said Bradford Trenary, a Raynier director.

"Jim's interests were wide and varied - and frequently influenced by his mania," he said. The board takes a more sensible approach to grant-giving, but holds on to "a bit of the quirkiness of who he was."

Said Trenary: "He liked to surprise people with spontaneous acts of kindness."

Family fortune

It's not enough just to say the Wideners were wealthy.

They were loaded, flush, rolling in it, and then some.

During the Civil War, Peter A.B. Widener, a brickmaker's son who became a butcher, laid the foundation for the family fortune by selling meat to Union troops. He plowed his $50,000 profit into streetcar lines in Philadelphia, New York, Chicago, Baltimore, and Pittsburgh.

Widener also invested shrewdly in the United States Steel Corp., American Tobacco, and International Mercantile Marine, whose subsidiary owned the R.M.S. Titanic. When the grand ship went down in 1912, it took one of his three sons and a grandson with it.

The patriarch died in 1915 at Lynnewood Hall, his "American Versailles" designed by famed architect Horace Trumbauer in 1900 on 220 Elkins Park acres. Graced with marble halls and sculpted gardens, the $8 million estate would cost $200 million to build today.

At Widener parties, a thousand guests could dance in the ballroom, then walk the corridors to admire masterpieces by Rembrandt, Manet, El Greco, Van Dyck, Titian, Donatello, Raphael.

His youngest son, Joseph, a horseman and art collector, took over managing his late father's holdings, valued at $35 million in 1915, equal to $750 million today.

In 1920, blueblood Philadelphia was aghast when Joseph's only daughter - 17-year-old Josephine, known as "Fifi" - eloped with her beau, a University of Pennsylvania freshman. News of their laughing all the way to wedded bliss in Knoxville, Tenn., was heralded on The Inquirer's front page.

The press made just as much fuss about her divorce six years later, as well as her three subsequent marriages.

Fifi's only child, Joan Leidy, was a principal heir to the Joseph Widener fortune.

In 1941, at age 17, she married amid requisite splendor at Beachmound Mansion in Newport, R.I. More than 400 dined under a red-and-white tent - the colors of the family's racing silks and a nod to Granddad Joe, who owned Hialeah Park in Miami.

The bride and her groom, George Eustis Paine Jr., set up housekeeping on Fifth Avenue in Manhattan. Her Reno divorce nine years later was quickly followed by marriage to James Chandler Ray, an ex-Air Force pilot and rancher.

Having had two children from her first union, Joan had two more with Ray: a daughter, also named Joan, and a son, James Widener Ray, born in 1952.

The family lived large.

The world was young James' backyard. He learned to ski in Gstaad, Switzerland. He sailed the Mediterranean for a year with his parents.

The family bought a ranch in Montana, where the boy "rode horses and roped cattle," said Carter Leidy Jr., a Philadelphia artist and his mother's half-brother.

The elder Ray, Leidy said, "didn't think the East Coast had much to offer. They lived in California and Montana, and places in between."

But James' relationship with his father was strained, according to Trenary, the Raynier Foundation director.

"Jim grew up very artistic, and was a sensitive, gentle young man," he said. "At one point, he identified himself as being gay. His father was military, and that was the worst news he could hear."

Contacted at his home in Florida, the father declined to talk about the son.

When he turned 21 in 1973, James Ray could partake of the annual income from the Joseph E. Widener Family Trust. His share that first year amounted to $1 million.

He took off for Telluride, Colo., to ski, party, and otherwise burn through his money. For a year, Trenary said, "he went wild."

Ray was diagnosed as bipolar.

Dropping out of community college, he moved about aimlessly. He once bought a used Mercedes-Benz to drive from San Francisco, where he lived briefly, to Arizona.

"The car broke down," Trenary said, "and he simply left it along the roadside, hitchhiked into the next town, and bought another Mercedes."

During the 1970s, Ray began a cycle of hospitalizations for mental illness. Frustrated by his drug use and reckless spending, his father had himself appointed legal guardian and asserted control over his finances, Trenary said.

In the 1980s, his parents turned to a noted psychiatrist in Seattle, John A. Chiles, for treatment. Ray moved into a group home there.

Two things happened to change his life.

In 1988, with his mother's death, Ray came into an inheritance of about $38 million.

By then, the hostility between him and his father had intensified into complete estrangement, Trenary said.

So, with the support of his psychiatrist, Ray got a lawyer and successfully petitioned the courts to allow him to hire a professional guardian to replace his father.

At the time, Ray's worldly possessions consisted of two pairs of overalls, a couple of T-shirts, socks, underwear, and a pair of sneakers.

"When he walked down the street," Trenary recalled, "people who didn't know him would absolutely think he was homeless."

In 1989, Trenary was brought in by Ray's new legal guardian, a firm called Guardianship Services of Seattle, to organize a staff and set up a support network so Ray could live independently.

Cost was no consideration.

Trenary hired mental health professionals with graduate degrees to be on call around the clock. There were also a full-time chef, a part-time chef, two housekeepers, and a man who was both boat captain and airplane pilot.

Ray's staff kept him safe in other ways, too. They did background checks on the people he befriended - warning him, for instance, about a man who was later arrested for cruelty to animals and beating his roommate.

Leidy Sue Samson, a half-sister who lives in Hailey, Idaho, described Ray as "a good soul" who "believed in helping people, maybe to his detriment."

During the first two years of this wholly chaperoned existence, Ray was in and out of hospitals every few months. But in the last five years of his life, he was hospitalized only twice, Trenary said.

With his inheritance, Ray renovated an 8,000-square-foot house on nearly four acres on a bluff in Seattle's Capitol Hill neighborhood.

"He was a designer, artist, and interior decorator," Trenary said, "and was actually good at it."

He played the role of bohemian to perfection. He was 6-foot-1, with "appetites" to match, Trenary said. "He wore lots of jewelry and three vests, layers of clothes and a sweatshirt."

Ray stayed clean and traveled with an entourage of friends and caregivers to places like Spain, Thailand, and Peru. He also made a yearly trip to Philadelphia to meet with his money managers.

"We always visited Chestnut Street to see the big building with the Widener name," said Trenary, who accompanied him. "In Seattle, he always introduced himself as Jim Ray. But when he was in Philadelphia, it was Jim Widener Ray."

In 1994, Ray started the Raynier Foundation (a play on his name and Mount Rainier) and supported his interests, in particular producing jazz festivals and reaching out to troubled teens.

"[He] used to get worried about some kid he knew who was evicted from his apartment or whose parents had kicked him out," Trenary said. "He ached about that."

'Philadelphia money'

James Widener Ray's death from a heart attack went unreported by Seattle media - until his sister, Joan, challenged his last wishes in court.

Under his original will, he left everything to family. In the revised version, signed in 1998, it all went to the foundation. An out-of-court settlement was reached in 2006 that put Joan on the board of directors. She died in 2009.

Today, the foundation is run by four volunteer directors. Two are from Seattle; two - Robert Warth, Ray's former money manager; and Michael Valucci, his tax accountant - are from Philadelphia.

The foundation has a tripartite focus: homelessness; alcohol and drug addiction; art and music. In 2010, it gave $7.75 million to two Seattle groups for homeless youths.

The board thought it only right that it send its next sizable grant east. "It's Philadelphia money," Warth said. "That's where it was made."

The local directors reached out to Sister Mary Scullion, co-founder of Project HOME. She had something for them: the $11 million renovation of a vacant apartment house using federal stimulus money from the city and state, plus private donations.

The brick building at 21st and Venango Streets, in the Tioga section, had been a notorious drug den.

Now by the front door is a simple metal plaque: James Widener Ray Homes.

Hyacinth King works at the front desk. She lived on the streets until Project HOME helped her get her life together and gave her a job seven years ago.

Curious about the building's namesake, she checked him out online.

"I was really, really happy," King said one recent afternoon, "to see that someone who struggled with some of the same things as the people living here had the good fortune and ability to give back."

Contact staff writer Jennifer Lin at 215-854-5659, jlin@phillynews.com or @j_linq on Twitter.