// JavaScript Document

$(function(){
	$('#Article p').first().addClass('firstPara');	
	
	$('.audio_popup').popupWindow({ 
		windowURL:'http://www.elinmanahanthomas.org/audio_player', 
		toolbar:0,
		height:316, 
		width:316, 
		top:50, 
		left:50 
	}); 
		
});

$(document).ready(function(){
	$("a[rel='gallery']").colorbox();
	$(".YouTube").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	$(".Vimeo").colorbox({iframe:true, innerWidth:400, innerHeight:255});
	
	$("#TitleImgFade").fadeIn(1000);
	
	$("#Gallery a:nth-child(6n)").addClass("EndImage img");
	
	$(".DiscColum a:nth-child(2n)").addClass("EndImage img");
	
	$(".DiscColumWIDE a:nth-child(4n)").addClass("EndImage img");
	
	$(".imageCol a:nth-child(2n)").addClass("EndImage img");


});

$(window).load(function(){  
	var max_size = 300;
	
	$(".VidThumb").each(function() {
								 
		if ($(this).height() > $(this).width()) {
		var h = max_size;
		var w = Math.ceil($(this).width() / $(this).height() * max_size);
		} else {
		var w = max_size;
		var h = Math.ceil($(this).height() / $(this).width() * max_size);
		}
		
		$(this).css({ height: h, width: w });
		
		
		//get the width of the parent  
		var parent_height = $(this).parent().height();  
		var parent_width = $(this).parent().width();  

	  
		//get the width of the image  
		var image_height = $(this).height(); 
		var image_width = $(this).width();  
	  
		//calculate how far from top the image should be  
		var top_margin = (parent_height - image_height)/2; 
		var left_margin = (parent_width - image_width)/2;

		//and change the margin-top css attribute of the image  
		$(this).css({'margin-top': top_margin, 'margin-left' : left_margin}); 
	});					
	
}); 
