$(document).ready(function(){
	$(window).load(function(){
		large1 = Math.max($(".colOne").height(),$(".colTwo").height());
		$(".colOne, .colTwo").css("height",((large1/10)+"em"));
		larger1 = Math.max($(".colThree:eq(1)").height(),$(".colThree:eq(2)").height());
		//alert(larger1);
		larger2 = Math.max(larger1,$(".colThree:eq(3)").height());
		//alert(larger2);
		$(".colThree").css("height",((larger2/10)+"em"));
	});
	$("#main, html, body").css("min-height","100%");
	$("#footerMenu li a").click(function(){
		//alert($("#wrapper").height());
		if(!$(this).hasClass("active")){
			$("#footerMenu li a").removeClass("active");
			curTab = "#"+$(this).attr("class");
			$(".expand").animate({
				height: "0px"
			},300,function(){							 
				$(curTab).animate({
					height: "45em"
				},300);
				$("html,body").animate({scrollTop: $("#wrapper").height()},330);
			});
			$(this).addClass("active");
			return false;
		} else {
			$(this).removeClass("active");
			$(".expand").animate({
				height: "0em"
			},300);
			return false;
		}
	});
	
	
	/* moved to css, don't need this, but keeping just in case
	$("#navigationPrimary li").mouseover(function(){
		$(this).children("ul").css("display","block");					  
	});
	$("#navigationPrimary li").mouseout(function(){
		$(this).children("ul").css("display","none");					  
	});
	
	//if($.browser.msie && (jQuery.browser.version < 7)){
	//	$("#navigationPrimary li ul li a").css("letter-spacing","-1px");
	//}
	$("#navigationPrimary>li>a").each(function(){
		var curTitle = $(this).attr("title");
		curTitle = curTitle.toLowerCase();
		var newTitle = curTitle.replace(" ","");
		var newTitle = newTitle.replace(" ","");
		var imgSrc = "url(images/main_" + newTitle + ".gif)";
		$(this).append("<img src='images/main_"+newTitle+".gif' />");		
		$(this).css("background-image",imgSrc);
		//$(this).children("img").remove();
	});
	$("#navigationPrimary>li>ul>li>a").each(function(){
		var curTitle = $(this).attr("title");
		curTitle = curTitle.toLowerCase();
		var newTitle = curTitle.replace(" ","");
		var newTitle = newTitle.replace(" ","");
		var newTitle = newTitle.replace(" ","");
		var newTitle = newTitle.replace(" ","");
		var imgSrc = "url(images/sub_" + newTitle + ".gif)";
		$(this).append("<img src='images/sub_"+newTitle+".gif' />");		
		$(this).css("background-image",imgSrc);
	});
	$("#navigationPrimary li ul li:last-child a").css("border-right","none");
	*/
	
	
	// provides a system to create advanced captions
	$('p.captionLeft + p.captionLeft').each(function(){
		$(this).prev('p.captionLeft').andSelf().wrapAll("<div class='captionedImagesLeft'>");
	});

	$('.captionedImagesLeft').each(function(){
		var imageWidth = $(this).find("img").width();
		$(this).css({
			'width': imageWidth
		});
	});
	$('p.captionRight + p.captionRight').each(function(){
		$(this).prev('p.captionRight').andSelf().wrapAll("<div class='captionedImagesRight'>");
	});

	$('.captionedImagesRight').each(function(){
		var imageWidth = $(this).find("img").width();
		$(this).css({
			'width': imageWidth
		});
	});
	
	
	// print image gallery
	
	$('.printGallery .ngg-gallery-thumbnail-box').each(function(){
		var imageLink = $(this).find('a').attr('href');
		// alert('imageLink');
		var nameArray = imageLink.split("/");
		var imageName = nameArray[(nameArray.length - 1)];
		var imageNameSansFiletype = imageName.split('.');
		var printImageLink = 'http://hnoc.org/press_images/' + imageNameSansFiletype[0] + '.zip';
		
		$(this).append('<div class="printLink"><a href="' + printImageLink + '">Download Print Image</a></div>');
		
	})
	
});
