A quick note that's becoming something of an internal FAQ - the information below is from MSDN.
Detecting Internet Explorer in SP2
You can use window.navigator.userAgent to detect if the browser connecting to your site is Internet Explorer in SP2.
var g_fIsSP2 = false;
g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
//This browser is Internet Explorer in SP2.
//This browser is not Internet Explorer in SP2.
If the user agent string contains "SV1", the browser connecting to your site is Internet Explorer in SP2.
An example SP2 user-agent string looks like this: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)