var selectedVideo;
var currentSlide    = 0;
var transitionTime  = 8; //in seconds
var baseurl         = location.href.substring(0, location.href.indexOf('/', 14 )) + '/';
//var baseurl         = 'http://www.basfturftalk.com/';    
        function autoPlay(){
            if(currentSlide == 3){
                currentSlide = 0;
            }else{
                currentSlide++;
            }
            $('.slider-panel').fadeOut(500, function(){
                //$('#content-slider-contain').animate({scrollLeft: currentSlide * 740});
                $('#content-slider-contain').scrollLeft(currentSlide * 740);
                $('.slider-panel').fadeIn(500);
                $('#content-slider-control li a').removeClass('active');
                $('#content-slider-control li a').eq(currentSlide).addClass('active');
            });

        }

        $(document).ready(function(){
            //begin slideshow
            var t = setInterval('autoPlay();', transitionTime * 1000);
            
            var numPosts = $('.slider-panel-contain').length;
            var postWidth = $('.slider-panel-contain').width() + 20;
            
            $('#content-slider-control li a').first().addClass('active');
            $('#content-slider').width(numPosts * postWidth);
            $('#content-slider-control li a.slideNumber').click(function(){
                clearInterval(t);
                var slideNum = $(this).parent().index();
                currentSlide = slideNum;
                $('#content-slider-control li a').removeClass('active');
                $(this).addClass('active');
                $('.slider-panel').fadeOut(250, function(){
                    $('#content-slider-contain').scrollLeft(slideNum * postWidth);
                    $('.slider-panel').fadeIn(500);
                    $('#content-slider-control li a').removeClass('active');
                    $('#content-slider-control li a').eq(currentSlide).addClass('active');
                });
                return false;
            });
            
            $('.video-list a.video').click(function(event){
		event.preventDefault();
                selectedVideo = $(this).attr('href');
                $('#mediaspace').children().remove();
                $('#mediaspace').load( baseurl + 'proplayer', {url: selectedVideo} ); 
                return false;
            });
            
            $('.video-item').mouseover(function(){
                $(this).addClass('video-hover');
            });
            $('.video-item').mouseout(function(){
                $(this).removeClass('video-hover');
            });
            
            $('#cat-archive').change(function(){
                window.location = '../' + $(this).val();
            });
//            $('#background-image img').width($(window).width());
//            $('#background-image').fadeIn();

            //split archives into 2 columns
            //get number of items in the list and divide them
            var colSplit = $('#monthly-container li').length/2;
            //slice out the second half of list and append it to right column
            $('#monthly-container li').slice(-colSplit).appendTo('#monthly-col-right');
        });
        
        
//        $(window).resize(function(){
//            if($(window).width() > ($('#wrap').width() + 100)){
//                $('#background-image img').width($(window).width());
//            }
//        });

