If you want to add your javascript to Joomla! header from your component, you can do it like this:
JHTML::_('behavior.mootools');
$doc =& JFactory::getDocument();
$js = "
function show(options)
{
$('update').innerHTML = '<div align=".'"center"'."><img src="/.'"images/ajax-loader.gif" width="66" height="66"/>'."<p/>Prosim poĂŤakajte</div>'
var ajaxRequest = new Ajax('index.php', {
method: 'get',
onComplete: function(response) {
$('update').innerHTML = response;
}
});
ajaxRequest.request(options);
}
window.addEvent('domready', function()
{
$('form1').addEvent('submit', function(e)
{ $('update').innerHTML = '<div align=".'"center"'."><img src="/.'"images/ajax-loader.gif" width="66" height="66"/>'."<p/>Prosim poĂŤakajte</div>'
// Stop the form from submitting
new Event(e).stop();
// Update the page
this.send({ update: $('update') });
});
});";
$doc->addScriptDeclaration($js);
Javascript in component you can add only once, if you try to do it twice, one javascript will be overwriten with another.Ă