In your code in each dialog you are using
if ($AllowCreateFolder!="true")
{
echo "alert('".GetString("NoPermission")."');";
echo "return;";
}
The command GetString("NoPermission") is returning a string containing a ' which breaks the alert command.
GetString("NoPermission") returns:-
Forbidden. You don't have permission to access this function.
You need to slash out the ' in don't.