Below is my current script:
Your "Windows XP" line is not working as Windows XP identifies itself as "Windows NT 5.1".
However, I'm curious as to why you'd want to do this at all. UserAgent sniffing in any form is generally frowned upon in the web-development community - there's always a far better (usually far easier) way.