how to implement jquery image gallery in drupal theme tpl.php files?
If you want the bluemasters rotator exactly, you need to copy their javascript and css that apply to the rotator element (image_reel) and install it in your theme. The following instructions would also be relevant for other slideshow scripts with obvious substituions.

First, you need to add the rotator script from bluemasters to your theme. The name of the file is bluemasters.js and is in bluemasters/js/ in the theme folder. 

To install it in your theme, you could just add it as a script tag in your page.tpl.php file in your template, ex:

&lt;script type="text/javascript" src="&lt;?php echo path_to_theme(); ?&gt;/path/to/bluemasters.js"&gt;&lt;/script&gt;


There are much better ways of adding this, using drupal_add_js and page_preprocess functions but this is the easiest way to make sure it is loaded on every page. 

Next, you're going to need to isolate the css bluemasters is using to create their slider. From their css file, it looks like all of the css for the front page slider is in one block in the file, starting with the comment 'Front-page slider'

/*
 * Front-page Slider 
 */
.main_view { float: left; position: relative; }

...etc.


Grab that and add it to your theme's css file.

If you've got these two files added to your theme correctly, then anywhere the image_reel class exists (with the following structure) on your pages, their code will convert it into a slideshow. The exact structure (from their demo file) is just a list of links like this:

        &lt;div class="image_reel"&gt;
            &lt;a href="/bluemasters/node/3"&gt;&lt;img src="/bluemasters/sites/all/themes/bluemasters/images/slide-image-3.jpg"&gt;&lt;/a&gt;
            &lt;a href="/bluemasters/node/2"&gt;&lt;img src="/bluemasters/sites/all/themes/bluemasters/images/slide-image-2.jpg"&gt;&lt;/a&gt;
            &lt;a href="/bluemasters/node/1"&gt;&lt;img src="/bluemasters/sites/all/themes/bluemasters/images/slide-image-1.jpg"&gt;&lt;/a&gt;
        &lt;/div&gt;


You can add this code in as a block or on a page or in your template directly and it will create the same slider effect.