$(document).ready(function() {
	loadVideo();
});


function loadVideo() {
	flowplayer('player', {src: 'js/flowplayer-3.1.5.swf', wmode: 'opaque'}, {
		canvas: {backgroundColor: 'transparent'},
		clip:  { 
			autoPlay:true
		},
		plugins: {
			controls: {
				url: 'js/flowplayer.controls-3.1.5.swf', 
				backgroundColor: '#333333',
				backgroundGradient: 'none',
				volume: false,
				mute: true,
				time:false,
				stop:true,
				fullscreen:true,
				progressGradient: 'none',
				progressColor: '#AFBD21',
				buttonColor: '#333333',
				buttonOverColor: '#AFBD21',
				sliderColor: '#000000',
				bufferColor: '#000000',
				tooltipColor: '#AFBD21'
			},
			content: {
				// the only required property 
				url: 'js/flowplayer.content-3.1.0.swf', 
				 
				// some display properties 
				padding:'5px 10px 5px 10px',
				bottom:25,
				backgroundColor: '#000000', 
				opacity: 0,
				
				 
				// one styling property  
				borderRadius: '0',
				width: '344px',
				 
				// content plugin specific properties 
				html: '', 
				style: {p: {fontSize: 12}}
			}
		}
	});

	$('.vidOpt a').click(function() {
		// play the clip specified in href- attribute with Flowplayer
		$newLink = $(this).attr('href');
		$newImage = $(this).children('img').attr('class');
		newIndex = $newImage.substr($newImage.length-1,1);
		
		$player = $('.player');
		$playerImg = $player.attr('id');
		oldIndex = $playerImg.substr($playerImg.length-1,1);
		$oldLink = $player.children('a').attr('href');
		
		$f().play(this.getAttribute("href", 2));
		
		$player.attr({'id': $newImage, 'href': $newLink});
		$(this).attr('href', $oldLink).children('img').attr({'src': '/images/UCA_Community/'+$playerImg+'.gif', 'class': $playerImg });
		
		$('#textTop').attr('src', '/images/UCA_Community/vidText_top' + newIndex + '.png');
		
		indexClicked = $('.vidOpt a').index($(this));
		$('.contentWrap img').eq(indexClicked+1).attr('src', '/images/UCA_Community/vidText_small' + oldIndex + '.png');
		
		// by returning false normal link behaviour is skipped
		return false;
	});

}


