jQuery(document).ready(function() {
	if( typeof( flashRotator ) != 'undefined' ) {
	flashPlay("#flash0", flashRotator.src[0]);
	jQuery('.slideshow').cycle({
			fx:	'fade',
			speed:	1,
			timeoutFn: calculateTimeout
		});
	}

   function flashPlay(id, flashsrc) {
     jQuery(id).flash({
            src: flashsrc,
            width: $('#bannerRotator').width(),
            height: $('#bannerRotator').height(),
            wmode: "transparent"
         });
   }

   jQuery('#goto0').click(function() {
    jQuery('.slideshow').cycle(0);
//    jQuery('#bannerRotator a').removeClass("act");
//    jQuery(this).addClass("act");
    return false;
   });

   jQuery('#goto1').click(function() {
    jQuery('.slideshow').cycle(1);
//    jQuery('#bannerRotator a').removeClass("act");
//    jQuery(this).addClass("act");
    return false;
   });

   // timeouts per slide (in seconds)
   function calculateTimeout(currElement, nextElement, opts, isForward) {
     var timeouts = flashRotator.timeouts;
     var src = flashRotator.src;

     var index = opts.currSlide;
//     jQuery('#bannerRotator a').removeClass("act");
//     jQuery("#goto"+index).addClass("act");
     flashPlay("#flash"+index, src[index]);
     return timeouts[index] * 1000;
   }

});