I'm making a website that contains CSS that only works in Firefox 3.5+ and Safari 4+

I would like to redirect people to my home.htm if they have either FF 3.5+ or Safari 4+.

If they have any other kind of browser or version, I would like them redirected to sorry.htm

I managed to get hold of a script that should do this, but it doesn't appear to work.

Here it is:

Code:
<script>
var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)
if (browser_type=="Firefox"&&browser_version>=3.5)
window.location.replace("home.htm")
else if (browser_type=="Safari"&&browser_version>=4)
window.location.replace("home.htm")
else
window.location="sorry.htm"
</script>
I've put this in the <head> section.

However, when I try it in my browser (Firefox 3.5.3) it takes me to sorry.htm
And when I try it in Safari 4.0.2 it also takes me to sorry.htm

How come this doesn't work? Can anybody help me with this?

Thanks in advance! I appreciate your time ^_^