Depends on what you mean by "work".
Looking at the contents of picarr[ ]
and then where you do the
, not a single one of your case
values matches any of your picarr[x]
values, so your switch will *always* end up getting to the default:
and so thelink
will always be just "".
Which means you could throw all this code away and just do
thelink = endlink = "";
and get the same effect.
I won't even comment any more on the fact that you are using obsolete document.write code.