How do I add JavaScript specific for a view? I have a view in my site that has a specific class name. I want to know, inside the template.php file of a theme, how I can know if a view with specific class name is available in the requested page.

This is very important for me because I need to include specific JavaScript and CSS, when a view with a specific class name (such as image-gallery) is used in a page.
You could use the template_preprocess_views_view() hook to do this:

function THEME_preprocess_views_view(&amp;$vars) {
  $view = &amp;$vars['view'];
  // Make sure it's the correct view
  if ($view-&gt;name == 'your-view-name') {
    // add needed javascript
    drupal_add_js(drupal_get_path('theme', 'your-theme') . '/your-js.js');
    // add needed stylesheet
    drupal_add_css(drupal_get_path('theme', 'your-theme') . '/your-css.css');
  }
}


Note that you could also check the specific display of the view using:

if ($view-&gt;name == 'your-view-name' &amp;&amp; $view-&gt;current_display == 'your-display-id') {
  // include javascript &amp; css here
}


You should be able to check for a custom css class like this:

if ($view-&gt;name == 'your-view-name' &amp;&amp; $view-&gt;display[$view-&gt;current_display]-&gt;display_options['css_class'] == 'your-css-class') {
   // include javascript &amp; css here
}