call a js function on loading a page is it possible to call a javascript(jquery) function once a particular page is loaded. It should be hacking the  of the whole site and to detect what the current page is and call the function. How can I actually do this? 

So in a non-drupal php site, I would add a js file and have a start_product_content() function there. In the head.php file it would be something like this:

...
&lt;head&gt;
    ...
    &lt;?php if $current_page = "product" ?&gt;
    start_product_content()
    ...
&lt;/head&gt;
...


I have explained in a different post about what I really want to achieve, long story: footer link to a page with hash changed content ready

I have achieved this when I was doing a non-drupal website, now I just want to be able to do this so that I can be closer to the target. 

Thanks
If you want to add arbitrary code to the &lt;head&gt; element you need to:


Take a copy of the core html.tpl.php file and put it in your theme somewhere
Clear the caches so it gets added to the theme registry
Implement hook_preprocess_html() in your theme's template.php file like so

function MYTHEME_preprocess_html(&amp;$vars) {
  $vars['some_var'] = 'Something';
}

In the html.tpl.php file, use

print $some_var;


wherever that might be appropriate.


If you want to add structured code to the &lt;head&gt; tag then use drupal_add_html_head().

Finally, specifically to add JS to the page, you can use drupal_add_js(). But that needs to happen before the HTML template is processed. hook_preprocess_page() would be one option, but there are many, depending on the context that makes up your page.

You'll find the Theming guide, and questions already asked on this site, invaluable if you're learning the theme system from scratch.