jq(document).ready(function(){

        jq('#slideshow').cycle({ //variables for jQuery photo gallery
                                                                 next: '#photoNext',
                                                                 prev: '#photoPrev',
                                                                 startingSlide: 0,
                                                                 timeout: 0,
                                                                 before: function(curr, next, opts) {
									     jq('#imageName').html(next.title);
                                                                             jq('#imageNumber').html('Image ' + next.alt + ' of ' + 
                                                                             jq('#slideshow').children().size());
                                                                         },
                                                                 after: function() {
                                                                 },
                                                                 pager: '#slideshowRightNav',
                                                                 pagerAnchorBuilder: function(idx, slide) {
                                                                         // return sel string for existing anchor
                                                                         return '#slideshowRightNav a:eq(' + (idx) + ')';
                                                                 }
                                                                 });

        jq('#slideshowRightNav a').html('<img src="++resource++kci.theme.images/galleryactive.gif">');

        //cycle is unhappy if there's only one slide. manually set caption.
        if(jq('#slideshow').children().size() == 1){
            //jq('#slideshowRightNav').addClass('hide');
            jq('#imageName').html(jq('#slideshow').find('img').attr('title'));
            jq('#imageNumber').html('Image 1 of 1');
        }


        jq('#playFlash').click(function(){ //hide gallery when clicked
                jq('#slideshow').addClass('hide');
                jq('#movie').removeClass('hide');
                jq('#movie').css('background', '#000');


                //set the caption
                jq('#imageName').html(jq('#movie_caption').text());
                jq('#imageNumber').text(' ');

        });


        jq('#slideshowRightNav a').click(function(){ //show gallery when thumbnails are clicked
                jq('#slideshow').removeClass('hide');
                jq('#movie').addClass('hide');
        });

});

