// JavaScript Document

$(document).ready(function () {

		$('.text p.MsoNormal span span').css({'font-family':'Helvetica,Arial,sans-serif', 'font-size': '10px'});
		$('.text p.MsoNormal span').css({'font-family':'Helvetica,Arial,sans-serif', 'font-size': '10px'});	
		$('.text p span').css({'font-family':'Helvetica,Arial,sans-serif', 'font-size': '10px'});			

		$('.tmpSlideCopy p.MsoNormal span').css({'font': '11px/1.75em Arial,sans-serif'});
		$('.tmpSlideCopy p span').css({'font': '11px/1.75em Arial,sans-serif'});
		$('.tmpSlideCopy p.MsoNormal span span').css({'font': '11px/1.75em Arial,sans-serif'});

    $(".npcoursel").jCarouselLite({
        visible: 4,
        start: 0,
        scroll: 1,
        btnNext: "#wrapper .next",
        btnPrev: "#wrapper .prev"
    });

    function animateCarousel (els) {
			

        // Where are we?
        var cur = $('.npcoursel .selected').prevAll().length;
				cur = cur + 1;
        // Where to next?
        var next = (cur == $('.npcoursel li').length - 1) ? 0 : cur + 1;
				
				next = (next == 0) ? next + 1 : next ;

 //console.log('---- next = ' + next + '---- cur = ' + cur +'----');
 //console.log($('.npcoursel li:nth-child('+ next +')'));

        $('.npcoursel li:nth-child('+ cur +')').removeClass('selected');
        $('.npcoursel li:nth-child('+ next +')').addClass('selected');
        var el = $('.npcoursel li:nth-child('+ next +')').find('div.new-banner').html();
        $('#banner-rotator').html(el);
    }


    // Start by "select"ing 4th item (since that's the first "big picture" that shows up)
    $('.npcoursel li:nth-child(5)').addClass('selected');
		
    var carusel_timer = setInterval(animateCarousel, 6000, $('.npcoursel li'));
    $('a.view-banner').click(function () {
        $('.npcoursel').find('.selected').removeClass('selected');
        $(this).parent().addClass('selected');
        var el = $(this).parent().find('div.new-banner').html();
        $('#banner-rotator').html(el);
        clearInterval(carusel_timer); // stop timer on first click
    });


});


