/**
 * @author Artjom Kurapov
 * @since 26.08.11 17:47
 */
/* YT related */
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";

var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

var player;

function onYouTubePlayerAPIReady() {
	player = new YT.Player('player', {
		width: '640',
		height: '390',
		videoId: first_video_id
	});
	//$()
}

function loadVideo(url, ref) {
	player.loadVideoById(url, 0, 'medium');
	$('#videothumbs UL A.active').removeClass('active');
	$(ref).addClass('active');
	return false;
}

$(document).ready(function(){
	$('#videothumbs-down').click(function(){
		if($('#videothumbs UL').is(':not(:animated)') && $('#videothumbs UL').outerHeight() > $('#videothumbs').outerHeight() && $('#videothumbs UL').outerHeight() + parseInt($('#videothumbs UL').css('marginTop')) - $('#videothumbs UL LI:first').outerHeight() > $('#videothumbs').outerHeight() ){
			$('#videothumbs UL').animate({
				marginTop: '-='+$('#videothumbs UL LI:first').outerHeight()+'px'
			},{
				duration: 300,
				queue: false
			});
		}
		return false;
	});

	$('#videothumbs-up').click(function(){
		if($('#videothumbs UL').is(':not(:animated)') && $('#videothumbs UL').outerHeight() > $('#videothumbs').outerHeight() && 0-parseInt($('#videothumbs UL').css('marginTop')) >= $('#videothumbs UL LI:first').outerHeight() ){
			$('#videothumbs UL').animate({
				marginTop: '+='+$('#videothumbs UL LI:first').outerHeight()+'px'
			},{
				duration: 300,
				queue: false
			});
		}
		return false;
	});
});

