It's because the generated javascript is wrong. You have a 'function' keyword too much. You get:
<script language='javascript'>function switchactionpanel(1)</script>
which doesn't make sense. Just make sure you get
<script language='javascript'>switchactionpanel(1)</script>
and you should be fine. Remove the 'function' keyword here:
String switchAction = "<script language='javascript'>function switchactionpanel(" + (int)((Global.upAction) Enum.Parse(typeof(Global.upAction), Global.ProfileAction.ToString())) + ")</script>";