function getSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		if(document[movieName].length != undefined){
			return document[movieName][1];
		}
		return document[movieName];
	}
}
function callAS(flvClip,noplay) {
	movie = getSWF('flashObject');
	movie.methodName(flvClip,noplay);
}
$(document).ready(function(){
	$total = 0;
	$current = 0;
	$videosToShow = 4;
	$('#videoControls').css('height','38px');
	$('.videoThumb p').css({'display':'none','position':'absolute'});
	$('.videoThumb').css({'display':'none','float':'left'});
	$('.videoThumb').each(function(){
		$total++;
	});
	if ($total<5) {
		$('.more').hide();
	}
	//$('.videoThumb:first a').addClass('selected');
	$('.videoThumb a').click(function(event){
		event.preventDefault();
		callAS($(this).attr('href'),0);
	});
	$('.videoThumb:lt('+$videosToShow+')').css('display','inline');
	
	$('.videoThumb a').hoverIntent(
		function() {
			//var pos = $('#flashVideo').position();
			var pos = $('#videoControls').position();
			var $xpos = pos.left;
			var $ypos = pos.top;
			$('p',$(this).parent()).css({
				'top':$ypos - $('p',$(this).parent()).height() - 21,
				'left':$xpos
			});
			$('p',$(this).parent()).fadeIn('fast');
		},
		function() {
			$('p',$(this).parent()).fadeOut('fast');
		}
	);
	$('.more').click(function(){
		if (($total - $current) > $videosToShow) {
			$current += $videosToShow;
			$('.videoThumb:lt('+$current+')').css('display','none');
			for (i=$current;i<$current+$videosToShow;i++) {
				$('.videoThumb:eq('+i+')').css('display','inline');
			}
		} else {
			$current = 0;
			$('.videoThumb:lt('+$total+')').css('display','none');
			for (i=$current;i<$current+$videosToShow;i++) {
				$('.videoThumb:eq('+i+')').css('display','inline');
			}
		}
	});
	//callAS($('.videoThumb:first a').attr('href'),1);
});