The check is case insensitive but the replacement is not. Suggestions:
```
if( /right/i.match( orientation ) ) {
	return orientation.replace( /right/i, 'left' );
} else {
	return orientation.replace( /left/i, 'right' );
}
```
or
```
return orientation.replace( /left|right/i, /right/i.match( orientation ) ? 'left' : 'right' );
```