Refactored the vb_set_mode function.

I hope now it's better to see what's done.
Added command to run javascript from input box.