This ought to do it.
1. First, I create a variable "agt", which sets the userAgent string to lower case.
2. The next line finds the starting position of the string "m-a-c" in the agent string. If that starting position is not equal to -1 (in other words, if the string is actually there) then the variable "is_mac" is set to a Boolean (true or false) value of "true".
3. Next, set another variable called "version" to be just the integer part of the navigator.appVersion string. This will truncate the decimal part of the version number.
4. Look to see if the string "m-s-i-e" appears in in the agt string (similar to step 2). If it's there (again, not equal to -1), then is_ie is set to "true".
5. Set a new variable to combine the "true or false" value of "is_ie" and the statement "version = 5". This gives us the "true or false" value for is_ie5. According tom Boolean operation, "is-ie5" will be true only if BOTH values are true.
6. The final step. If both "is_mac" and "is_ie5" are true, then replace the current location. I used the replace() method so that the user's Back Button will stay intuitive.