$('HTML').addClass('JS');
var picno = 1, imageList = [], captionList = [], cycleStarted = false;

$(function() {
    $('a[rel$="external"]').addClass("external").click(function(){ this.target = "_blank"; });



});

function changeImage(newpic,nocap){
    var currentBG = $('#bg img').attr('src');
    $('#bg2 img').attr('src', currentBG);
    $('#bg2 img').show();
    var img = new Image();
    $(img).load(function () {
        $('#bg').empty();
        $('#bg').append(this);
        $(this).css({width:'100%',height:'auto'})
        $('#bg2 img').fadeOut(1000);
        if(nocap !=1){
            $('#sscaption').html(captionList[picno]+'&nbsp;&nbsp;');
            picno = picno + 1;
            if (picno > imageList.length - 1){picno = 0}
        }
    }).attr('src', newpic );
}

function cycleImages() {
        cycleStarted = true;
	if (imageList[picno] != undefined ){
            changeImage('/lib/'+imageList[picno]);
            setTimeout("cycleImages()", 5000);
	}else{
            cycleStarted = false;
        }
}
