var $currentTvPage = 1;
var $currentFilmPage = 1;
var $currentNewsPage = 1;

/* code for animating the video scroller */
function tvTabScroller() {

	var $tvPages = $('#tv_spots .tvPage').length;
	$('#tvNavBox .pageCount').text('page 1 of ' + $tvPages);
	$('#tvNavBox .rightArrow, #tvNavBox .leftArrow').css('cursor','pointer');
	var $tvPageWidth = '900';
	
	$('#tvNavBox .leftArrow').click(function() {
		if( $currentTvPage > 1 ) {
			$('#tvScrollHolder').animate({
				marginLeft: "+=" + $tvPageWidth + "px"
			}, 1500);
			
			$currentTvPage--;
			$('#tvNavBox .pageCount').text('page ' + $currentTvPage + ' of ' + $tvPages);
		}
	});
	$('#tvNavBox .rightArrow').click(function() {
		if( $currentTvPage < $tvPages ) {
			$('#tvScrollHolder').animate({
				marginLeft: "-=" + $tvPageWidth + "px"
			}, 1500);
			
			$currentTvPage++;
			$('#tvNavBox .pageCount').text('page ' + $currentTvPage + ' of ' + $tvPages);
		}
	});
    
}

function filmTabScroller() {
    var $filmPages = $('#open_film .tvPage').length;
    $('#filmNavBox .pageCount').text('page 1 of ' + $filmPages);
    $('#filmNavBox .rightArrow, #filmNavBox .leftArrow').css('cursor', 'pointer');
    var $filmPageWidth = '900';

    $('#filmNavBox .leftArrow').click(function () {
        if ($currentFilmPage > 1) {
            $('#filmScrollHolder').animate({
                marginLeft: "+=" + $filmPageWidth + "px"
            }, 1500);

            $currentFilmPage--;
            $('#filmNavBox .pageCount').text('page ' + $currentFilmPage + ' of ' + $filmPages);
        }
    });
    $('#filmNavBox .rightArrow').click(function () {
        if ($currentFilmPage < $filmPages) {
            $('#filmScrollHolder').animate({
                marginLeft: "-=" + $filmPageWidth + "px"
            }, 1500);

            $currentFilmPage++;
            $('#filmNavBox .pageCount').text('page ' + $currentFilmPage + ' of ' + $filmPages);
        }
    });
}

function newsTabScroller() {
	/* code for animating the news scroller */
	var $newsPages = $('.newsPage').length;
	$('#newsNavBox .pageCount').text('page 1 of ' + $newsPages);
	var $newsPageWidth = '900';

	$('#newsNavBox .leftArrow').click(function () {
	    if ($currentNewsPage > 1) {
	        $('#newsScrollHolder').animate({
	            marginLeft: "+=" + $newsPageWidth + "px"
	        }, 1500);

	        $currentNewsPage--;
	        $('#newsNavBox .pageCount').text('page ' + $currentNewsPage + ' of ' + $newsPages);
	        console.log('page: ' + $currentNewsPage);
	    }
	});

	$('#newsNavBox .rightArrow').click(function() {
		if( $currentNewsPage < $newsPages ) {
			$('#newsScrollHolder').animate({
				marginLeft: '-=' + $newsPageWidth + 'px'
			}, 1500);
			
			$currentNewsPage++;
			$('#newsNavBox .pageCount').text('page ' + $currentNewsPage + ' of ' + $newsPages);
			console.log('page: ' + $currentNewsPage);
		}
	});
}
