$(function(){
	$('.videoLink').click(changeVideo);
});


function changeVideo(){
	var videoLink = $(this).attr('href');
	var regex = /^.*videoId=/gi
	var videoCode = videoLink.replace(regex,'');
	var embedCode = '<object width="640" height="360"><param value="transparent" name="wmode"></param>';
	embedCode += '<param name="movie" value="http://www.youtube.com/v/' + videoCode + '?version=3&f=playlists&app=youtube_gdata&rel=0&border=0&fs=1&autoplay=0&modestbranding=1"></param>';   
	embedCode += '<param name="allowFullScreen" value="true"></param>';
	embedCode += '<param name="allowscriptaccess" value="always"></param>';
	embedCode += '<param name="modestbranding" value="1"></param>';
	embedCode += '<embed src="http://www.youtube.com/v/' + videoCode + '?version=3&f=playlists&app=youtube_gdata&rel=0&border=0&fs=1&autoplay=0&modestbranding=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="640" height="360"></embed>';
	embedCode += '</object>';
	
	$('#playerContainer').html(embedCode);
	return false;
}
function pagination(startNum){
	$.ajax({
	   type: "GET",
	   url: "/includes/videochannel/video_inner.php",
	   data: "starting="+startNum,
	   success: function(msg){
			$('#vidLinks').html(msg);
			$('.videoLink').click(changeVideo);
	   }
	 });
}
