This is an UNSUPPORTED customization and may break your customization's (while installing further roll-up's). Shared just for learning purpose and not recommended to use in any CRM environment.
We expected 'document.getElementById("to").setAttribute()' to work as expected, but it didn't work as expected, rather it also didn't throw any script errors too. Will analyzing more we found that CRM 2013 form structure is driven by series of div components in order to improve performance.
Then finally identified 'document.getElementById("to_i").setAttribute()' div was available and tired to use it, and surprisingly it worked. Below is the code snippet which helped to filter entities in CRM 2013 lookup fields.
Note: This is an identified bug in CRM 2013 and reported to Microsoft. We can expect the fix for the same in the coming Rollup's.