 $(document).ready(function(){  
			$(".photo").wrapAll("<div id='photo-list' class='clearfix'></div>");
			$(".gallery").wrapAll("<div id='gallery-list' class='clearfix'></div>");    
			  /**
			 * Aligns a grid of objects
			 * 
			 * @param cols       The number of columns in the grid
			 * @param cellWidth  the width of each cell
			 * @param cellHeight the height of each cell
			 * @param padding    the padding between the cells
			 */
			function alignGrid(/*string*/ id, /*int*/ cols, /*int*/ cellWidth, /*int*/ cellHeight, /*int*/ padding) {

			    var x = 0;
			    var y = 0;
			    var count = 1;

			    jQuery("#" + id).each(function() {
			        jQuery(this).css("position", "relative");

			        jQuery(this).children("div").each(function() {
			            jQuery(this).css("width", cellWidth + "em");
			            jQuery(this).css("height", cellHeight + "em");
			            jQuery(this).css("position", "absolute");

			            jQuery(this).css("left", x + "em");
			            jQuery(this).css("top", y + "em");

			            if ((count % cols) == 0) {
			                x = 0;
			                y += cellHeight + padding;
			            } else {
			                x += cellWidth + padding;
			            }

			            count++;
			        });
			    });
			  
			   var parentpos = jQuery("#" + id).offset();
			   var childpos = jQuery("#" + id).children("div:last").offset();
			   var childheight  = jQuery("#" + id).children("div:last").outerHeight();   
			   jQuery("#" + id).css({"height": (childpos.top - parentpos.top) + childheight + 10 + "px"});
				
			}
			
			
			alignGrid("photo-list", 4 , 15, 11, 2);
			alignGrid("gallery-list", 2 , 33, 15, 2);  
			
			$(".photo, .gallery").hover(function(){ 
				$(this).fadeTo(100,.75);
				},function(){
				 $(this).fadeTo(100,1);
				}); 
		  
		
		 /* //setting heights of containers since .photo & .gallery items are abs pos	
		  var prepos =  $(".photo:last").offset();
		  var preheight = $(".photo:last").outerHeight();
		  var pos = $("#photo-list").offset();
		
		  $("#photo-list").css({"height": (prepos.top - pos.top) + preheight + 10 + "px"}); 
		
		 var prepos =  $(".gallery:last").offset();
		 var preheight = $(".gallery:last").outerHeight();
		 var pos = $("#gallery-list").offset(); 
		
		$("#gallery-list").css({"height": (prepos.top - pos.top) + preheight + 10 + "px"}); */ 
			
		});    