As of the Superbank release, this code no longer works. The component.type field has been renamed to component._componentType. The fix is simply to change the switch statement from:
switch ( component.type ){
to
switch ( component._componentType ){
Enjoy!
- Chris