I suggest step by step debugging, http://www.codeguru.com/forum/showthread.php?t=360659.