//Redeclaring $ as $j to prevent conflicts from ad servers like Undertone.

var $j = jQuery.noConflict();

function flashBox(url) {
	$j('#flashbox').flash({
        swf: url,
        width: '480',
        height: '302',
        flashvars: {
            autoStart: 'true'
        }
    });
}

// Create/Update video box
function blipJSON(data) {
	flashBox(data[0]['url']);
	var img = 'http://cdn.nesn.com/cat/cat_video_120.jpg';
	$j.each(data, function (i, post) {
		if(i == 6) {return false;}
		if(post['img']) {
			img = post['img'];
		}
	    $j('.video-promo').append('<li><a href="http://www.nesn.com/video/" target="_blank" data-url="' + post['url'] + '"><img src="' + img + '" /></a><br /><a href="http://www.nesn.com/video/" data-url="' + post['url'] + '" class="title">' + post['title'] + '</a></li>');
    });
	
	$j('.video-promo a').click(function() {
		flashBox($j(this).attr('data-url'));
		return false;
	});
}

// Get blip feed
function blipAJAX() {
    if($j('#flashbox')[0]) {
        $j.ajax({
            dataType: 'jsonp',
            jsonpCallback: 'blipJSON',
            url: 'http://proxy.nesn.com/exports/nesnnation-bliptv.js'
        });
    }
}

$j(document).ready(function() {
    blipAJAX();
    
	if($j('#tabs')[0]) {
        $j('#tabs').tabs();
    }
	
	function handleSliderChange(e, ui) {
  		var maxScroll = 1030 - $j("#content-scroll").width();
  		$j("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
	}

	function handleSliderSlide(e, ui) {
  		var maxScroll = 1030 - $j("#content-scroll").width();
  		$j("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
	}
	
	$j("#content-slider").slider({
		animate: true,
		change: handleSliderChange,
		slide: handleSliderSlide
  	});
});

<!-- ph=1 -->

