Rajeev,
You can also use an output script control ... In your XPage, where you want the script located, click the Create menu, and pick Other, then expand Core Controls and pick Output Script ... this allows you to embed a client side script using a script editor, etc ... and you don't have to fake it with the text control.