In Joomla 2.5 JavaScript is not enabled in articles by default, which means, that if you try to place a javascript code into an article and you click Save, the JavaScript code will be automatically removed.
What is the solution?
Log in to your Joomla admin panel and navigate to Extensions > Plug-in Manager and from the "Select type" drop-down menu choose "editors".
In the filtered editors click on "Editor - TinyMCE" and in its configuration screen in the bottom-right corner you will see "Prohibited Elements" and inside it the following definition:
script,applet,iframe
Delete the "script" and "iframe" words from there and click Save.
NOTE: You can not leave that field completely empty, since it will restore the default settings. If you do not wish to prohibit anything, then place there some dummy string (text)
Now, in your Joomla admin navigate to Site > Global Configuration > Text Filters and for "Super user" select 'No Filtering'.
From now on, you can use JavaScript in your articles.