I think the conditional statement has to occue AFTER the global $sitepress statement, so perhaps this would be the fix:
// WPML
if( $options['lang'] )
{
global $sitepress;
if( !empty($sitepress) )
{
$sitepress->switch_lang( $options['lang'] );
}
}
Can you try that and let me know if it works?
Thanks
E