BANGKOK -- Thailand may have a reputation for acceptance when it comes to the transgender females that perform in the capital's extravagant cabaret shows, but the country's legal system, like many in Southeast Asia, has traditionally been less accommodating to the LGBT community.

This appears to be changing, however, as the junta aims to prepare a bill that would effectively recognize same-sex unions by the end of this year.

Thais have already begun embracing the change. Last year, Krungthai-AXA Life Insurance revised policy terms to allow same-sex partners to be named as beneficiaries. This came on the heels of a gender equality law enacted in 2015 that banned corporate policies and rules discriminatory to LGBT people, punishing violators with fines and prison.

A recent flurry of online dramas and advertisements reflects the new attitudes. One shampoo ad by Unilever's Thai subsidiary shows a young boy transforming himself into a woman. It immediately went viral, garnering 37 million views within two months of its release in June.

The poignant four-and-a-half-minute spot -- which would push boundaries in most Western countries -- portrays the transition through the person's hair, culminating in the star winning both a beauty pageant and the love of her father, who had initially rejected her. "They say boys can't grow me long," says her hair in a voice-over. "But what if that boy doesn't want to be a boy?"

A scene from Unilever's online shampoo ad reflects Thailand's growing acceptance of its LGBT community.

In August, rival Procter & Gamble answered with its own LGBT-friendly online ad -- hashtagged #SeeBeautyNotGender -- that features transgender actresses and models.

Bangkok's transgender cabaret acts are a big tourist draw, but the country's image as an LGBT paradise can be deceptive. "We were surprised with the bias against LGBTs, and we wanted to have society realize that beauty is about inner beauty," said Raffy Fajardo, managing director of Procter & Gamble Trading (Thailand). "We wanted to send a positive message that is relatable to all consumers, not just transgender people."

According to a recent World Bank report titled "Economic Inclusion of LGBTI Groups in Thailand," more than one-third of non-LGBTI respondents to a survey -- the "I" standing for intersex -- said it is acceptable for employers to discriminate against LGBTI individuals under certain circumstances. Nearly half found it reasonable for LGBTI people to expect some form of discrimination when seeking government services.

The survey also showed LGBTI people are often limited to employment in the entertainment or beauty industries, and that they have difficulty landing jobs in government, finance and medicine.

Procter & Gamble online shampoo ad features a transgender cast.

Danai Linjongrut, executive director of the LGBT advocacy group Rainbow Sky Association of Thailand, said there is a tendency for Thais to regard LGBT people as "those with whom you can be friends, but whom you don't want in the family."

Danai, a gay man, had a hard time being accepted by his family. His father died thinking Danai was diseased.

Attitudes like this are not uncommon in predominantly Buddhist Thailand. Many still believe LGBT people committed crimes in previous lives and are now paying the price, said Danai. But the LGBT movements sweeping many Western countries have arrived in Asia, albeit tentatively, and attitudes are swinging the other way.

The bill that the Thai government is expected to pass will lead to a civil partnership act that recognizes same-sex unions. Existing law only recognizes heterosexual marriage and does not allow an individual in a same-sex relationship to receive the body of a dead partner, nor does it provide the same rights in regards to inheriting the partner's assets. The military government aims to pass the bill before the next general election, slated for as early as next February.

Thailand's move follows Taiwan's 2017 constitutional court ruling in favor of allowing same-sex couples to marry -- a first for Asia. The court called for legislative measures to resolve the situation within two years.

Still, it is not a complete win for the Thai LGBT community. The new law, dubbed the Civil Partnership Act, would still restrict some rights to heterosexual couples. For example, same-sex couples would not be allowed to adopt children. But if the bill becomes law before Taiwan revises its law, Thailand would become the first Asian country to legally recognize same-sex partnerships.

"This would be a major step forward, but our true goal is to win the same rights as those enjoyed by heterosexual couples," Danai said.