A manager who stole £20,000 from a charity and contributed to its collapse has been told to repay the money or face jail.

Edward McGregor embezzled the cash from employment support group Skillnet between July 2006 and August 2012.

The charity had been receiving funding from the Scottish Government but that had ceased and it got into financial difficulties in 2012.

Edinburgh Sheriff Court heard McGregor told the company board that it owed tax money to HMRC in July 2012 and he resigned the next month.

When board members examined the accounts they discovered the money due to HMRC was still outstanding and the amount had increased.

An investigation showed a string of payments had been made into a bank account held by McGregor.

Skillnet, which was set up in 2002, went into liquidation shortly afterwards.

Fiscal depute Tom Crosbie said: "Clearly the actions of the accused were a contributory factor."

Sheriff Kenneth Maciver told McGregor, who had previously admitted embezzling the cash, to pay back the full amount to avoid a custodial sentence.

McGregor's defence solicitor Jim Stephenson said his client had sold his home in Ayton in the Scottish Borders and was now living in rented accommodation.

The 48-year-old has already repaid £15,000 and pledged to pay back the remaining £5000 within six months.

Sheriff Maciver told McGregor: "You set up an account in another name and diverted funds to this account.

"The matter came to light because HMRC were due money. It has now been agreed that the sum will be repaid to the Scottish Government and they will decide where it should be allocated and, as I understand it, it will be paid to good causes."

He deferred sentence on McGregor for six months to allow the full amount to be repaid.