If you indeed want to do this, you can check the User Agent along the same lines Ext uses to do it.
A snippet from Ext.js:
ua = navigator.userAgent.toLowerCase(),
check = function(r){
return r.test(ua);
},
DOC = document,
isStrict = DOC.compatMode == "CSS1Compat",
isOpera = check(/opera/),
isChrome = check(/\bchrome\b/),
isWebKit = check(/webkit/),
isSafari = !isChrome && check(/safari/),
isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
isSafari3 = isSafari && check(/version\/3/),
isSafari4 = isSafari && check(/version\/4/),
I'm guessing for Safari 5 you could write a similar test where version would be 5, though I did not check what Safari 5's User Agent string looks like myself.