$( document ).ready(function () {
	
	/**********************************************************/
	$(function() { //
		
		if( $('body.videos').length ){
		
			var vid_pag = $('#videos-pagination');
			
			$(vid_pag).css({ paddingLeft : ( Math.floor( ( $(vid_pag).parent().width() - 18 - $(vid_pag).width() ) / 2 ) ) + 'px' });
	
			$('#videos-blocks-container .notFirst').fadeOut();
			var current_page = 1;
			$('li a', $(vid_pag)).click(function(){
				
				var rel = $(this).attr('rel');
				if( rel !=  current_page){
					
					$('#videos-block-ID' + current_page).fadeOut('fast',function(){
						$('#videos-block-ID' + rel ).fadeIn('fast');
					});
	
					current_page = rel;
					$('li a', $(vid_pag)).removeClass('on');
					$(this).addClass('on');
				
					if (typeof pageTracker != 'undefined') {
						pageTracker._trackPageview('/videos/page/'+rel);
					}
				}
				
				return false;
			});
			
		}	
	});// end :: 
	/**********************************************************/

	
	/**********************************************************/
	$(function() { //

		var link_vids = '';
		if( $('body.videos').length ){
			link_vids = $('#videos-blocks-container .video-block a');
		}else{
			link_vids = $('#content-home-videos .video a');
		}
				
		var delay_transition = 300;
		$(link_vids).click(function(){
			var link = $(this);
			
			if (typeof pageTracker != 'undefined') {
				pageTracker._trackPageview('/videos/view/'+$(link).attr('title'));
			}
			$('#popup_overlay').fadeIn(delay_transition);
			$('#popup').fadeIn(delay_transition, function(){
				
				$('#popup h3').html( $(link).attr('title') );
				
				var flashvars = {
					sourceFile : $(link).attr('rel')
				};
				var params = {
					menu				: "false",
					quality				: "best",
					wmode				: "transparent",
					allowFullScreen		: "true",
					bgcolor				: "#000000"
				};
				swfobject.embedSWF("/flash/video.swf", "popup_player_inner", "552px", "312px", "9.0.0", "/flash/expressInstall.swf", flashvars, params);

			});
			
			return false;
		});
		
		$('#popup_overlay a').click(function(){
			$('#popup').fadeOut(delay_transition);
			$('#popup_overlay').fadeOut(delay_transition);
			
			return false;
		});
		$('#popup_overlay').click(function(){
			$('#popup_overlay a').trigger('click');
			
			return false;
		});
		
	});// end :: 
	/**********************************************************/

});




