When scripting is enabled, numbers appear next to your pages (for instance, "[#1] The First Page"). Take note of these page ID numbers.
For every link leading to the area, you would put in a code like this:
IF %THUGS = 1 THEN $DEST := @P[#1] ELSE $DEST := @P[#2]
Replace the [#1] with the page ID number for the thugs encounter and the [#2] with the page ID without the encounter. (For instance if the thug encounter is page #31 then @P[#1] should be @P31).
The script is an "if statement" that checks the variable THUGS. If it's 1, then the destination for the link is set to the encounter. If it isn't, the destination is the page without the encounter. You might want to take a look at the articles The Basics of Scripting and Intermediate Scripting for more info on the scripting language of CYS.