take a look on the code in the link which Zaf Khan was given in his post.