Change system input/keyboard language

Hi,

This is not a duplicate of http://bbs.applescript.net/viewtopic.php?id=24310 because it’s a different question. It doesn’t look like anyone knows how to run an action on a fast-user switch despite this: http://www.radiotope.com/content/os-x-how-perform-action-during-fast-user-switch.

This question is:

Does anyone know how to change the selected input language using Apple Script?

Thanks