$ = jQuery;

var sbullet = 0;
var oldBullet = -1;

$('.slideshow-bullet').click(function () { return false; });

	
function startSlideshow(noSlides) {
    var totalSlideCount = noSlides;
    var $slideshow = $('#slideshow');

    // start slideshow 
    $('#slideshow').cycle({
        fx: 'fade',
            timeout: 15000,
        speed: 200,
        prev: '#prev',
        next: '#next',
        pager : '#slideshowControls',
        after: onAfter
    });
    
    $("#slideshowControls a").each(function(i,item){
		if ( i == 0) $(item).html('<img id="sbullet'+i+'" src="/images/slideshow-bullet-sel.png" alt="" style="margin-right:5px"//>');
		else $(item).html('<img id="sbullet'+i+'" src="/images/slideshow-bullet.png" alt="" style="margin-right:5px"/>');
    })
    
    

    function onAfter(curr, next, opts, fwd) {
        if ($('#sbullet' + oldBullet).length > 0)
            $('#sbullet' + oldBullet).attr('src', '/images/slideshow-bullet.png');
        var cs = opts.currSlide;
        if (cs < 0 || cs >= totalSlideCount) cs = 0;
        $('#sbullet' + cs).attr('src', '/images/slideshow-bullet-sel.png');

        oldBullet = cs;
    }
};



