// JavaScript Document
var imgs;
var origHeights = [];

$(function(){
		   
	/**/	  
	$("#content").wrapInner("<table><tr>");
	$(".section").wrap("<td>");
	
	$(".section").wrapInner("<table><tr>");
	$(".project").wrap("<td>");

	$(".project").wrapInner("<table><tr>");
	$(".project .project_main").wrap("<td>");
	$(".project .images").wrap("<td>");

	$(".project .images").wrapInner("<table><tr>");
	$(".project .images img").wrap("<td>");
	
	$("#awards_main").wrapInner("<table><tr>");
	$("#awards_main #award_items").wrap("<td>");
	
	$("#award_items").wrapInner("<table><tr>");
	$("#award_items .award").wrap("<td>");
	
	
	// remove css necessary for javascript disabled browsers
	$("#content").css("padding-bottom","0");
	$(".section").css("margin-bottom","0");
	$(".images img").css("margin-bottom","0");
	$("ul#nav").css("background" , "none");
	
	// main scrolling hack
	imgs = $.makeArray( $(".images img"));
	
	$.each(imgs , function(){
		origHeights.push( $(this).attr('height') );
	});

	resizeImgs();
	$(window).resize(function() {
		resizeImgs();
	});
});

function resizeImgs()
{
	if($(window).height() > 600)
	{
		$.each( imgs , function(index){							
			if( ((this.y + this.height) > $(window).height()) ||
				(this.height < origHeights[index]))										  											
			{
				this.height = $(window).height() - this.y;
			}
			if(this.height > origHeights[index])
			{
				this.height = origHeights[index];
			}
		});
	}
}
