Javascript is capable of writing files in the user's cache folder, and in shell-executing system resident executables, among other things. This combination is especially dangerous when coupled with zero day exploits, such as those in older versions of the JVM, and older security holes in browsers, like the EMF code execution exploit.
Basically, a javascript can function as a dropper, drop malicious executables into the user's cache foler, then shell execute say, javaw.exe on it, and escallate out of the browser using that-- or, on an older and vulnerable browser (like IE6 that refuses to fucking die!) They could drop a harmless looking EMF image file that contains malicious executable code, and make use of a horrible kludge from the old win3.11 days to do very nasty things indeed.
If the user is foolish enough to be driving under an admin capable account already, then the shell executed script can do whatever the hell it wants to!
If I were a malicous program maker, I would first call in a new javascript file offsite that does a background check on the browser using its useragent string, and a few probes of other resouces, to determine what exploit to attempt, or simply to stop gracefully. It would then call the appropriate exploit script from aother external dependency, and do its nsty business.
From your end, looking at the trojan vector snippet, all you would see is a suspicious call to "secretsauce.js", which is obfuscated javascript. Being obfuscated, unless you are super good, you won't be able to read it, while the browser can. (That's the point!).
The only way to prevent this, is some very hard rules about cross linking javascripts. NO OUTSIDE SCRIPTS, NO OBFUSCATED SCRIPTS, NO LOCAL FILE WRITES.
Such rules would have to be backed up with viggorous enforcement and active policing, especially if the site became popular.
Much like with the advert industry, the desire to do those very things by customers is VERY high. (Google "evercookie"). As such, the advert servers invariably become unwhitting hosts to malware, as uploaded attack scripts enter the system faster than they can be reported and removed.