var slider;
var offset;

var windowWidth = $(window).width();
var windowHeight = $(window).height();

function centerModalVideo(){
	
	$('DIV.modalVideo').css('left', getAbsoluteX());
	$('DIV.modalVideo').css('top', getAbsoluteY());
	
}

function getAbsoluteX(){
	var w = $(window).width();
	var vw = $('DIV.modalVideo').width();
	
	return (w/2) - (vw/2);
}

function getAbsoluteY(){
	var h = $(window).height();
	var vh = $('DIV.modalVideo').height();
	
	return (h/2) - (vh/2);
}

function setDimWidth(){

	var w = $(window).width();
	//var nw = (w - $('DIV#featuredLinksContainer').width()) / 2;	
	var nw = (w - 950) / 2;
	
	$('DIV#leftDim').css('width', nw + 'px');
	$('DIV#rightDim').css('width', nw + 'px');
}

	function delvePlayerCallback(playerId, eventName, data) {
				
		var id = "limelight_player_144528o";
		if (eventName == 'onPlayerLoad' && (DelvePlayer.getPlayers() == null || DelvePlayer.getPlayers().length == 0)) {
		  DelvePlayer.registerPlayer(id);
		}
		
		switch (eventName) {
	      case 'onPlayerLoad':
			
	        break;
			
	      case 'onChannelLoad':
	        break;
	
	      case 'onMediaLoad':

	        break;
	      
	      case 'onMediaComplete':
	      	break;
	
	      case 'onPlayStateChanged':
			
	        break;
	
	      case 'onPlayheadUpdate':

	        break; 
	    }
  	}

$(document).ready(function(){ 	
	
	centerModalVideo();
	setDimWidth();
	
	$(window).resize(function(){
		setDimWidth();
	});
	
	$('a.mediaLink').click(function(event){
		event.preventDefault();
		$('DIV#mediaWindow').fadeIn();
	});
	
	$('a#oppLink').click(function(event){
		event.preventDefault();
		$('DIV#mediaWindow').fadeIn();
	});
	/*
	$('DIV#mediaWindow').click(function(){
		$('DIV#mediaWindow').fadeOut();
	});
	*/
	$('P#modalClose').click(function(event){
		$('DIV#mediaWindow').fadeOut();
		DelvePlayer.doPause();
	});
	
	$('a.storyThumb').click(function(event){
		$('TABLE.thumbTable').find('a.storyThumb IMG').removeClass('current');
		$(this).find('IMG').addClass('current');
	});
	
	
/* featured item rollover */
	
	 
	  
	$('DIV.linkItem').mouseenter(function(){
		$(this).animate({bottom: '-3px'}, 200);
		/*$(this).css('bottom', '-2px');*/
	});
	
	$('DIV.linkItem').mouseleave(function(){
		$(this).animate({bottom: '-54px'}, 200);
		/*$(this).css('bottom', '-44px');*/
	});

/* story rollovers */
	$('DIV.storyItem').mouseenter(function(){
	
		$(this).find('IMG.rollover').toggleClass('hover normal');
	
	});
	
	$('DIV.storyItem').mouseleave(function(){
	
		$(this).find('IMG.rollover').toggleClass('hover normal');
	
	});
	
	
 });
