writen for: http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22548479.html check the discussion for more details