//rollovers
portnav = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" portnav";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" portnav\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", portnav);

(function ($) {//function to set heights based on tallest element in the world
			$.fn.equalHeight = function () {
				var tallest = 0;
				$(this).each(function() {
					$(this).css('height','auto');
					var thisHeight = $(this).height();
					if(thisHeight > tallest) {
						tallest = thisHeight;
					}
				});
				$(this).height(tallest);
			};
		})($);

$(document).ready(function(){
	$('#vid-wrapper .vid-thumb:nth-child(4n), #print-wrapper .print-thumb:nth-child(4n)').addClass('last-in-row');	
	
	var vidThumbs = $("#vid-wrapper .vid-thumb");
	for(var i = 0; i < vidThumbs.length; i+=4) {
	  vidThumbs.slice(i, i+4).wrapAll("<div class='thumb-row'></div>");
	}
	  
	var printThumbs = $("#print-wrapper .print-thumb");
	for(var i = 0; i < printThumbs.length; i+=4) {
	  printThumbs.slice(i, i+4).wrapAll("<div class='thumb-row'></div>");
	}
	
	  
	$('.thumb span:last-child').addClass('last-child');
	
	$(window).load(function () {
		$('.thumb-row').each(function(index) { //give every common module row a unique class
			$(this).children('.thumb').equalHeight();
		});
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto();//Initialize PrettyPhoto

});

